mirror of
git://git.gnupg.org/gnupg.git
synced 2024-12-22 10:19:57 +01:00
(open_info_file): New.
(main): Unconditionally implement --status-file, --logger-file, --attribute-file, --passphrase-file, --command-file. This is not generally useful but easy to support and might make scripting under Windows easier.
This commit is contained in:
parent
42dfecadf7
commit
3220faf7f7
2
AUTHORS
2
AUTHORS
@ -9,7 +9,7 @@ Authors
|
||||
|
||||
Birger Langkjer <birger.langkjer@image.dk> Translations [da]
|
||||
|
||||
Britov Ivanovich <maxbritov@tut.by> Translations [ru]
|
||||
Maxim Britov <maxbritov@tut.by> Translations [ru]
|
||||
|
||||
Daniel Resare <daniel@resare.com> Translations [sv]
|
||||
|
||||
|
@ -7,6 +7,11 @@
|
||||
* README, configure.ac: Add --enable-backsigs to enable the
|
||||
experimental backsigs code.
|
||||
|
||||
2004-11-04 Werner Koch <wk@g10code.com>
|
||||
|
||||
* AUTHORS: Use Maxim Britov. I am not that accustomed to the
|
||||
Russian way of writing names.
|
||||
|
||||
2004-10-28 Werner Koch <wk@g10code.com>
|
||||
|
||||
Released 1.3.92.
|
||||
|
2
README
2
README
@ -603,7 +603,7 @@
|
||||
|
||||
--enable-selinux-support
|
||||
This prevents access to certain files and won't
|
||||
allow import or export of secret keys.
|
||||
allow import or export of secret keys.
|
||||
|
||||
--disable-gnupg-iconv
|
||||
If iconv is available it is used to convert
|
||||
|
@ -1,3 +1,27 @@
|
||||
2004-11-17 Werner Koch <wk@g10code.com>
|
||||
|
||||
* g10.c (open_info_file): New.
|
||||
(main): Unconditionally implement --status-file, --logger-file,
|
||||
--attribute-file, --passphrase-file, --command-file. This is not
|
||||
generally useful but easy to support and might make scripting
|
||||
under Windows easier.
|
||||
|
||||
2004-11-11 Werner Koch <wk@g10code.com>
|
||||
|
||||
* passphrase.c (readn): Fixed test against EINTR.
|
||||
|
||||
2004-11-05 Werner Koch <wk@g10code.com>
|
||||
|
||||
* app-openpgp.c: Made more strings translatable.
|
||||
(verify_chv3, do_change_pin): Add a special prefix to the prompt
|
||||
of the Admin PIN prompts.
|
||||
* passphrase.c (ask_passphrase): Add arg TRYAGAIN_TEXT. Changed
|
||||
call callers.
|
||||
* cardglue.c (pin_cb): Make use of the OPAQUE arg to pass
|
||||
arguments to the PIN callback. Use this to implement a way to
|
||||
check for correct PIN repetition. Changed all callers to pass an
|
||||
opaque argument. Improved detection of Admin PIN prompts.
|
||||
|
||||
2004-11-04 David Shaw <dshaw@jabberwocky.com>
|
||||
|
||||
* plaintext.c (handle_plaintext): Don't try and create a
|
||||
@ -20,9 +44,9 @@
|
||||
|
||||
2004-11-03 Timo Schulz <twoaday@g10code.com>
|
||||
|
||||
* passphrase.c (readn, writen): Use w32_strerror instead
|
||||
* passphrase.c (readn, writen): Use w32_strerror instead
|
||||
of just showing the error number.
|
||||
* misc.c [_WIN32]: Fix warning about missing prototypes.
|
||||
* misc.c [_WIN32]: Fix warning about missing prototypes.
|
||||
|
||||
2004-10-28 David Shaw <dshaw@jabberwocky.com>
|
||||
|
||||
|
@ -815,7 +815,10 @@ verify_chv3 (app_t app,
|
||||
" is permanently locked\n"), value[6]);
|
||||
xfree (relptr);
|
||||
|
||||
rc = pincb (pincb_arg, _("Admin PIN"), &pinvalue);
|
||||
/* Note to translators: Do not translate the "|A|" prefix but
|
||||
keep it at the start of the string. We need this elsewhere
|
||||
to get some infos on the string. */
|
||||
rc = pincb (pincb_arg, _("|A|Admin PIN"), &pinvalue);
|
||||
if (rc)
|
||||
{
|
||||
log_info (_("PIN callback returned error: %s\n"), gpg_strerror (rc));
|
||||
@ -953,10 +956,14 @@ do_change_pin (app_t app, ctrl_t ctrl, const char *chvnostr, int reset_mode,
|
||||
else
|
||||
app->did_chv1 = app->did_chv2 = 0;
|
||||
|
||||
rc = pincb (pincb_arg, chvno == 3? "New Admin PIN" : "New PIN", &pinvalue);
|
||||
/* Note to translators: Do not translate the "|A|" prefix but
|
||||
keep it at the start of the string. We need this elsewhere
|
||||
to get some infos on the string. */
|
||||
rc = pincb (pincb_arg, chvno == 3? _("|A|New Admin PIN") : _("New PIN"),
|
||||
&pinvalue);
|
||||
if (rc)
|
||||
{
|
||||
log_error ("error getting new PIN: %s\n", gpg_strerror (rc));
|
||||
log_error (_("error getting new PIN: %s\n"), gpg_strerror (rc));
|
||||
goto leave;
|
||||
}
|
||||
|
||||
@ -1022,14 +1029,14 @@ do_genkey (app_t app, ctrl_t ctrl, const char *keynostr, unsigned int flags,
|
||||
rc = iso7816_get_data (app->slot, 0x006E, &buffer, &buflen);
|
||||
if (rc)
|
||||
{
|
||||
log_error ("error reading application data\n");
|
||||
log_error (_("error reading application data\n"));
|
||||
return gpg_error (GPG_ERR_GENERAL);
|
||||
}
|
||||
fpr = find_tlv (buffer, buflen, 0x00C5, &n);
|
||||
if (!fpr || n != 60)
|
||||
{
|
||||
rc = gpg_error (GPG_ERR_GENERAL);
|
||||
log_error ("error reading fingerprint DO\n");
|
||||
log_error (_("error reading fingerprint DO\n"));
|
||||
goto leave;
|
||||
}
|
||||
fpr += 20*keyno;
|
||||
@ -1038,13 +1045,13 @@ do_genkey (app_t app, ctrl_t ctrl, const char *keynostr, unsigned int flags,
|
||||
if (i!=20 && !force)
|
||||
{
|
||||
rc = gpg_error (GPG_ERR_EEXIST);
|
||||
log_error ("key already exists\n");
|
||||
log_error (_("key already exists\n"));
|
||||
goto leave;
|
||||
}
|
||||
else if (i!=20)
|
||||
log_info ("existing key will be replaced\n");
|
||||
log_info (_("existing key will be replaced\n"));
|
||||
else
|
||||
log_info ("generating new key\n");
|
||||
log_info (_("generating new key\n"));
|
||||
|
||||
|
||||
rc = verify_chv3 (app, pincb, pincb_arg);
|
||||
@ -1054,7 +1061,7 @@ do_genkey (app_t app, ctrl_t ctrl, const char *keynostr, unsigned int flags,
|
||||
xfree (buffer); buffer = NULL;
|
||||
|
||||
#if 1
|
||||
log_info ("please wait while key is being generated ...\n");
|
||||
log_info (_("please wait while key is being generated ...\n"));
|
||||
start_at = time (NULL);
|
||||
rc = iso7816_generate_keypair
|
||||
#else
|
||||
@ -1069,16 +1076,16 @@ do_genkey (app_t app, ctrl_t ctrl, const char *keynostr, unsigned int flags,
|
||||
if (rc)
|
||||
{
|
||||
rc = gpg_error (GPG_ERR_CARD);
|
||||
log_error ("generating key failed\n");
|
||||
log_error (_("generating key failed\n"));
|
||||
goto leave;
|
||||
}
|
||||
log_info ("key generation completed (%d seconds)\n",
|
||||
log_info (_("key generation completed (%d seconds)\n"),
|
||||
(int)(time (NULL) - start_at));
|
||||
keydata = find_tlv (buffer, buflen, 0x7F49, &keydatalen);
|
||||
if (!keydata)
|
||||
{
|
||||
rc = gpg_error (GPG_ERR_CARD);
|
||||
log_error ("response does not contain the public key data\n");
|
||||
log_error (_("response does not contain the public key data\n"));
|
||||
goto leave;
|
||||
}
|
||||
|
||||
@ -1086,7 +1093,7 @@ do_genkey (app_t app, ctrl_t ctrl, const char *keynostr, unsigned int flags,
|
||||
if (!m)
|
||||
{
|
||||
rc = gpg_error (GPG_ERR_CARD);
|
||||
log_error ("response does not contain the RSA modulus\n");
|
||||
log_error (_("response does not contain the RSA modulus\n"));
|
||||
goto leave;
|
||||
}
|
||||
/* log_printhex ("RSA n:", m, mlen); */
|
||||
@ -1096,7 +1103,7 @@ do_genkey (app_t app, ctrl_t ctrl, const char *keynostr, unsigned int flags,
|
||||
if (!e)
|
||||
{
|
||||
rc = gpg_error (GPG_ERR_CARD);
|
||||
log_error ("response does not contain the RSA public exponent\n");
|
||||
log_error (_("response does not contain the RSA public exponent\n"));
|
||||
goto leave;
|
||||
}
|
||||
/* log_printhex ("RSA e:", e, elen); */
|
||||
@ -1129,7 +1136,7 @@ convert_sig_counter_value (const unsigned char *value, size_t valuelen)
|
||||
ul = (value[0] << 16) | (value[1] << 8) | value[2];
|
||||
else
|
||||
{
|
||||
log_error ("invalid structure of OpenPGP card (DO 0x93)\n");
|
||||
log_error (_("invalid structure of OpenPGP card (DO 0x93)\n"));
|
||||
ul = 0;
|
||||
}
|
||||
return ul;
|
||||
@ -1164,14 +1171,14 @@ compare_fingerprint (app_t app, int keyno, unsigned char *sha1fpr)
|
||||
rc = get_cached_data (app, 0x006E, &buffer, &buflen);
|
||||
if (rc)
|
||||
{
|
||||
log_error ("error reading application data\n");
|
||||
log_error (_("error reading application data\n"));
|
||||
return gpg_error (GPG_ERR_GENERAL);
|
||||
}
|
||||
fpr = find_tlv (buffer, buflen, 0x00C5, &n);
|
||||
if (!fpr || n != 60)
|
||||
{
|
||||
xfree (buffer);
|
||||
log_error ("error reading fingerprint DO\n");
|
||||
log_error (_("error reading fingerprint DO\n"));
|
||||
return gpg_error (GPG_ERR_GENERAL);
|
||||
}
|
||||
fpr += (keyno-1)*20;
|
||||
@ -1290,7 +1297,7 @@ do_sign (app_t app, const char *keyidstr, int hashalgo,
|
||||
memcpy (data+15, indata, indatalen);
|
||||
|
||||
sigcount = get_sig_counter (app);
|
||||
log_info ("signatures created so far: %lu\n", sigcount);
|
||||
log_info (_("signatures created so far: %lu\n"), sigcount);
|
||||
|
||||
if (!app->did_chv1 || app->force_chv1 )
|
||||
{
|
||||
|
@ -49,6 +49,12 @@ struct ctrl_ctx_s {
|
||||
};
|
||||
|
||||
|
||||
struct pin_cb_info_s
|
||||
{
|
||||
int repeat;
|
||||
};
|
||||
|
||||
|
||||
static char *default_reader_port;
|
||||
static APP current_app;
|
||||
|
||||
@ -620,28 +626,69 @@ agent_scd_getattr (const char *name, struct agent_card_info_s *info)
|
||||
static int
|
||||
pin_cb (void *opaque, const char *info, char **retstr)
|
||||
{
|
||||
struct pin_cb_info_s *parm = opaque;
|
||||
char *value;
|
||||
int canceled;
|
||||
int isadmin = (info && strstr (info, "dmin"));
|
||||
|
||||
int isadmin = 0;
|
||||
const char *again_text = NULL;
|
||||
|
||||
*retstr = NULL;
|
||||
log_debug ("asking for PIN '%s'\n", info);
|
||||
|
||||
/* We use a special prefix to check whether the Admin PIN has been
|
||||
requested. */
|
||||
if (info && !strncmp (info, "|A|", 3))
|
||||
{
|
||||
isadmin = 1;
|
||||
info += 3;
|
||||
}
|
||||
|
||||
again:
|
||||
if (is_status_enabled())
|
||||
write_status_text (STATUS_NEED_PASSPHRASE_PIN,
|
||||
isadmin? "OPENPGP 3" : "OPENPGP 1");
|
||||
|
||||
value = ask_passphrase (info,
|
||||
value = ask_passphrase (info, again_text,
|
||||
isadmin? "passphrase.adminpin.ask"
|
||||
: "passphrase.pin.ask",
|
||||
isadmin? _("Enter Admin PIN: ") : _("Enter PIN: "),
|
||||
isadmin? _("Enter Admin PIN: ")
|
||||
: _("Enter PIN: "),
|
||||
&canceled);
|
||||
again_text = NULL;
|
||||
if (!value && canceled)
|
||||
return -1;
|
||||
else if (!value)
|
||||
return G10ERR_GENERAL;
|
||||
|
||||
if (parm->repeat)
|
||||
{
|
||||
char *value2;
|
||||
|
||||
value2 = ask_passphrase (info, NULL,
|
||||
"passphrase.pin.repeat",
|
||||
_("Repeat this PIN: "),
|
||||
&canceled);
|
||||
if (!value && canceled)
|
||||
{
|
||||
xfree (value);
|
||||
return -1;
|
||||
}
|
||||
else if (!value)
|
||||
{
|
||||
xfree (value);
|
||||
return G10ERR_GENERAL;
|
||||
}
|
||||
if (strcmp (value, value2))
|
||||
{
|
||||
again_text = N_("PIN not correctly repeated; try again");
|
||||
xfree (value2);
|
||||
xfree (value);
|
||||
value = NULL;
|
||||
goto again;
|
||||
}
|
||||
xfree (value2);
|
||||
}
|
||||
|
||||
*retstr = value;
|
||||
return 0;
|
||||
}
|
||||
@ -654,12 +701,15 @@ agent_scd_setattr (const char *name,
|
||||
const unsigned char *value, size_t valuelen)
|
||||
{
|
||||
APP app;
|
||||
struct pin_cb_info_s parm;
|
||||
|
||||
memset (&parm, 0, sizeof parm);
|
||||
|
||||
app = current_app? current_app : open_card ();
|
||||
if (!app)
|
||||
return gpg_error (GPG_ERR_CARD);
|
||||
|
||||
return app->fnc.setattr (app, name, pin_cb, NULL, value, valuelen);
|
||||
return app->fnc.setattr (app, name, pin_cb, &parm, value, valuelen);
|
||||
}
|
||||
|
||||
|
||||
@ -670,7 +720,7 @@ genkey_status_cb (void *opaque, const char *line)
|
||||
const char *keyword = line;
|
||||
int keywordlen;
|
||||
|
||||
log_debug ("got status line `%s'\n", line);
|
||||
/* log_debug ("got status line `%s'\n", line); */
|
||||
for (keywordlen=0; *line && !spacep (line); line++, keywordlen++)
|
||||
;
|
||||
while (spacep (line))
|
||||
@ -722,6 +772,9 @@ agent_scd_genkey (struct agent_card_genkey_s *info, int keyno, int force)
|
||||
APP app;
|
||||
char keynostr[20];
|
||||
struct ctrl_ctx_s ctrl;
|
||||
struct pin_cb_info_s parm;
|
||||
|
||||
memset (&parm, 0, sizeof parm);
|
||||
|
||||
app = current_app? current_app : open_card ();
|
||||
if (!app)
|
||||
@ -734,7 +787,7 @@ agent_scd_genkey (struct agent_card_genkey_s *info, int keyno, int force)
|
||||
|
||||
return app->fnc.genkey (app, &ctrl, keynostr,
|
||||
force? 1:0,
|
||||
pin_cb, NULL);
|
||||
pin_cb, &parm);
|
||||
}
|
||||
|
||||
/* Send a PKSIGN command to the SCdaemon. */
|
||||
@ -745,6 +798,9 @@ agent_scd_pksign (const char *serialno, int hashalgo,
|
||||
{
|
||||
APP app;
|
||||
int rc;
|
||||
struct pin_cb_info_s parm;
|
||||
|
||||
memset (&parm, 0, sizeof parm);
|
||||
|
||||
*r_buf = NULL;
|
||||
*r_buflen = 0;
|
||||
@ -761,7 +817,7 @@ agent_scd_pksign (const char *serialno, int hashalgo,
|
||||
return rc;
|
||||
|
||||
return app->fnc.sign (app, serialno, hashalgo,
|
||||
pin_cb, NULL,
|
||||
pin_cb, &parm,
|
||||
indata, indatalen,
|
||||
r_buf, r_buflen);
|
||||
}
|
||||
@ -775,6 +831,9 @@ agent_scd_pkdecrypt (const char *serialno,
|
||||
{
|
||||
APP app;
|
||||
int rc;
|
||||
struct pin_cb_info_s parm;
|
||||
|
||||
memset (&parm, 0, sizeof parm);
|
||||
|
||||
*r_buf = NULL;
|
||||
*r_buflen = 0;
|
||||
@ -791,7 +850,7 @@ agent_scd_pkdecrypt (const char *serialno,
|
||||
return rc;
|
||||
|
||||
return app->fnc.decipher (app, serialno,
|
||||
pin_cb, NULL,
|
||||
pin_cb, &parm,
|
||||
indata, indatalen,
|
||||
r_buf, r_buflen);
|
||||
}
|
||||
@ -803,6 +862,10 @@ agent_scd_change_pin (int chvno)
|
||||
APP app;
|
||||
char chvnostr[20];
|
||||
int reset = 0;
|
||||
struct pin_cb_info_s parm;
|
||||
|
||||
memset (&parm, 0, sizeof parm);
|
||||
parm.repeat = 1;
|
||||
|
||||
reset = (chvno >= 100);
|
||||
chvno %= 100;
|
||||
@ -813,7 +876,7 @@ agent_scd_change_pin (int chvno)
|
||||
|
||||
sprintf (chvnostr, "%d", chvno);
|
||||
return app->fnc.change_pin (app, NULL, chvnostr, reset,
|
||||
pin_cb, NULL);
|
||||
pin_cb, &parm);
|
||||
}
|
||||
|
||||
/* Perform a CHECKPIN operation. SERIALNO should be the serial
|
||||
@ -823,12 +886,15 @@ int
|
||||
agent_scd_checkpin (const char *serialnobuf)
|
||||
{
|
||||
APP app;
|
||||
struct pin_cb_info_s parm;
|
||||
|
||||
memset (&parm, 0, sizeof parm);
|
||||
|
||||
app = current_app? current_app : open_card ();
|
||||
if (!app)
|
||||
return gpg_error (GPG_ERR_CARD);
|
||||
|
||||
return app->fnc.check_pin (app, serialnobuf, pin_cb, NULL);
|
||||
return app->fnc.check_pin (app, serialnobuf, pin_cb, &parm);
|
||||
}
|
||||
|
||||
|
||||
@ -841,6 +907,9 @@ agent_openpgp_storekey (int keyno,
|
||||
const unsigned char *e, size_t elen)
|
||||
{
|
||||
APP app;
|
||||
struct pin_cb_info_s parm;
|
||||
|
||||
memset (&parm, 0, sizeof parm);
|
||||
|
||||
app = current_app? current_app : open_card ();
|
||||
if (!app)
|
||||
@ -848,5 +917,5 @@ agent_openpgp_storekey (int keyno,
|
||||
|
||||
return app_openpgp_storekey (app, keyno, template, template_len,
|
||||
created_at, m, mlen, e, elen,
|
||||
pin_cb, NULL);
|
||||
pin_cb, &parm);
|
||||
}
|
||||
|
110
g10/g10.c
110
g10/g10.c
@ -33,6 +33,7 @@
|
||||
#ifdef HAVE_STAT
|
||||
#include <sys/stat.h> /* for stat() */
|
||||
#endif
|
||||
#include <fcntl.h>
|
||||
|
||||
#define INCLUDED_BY_MAIN_MODULE 1
|
||||
#include "packet.h"
|
||||
@ -57,6 +58,12 @@
|
||||
#include "ccid-driver.h"
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_DOSISH_SYSTEM) || defined(__CYGWIN__)
|
||||
#define MY_O_BINARY O_BINARY
|
||||
#else
|
||||
#define MY_O_BINARY 0
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
enum cmd_and_opt_values
|
||||
@ -174,13 +181,9 @@ enum cmd_and_opt_values
|
||||
oDebugAll,
|
||||
oDebugCCIDDriver,
|
||||
oStatusFD,
|
||||
#ifdef __riscos__
|
||||
oStatusFile,
|
||||
#endif /* __riscos__ */
|
||||
oAttributeFD,
|
||||
#ifdef __riscos__
|
||||
oAttributeFile,
|
||||
#endif /* __riscos__ */
|
||||
oSKComments,
|
||||
oNoSKComments,
|
||||
oEmitVersion,
|
||||
@ -205,13 +208,9 @@ enum cmd_and_opt_values
|
||||
oBZ2CompressLevel,
|
||||
oBZ2DecompressLowmem,
|
||||
oPasswdFD,
|
||||
#ifdef __riscos__
|
||||
oPasswdFile,
|
||||
#endif /* __riscos__ */
|
||||
oCommandFD,
|
||||
#ifdef __riscos__
|
||||
oCommandFile,
|
||||
#endif /* __riscos__ */
|
||||
oQuickRandom,
|
||||
oNoVerbose,
|
||||
oTrustDBName,
|
||||
@ -284,9 +283,7 @@ enum cmd_and_opt_values
|
||||
oHiddenEncryptTo,
|
||||
oNoEncryptTo,
|
||||
oLoggerFD,
|
||||
#ifdef __riscos__
|
||||
oLoggerFile,
|
||||
#endif /* __riscos__ */
|
||||
oUtf8Strings,
|
||||
oNoUtf8Strings,
|
||||
oDisableCipherAlgo,
|
||||
@ -487,13 +484,9 @@ static ARGPARSE_OPTS opts[] = {
|
||||
{ oDebug, "debug" ,4|16, "@"},
|
||||
{ oDebugAll, "debug-all" ,0, "@"},
|
||||
{ oStatusFD, "status-fd" ,1, "@"},
|
||||
#ifdef __riscos__
|
||||
{ oStatusFile, "status-file" ,2, "@"},
|
||||
#endif /* __riscos__ */
|
||||
{ oAttributeFD, "attribute-fd" ,1, "@" },
|
||||
#ifdef __riscos__
|
||||
{ oAttributeFile, "attribute-file" ,2, "@" },
|
||||
#endif /* __riscos__ */
|
||||
{ oNoSKComments, "no-sk-comments", 0, "@"},
|
||||
{ oSKComments, "sk-comments", 0, "@"},
|
||||
{ oCompletesNeeded, "completes-needed", 1, "@"},
|
||||
@ -554,17 +547,13 @@ static ARGPARSE_OPTS opts[] = {
|
||||
{ aPipeMode, "pipemode", 0, "@" },
|
||||
{ oKOption, NULL, 0, "@"},
|
||||
{ oPasswdFD, "passphrase-fd",1, "@" },
|
||||
#ifdef __riscos__
|
||||
{ oPasswdFile, "passphrase-file",2, "@" },
|
||||
#endif /* __riscos__ */
|
||||
{ oCommandFD, "command-fd",1, "@" },
|
||||
#ifdef __riscos__
|
||||
{ oCommandFile, "command-file",2, "@" },
|
||||
#endif /* __riscos__ */
|
||||
{ oQuickRandom, "quick-random", 0, "@"},
|
||||
{ oNoVerbose, "no-verbose", 0, "@"},
|
||||
{ oTrustDBName, "trustdb-name", 2, "@" },
|
||||
{ oNoSecmemWarn, "no-secmem-warning", 0, "@" }, /* used only by regression tests */
|
||||
{ oNoSecmemWarn, "no-secmem-warning", 0, "@" },
|
||||
{ oNoPermissionWarn, "no-permission-warning", 0, "@" },
|
||||
{ oNoMDCWarn, "no-mdc-warning", 0, "@" },
|
||||
{ oNoArmor, "no-armor", 0, "@"},
|
||||
@ -613,9 +602,7 @@ static ARGPARSE_OPTS opts[] = {
|
||||
{ oLockMultiple, "lock-multiple", 0, "@" },
|
||||
{ oLockNever, "lock-never", 0, "@" },
|
||||
{ oLoggerFD, "logger-fd",1, "@" },
|
||||
#ifdef __riscos__
|
||||
{ oLoggerFile, "logger-file",2, "@" },
|
||||
#endif /* __riscos__ */
|
||||
{ oUseEmbeddedFilename, "use-embedded-filename", 0, "@" },
|
||||
{ oNoUseEmbeddedFilename, "no-use-embedded-filename", 0, "@" },
|
||||
{ oUtf8Strings, "utf8-strings", 0, "@" },
|
||||
@ -930,6 +917,51 @@ set_screen_dimensions(void)
|
||||
}
|
||||
|
||||
|
||||
/* Helper to open a file FNAME either for reading or writing to be
|
||||
used with --status-file etc functions. Not generally useful but it
|
||||
avoids the riscos specific functions and well some Windows people
|
||||
might like it too. Prints an error message and returns -1 on
|
||||
error. On success the file descriptor is returned. */
|
||||
static int
|
||||
open_info_file (const char *fname, int for_write)
|
||||
{
|
||||
#ifdef __riscos__
|
||||
return riscos_fdopenfile (fname, for_write);
|
||||
#elif defined (ENABLE_SELINUX_HACKS)
|
||||
/* We can't allow these even when testing for a secured filename
|
||||
because files to be secured might not yet been secured. This is
|
||||
similar to the option file but in that case it is unlikely that
|
||||
sensitive information may be retrieved by means of error
|
||||
messages. */
|
||||
return -1;
|
||||
#else
|
||||
int fd;
|
||||
|
||||
/* if (is_secured_filename (fname)) */
|
||||
/* { */
|
||||
/* fd = -1; */
|
||||
/* errno = EPERM; */
|
||||
/* } */
|
||||
/* else */
|
||||
/* { */
|
||||
do
|
||||
{
|
||||
if (for_write)
|
||||
fd = open (fname, O_CREAT | O_TRUNC | O_WRONLY,
|
||||
S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP);
|
||||
else
|
||||
fd = open (fname, O_RDONLY | MY_O_BINARY);
|
||||
}
|
||||
while (fd == -1 && errno == EINTR);
|
||||
/* } */
|
||||
if ( fd == -1)
|
||||
log_error ( for_write? _("can't create `%s': %s\n")
|
||||
: _("can't open `%s': %s\n"), fname, strerror(errno));
|
||||
|
||||
return fd;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void
|
||||
set_cmd( enum cmd_and_opt_values *ret_cmd, enum cmd_and_opt_values new_cmd )
|
||||
{
|
||||
@ -1950,34 +1982,30 @@ main( int argc, char **argv )
|
||||
case oStatusFD:
|
||||
set_status_fd( iobuf_translate_file_handle (pargs.r.ret_int, 1) );
|
||||
break;
|
||||
#ifdef __riscos__
|
||||
case oStatusFile:
|
||||
set_status_fd( iobuf_translate_file_handle ( riscos_fdopenfile (pargs.r.ret_str, 1), 1) );
|
||||
set_status_fd ( open_info_file (pargs.r.ret_str, 1) );
|
||||
break;
|
||||
#endif /* __riscos__ */
|
||||
case oAttributeFD:
|
||||
set_attrib_fd(iobuf_translate_file_handle (pargs.r.ret_int, 1));
|
||||
break;
|
||||
#ifdef __riscos__
|
||||
case oAttributeFile:
|
||||
set_attrib_fd(iobuf_translate_file_handle ( riscos_fdopenfile (pargs.r.ret_str, 1), 1) );
|
||||
set_attrib_fd ( open_info_file (pargs.r.ret_str, 1) );
|
||||
break;
|
||||
#endif /* __riscos__ */
|
||||
case oLoggerFD:
|
||||
log_set_logfile( NULL,
|
||||
iobuf_translate_file_handle (pargs.r.ret_int, 1) );
|
||||
iobuf_translate_file_handle (pargs.r.ret_int, 1));
|
||||
break;
|
||||
#ifdef __riscos__
|
||||
case oLoggerFile:
|
||||
log_set_logfile( NULL,
|
||||
iobuf_translate_file_handle ( riscos_fdopenfile (pargs.r.ret_str, 1), 1) );
|
||||
log_set_logfile( NULL, open_info_file (pargs.r.ret_str, 1) );
|
||||
break;
|
||||
#endif /* __riscos__ */
|
||||
|
||||
case oWithFingerprint:
|
||||
opt.with_fingerprint = 1;
|
||||
with_fpr=1; /*fall thru*/
|
||||
case oFingerprint: opt.fingerprint++; break;
|
||||
case oSecretKeyring: append_to_strlist( &sec_nrings, pargs.r.ret_str); break;
|
||||
case oSecretKeyring:
|
||||
append_to_strlist( &sec_nrings, pargs.r.ret_str);
|
||||
break;
|
||||
case oOptions:
|
||||
/* config files may not be nested (silently ignore them) */
|
||||
if( !configfp ) {
|
||||
@ -2212,21 +2240,21 @@ main( int argc, char **argv )
|
||||
pwfd = iobuf_translate_file_handle (pargs.r.ret_int, 0);
|
||||
opt.use_agent = 0;
|
||||
break;
|
||||
#ifdef __riscos__
|
||||
case oPasswdFile:
|
||||
pwfd = iobuf_translate_file_handle ( riscos_fdopenfile (pargs.r.ret_str, 0), 0);
|
||||
pwfd = open_info_file (pargs.r.ret_str, 0);
|
||||
break;
|
||||
#endif /* __riscos__ */
|
||||
case oCommandFD:
|
||||
opt.command_fd = iobuf_translate_file_handle (pargs.r.ret_int, 0);
|
||||
break;
|
||||
#ifdef __riscos__
|
||||
case oCommandFile:
|
||||
opt.command_fd = iobuf_translate_file_handle ( riscos_fdopenfile (pargs.r.ret_str, 0), 0);
|
||||
opt.command_fd = open_info_file (pargs.r.ret_str, 0);
|
||||
break;
|
||||
case oCipherAlgo:
|
||||
def_cipher_string = m_strdup(pargs.r.ret_str);
|
||||
break;
|
||||
case oDigestAlgo:
|
||||
def_digest_string = m_strdup(pargs.r.ret_str);
|
||||
break;
|
||||
#endif /* __riscos__ */
|
||||
case oCipherAlgo: def_cipher_string = m_strdup(pargs.r.ret_str); break;
|
||||
case oDigestAlgo: def_digest_string = m_strdup(pargs.r.ret_str); break;
|
||||
case oCompressAlgo:
|
||||
/* If it is all digits, stick a Z in front of it for
|
||||
later. This is for backwards compatibility with
|
||||
|
@ -187,7 +187,9 @@ int build_sk_list( STRLIST locusr, SK_LIST *ret_sk_list,
|
||||
int have_static_passphrase(void);
|
||||
void read_passphrase_from_fd( int fd );
|
||||
void passphrase_clear_cache ( u32 *keyid, int algo );
|
||||
char *ask_passphrase (const char *description, const char *promptid,
|
||||
char *ask_passphrase (const char *description,
|
||||
const char *tryagain_text,
|
||||
const char *promptid,
|
||||
const char *prompt, int *canceled);
|
||||
DEK *passphrase_to_dek( u32 *keyid, int pubkey_algo,
|
||||
int cipher_algo, STRING2KEY *s2k, int mode,
|
||||
|
@ -267,19 +267,20 @@ readn (int fd, void *buf, size_t buflen, size_t *ret_nread)
|
||||
size_t nleft = buflen;
|
||||
int nread;
|
||||
char *p;
|
||||
|
||||
|
||||
p = buf;
|
||||
while (nleft > 0)
|
||||
while( nleft > 0 )
|
||||
{
|
||||
nread = read (fd, buf, nleft);
|
||||
if (nread < 0)
|
||||
nread = read ( fd, buf, nleft );
|
||||
if( nread < 0 )
|
||||
{
|
||||
if (nread == EINTR)
|
||||
if (errno == EINTR)
|
||||
nread = 0;
|
||||
else {
|
||||
log_error ("read() error: %s\n", strerror (errno));
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
log_error ( "read() error: %s\n", strerror (errno) );
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else if (!nread)
|
||||
break; /* EOF */
|
||||
@ -1030,6 +1031,7 @@ passphrase_clear_cache ( u32 *keyid, int algo )
|
||||
*/
|
||||
char *
|
||||
ask_passphrase (const char *description,
|
||||
const char *tryagain_text,
|
||||
const char *promptid,
|
||||
const char *prompt, int *canceled)
|
||||
{
|
||||
@ -1044,7 +1046,9 @@ ask_passphrase (const char *description,
|
||||
agent_died:
|
||||
if ( opt.use_agent )
|
||||
{
|
||||
pw = agent_get_passphrase (NULL, 0, description, canceled );
|
||||
pw = agent_get_passphrase (NULL, 0,
|
||||
tryagain_text? tryagain_text :description,
|
||||
canceled );
|
||||
if (!pw)
|
||||
{
|
||||
if (!opt.use_agent)
|
||||
@ -1063,6 +1067,8 @@ ask_passphrase (const char *description,
|
||||
pw = NULL;
|
||||
}
|
||||
else {
|
||||
if (tryagain_text)
|
||||
tty_printf(_("%s.\n"), tryagain_text);
|
||||
pw = cpr_get_hidden(promptid? promptid : "passphrase.ask",
|
||||
prompt?prompt : _("Enter passphrase: ") );
|
||||
tty_kill_prompt();
|
||||
@ -1177,7 +1183,7 @@ passphrase_to_dek( u32 *keyid, int pubkey_algo,
|
||||
|
||||
agent_died:
|
||||
if( next_pw ) {
|
||||
/* Simply return the passpharse we already have in NEXT_PW. */
|
||||
/* Simply return the passphrase we already have in NEXT_PW. */
|
||||
pw = next_pw;
|
||||
next_pw = NULL;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user