mirror of
git://git.gnupg.org/gnupg.git
synced 2025-03-28 22:49:59 +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]
|
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]
|
Daniel Resare <daniel@resare.com> Translations [sv]
|
||||||
|
|
||||||
|
@ -7,6 +7,11 @@
|
|||||||
* README, configure.ac: Add --enable-backsigs to enable the
|
* README, configure.ac: Add --enable-backsigs to enable the
|
||||||
experimental backsigs code.
|
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>
|
2004-10-28 Werner Koch <wk@g10code.com>
|
||||||
|
|
||||||
Released 1.3.92.
|
Released 1.3.92.
|
||||||
|
2
README
2
README
@ -603,7 +603,7 @@
|
|||||||
|
|
||||||
--enable-selinux-support
|
--enable-selinux-support
|
||||||
This prevents access to certain files and won't
|
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
|
--disable-gnupg-iconv
|
||||||
If iconv is available it is used to convert
|
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>
|
2004-11-04 David Shaw <dshaw@jabberwocky.com>
|
||||||
|
|
||||||
* plaintext.c (handle_plaintext): Don't try and create a
|
* plaintext.c (handle_plaintext): Don't try and create a
|
||||||
@ -20,9 +44,9 @@
|
|||||||
|
|
||||||
2004-11-03 Timo Schulz <twoaday@g10code.com>
|
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.
|
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>
|
2004-10-28 David Shaw <dshaw@jabberwocky.com>
|
||||||
|
|
||||||
|
@ -815,7 +815,10 @@ verify_chv3 (app_t app,
|
|||||||
" is permanently locked\n"), value[6]);
|
" is permanently locked\n"), value[6]);
|
||||||
xfree (relptr);
|
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)
|
if (rc)
|
||||||
{
|
{
|
||||||
log_info (_("PIN callback returned error: %s\n"), gpg_strerror (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
|
else
|
||||||
app->did_chv1 = app->did_chv2 = 0;
|
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)
|
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;
|
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);
|
rc = iso7816_get_data (app->slot, 0x006E, &buffer, &buflen);
|
||||||
if (rc)
|
if (rc)
|
||||||
{
|
{
|
||||||
log_error ("error reading application data\n");
|
log_error (_("error reading application data\n"));
|
||||||
return gpg_error (GPG_ERR_GENERAL);
|
return gpg_error (GPG_ERR_GENERAL);
|
||||||
}
|
}
|
||||||
fpr = find_tlv (buffer, buflen, 0x00C5, &n);
|
fpr = find_tlv (buffer, buflen, 0x00C5, &n);
|
||||||
if (!fpr || n != 60)
|
if (!fpr || n != 60)
|
||||||
{
|
{
|
||||||
rc = gpg_error (GPG_ERR_GENERAL);
|
rc = gpg_error (GPG_ERR_GENERAL);
|
||||||
log_error ("error reading fingerprint DO\n");
|
log_error (_("error reading fingerprint DO\n"));
|
||||||
goto leave;
|
goto leave;
|
||||||
}
|
}
|
||||||
fpr += 20*keyno;
|
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)
|
if (i!=20 && !force)
|
||||||
{
|
{
|
||||||
rc = gpg_error (GPG_ERR_EEXIST);
|
rc = gpg_error (GPG_ERR_EEXIST);
|
||||||
log_error ("key already exists\n");
|
log_error (_("key already exists\n"));
|
||||||
goto leave;
|
goto leave;
|
||||||
}
|
}
|
||||||
else if (i!=20)
|
else if (i!=20)
|
||||||
log_info ("existing key will be replaced\n");
|
log_info (_("existing key will be replaced\n"));
|
||||||
else
|
else
|
||||||
log_info ("generating new key\n");
|
log_info (_("generating new key\n"));
|
||||||
|
|
||||||
|
|
||||||
rc = verify_chv3 (app, pincb, pincb_arg);
|
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;
|
xfree (buffer); buffer = NULL;
|
||||||
|
|
||||||
#if 1
|
#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);
|
start_at = time (NULL);
|
||||||
rc = iso7816_generate_keypair
|
rc = iso7816_generate_keypair
|
||||||
#else
|
#else
|
||||||
@ -1069,16 +1076,16 @@ do_genkey (app_t app, ctrl_t ctrl, const char *keynostr, unsigned int flags,
|
|||||||
if (rc)
|
if (rc)
|
||||||
{
|
{
|
||||||
rc = gpg_error (GPG_ERR_CARD);
|
rc = gpg_error (GPG_ERR_CARD);
|
||||||
log_error ("generating key failed\n");
|
log_error (_("generating key failed\n"));
|
||||||
goto leave;
|
goto leave;
|
||||||
}
|
}
|
||||||
log_info ("key generation completed (%d seconds)\n",
|
log_info (_("key generation completed (%d seconds)\n"),
|
||||||
(int)(time (NULL) - start_at));
|
(int)(time (NULL) - start_at));
|
||||||
keydata = find_tlv (buffer, buflen, 0x7F49, &keydatalen);
|
keydata = find_tlv (buffer, buflen, 0x7F49, &keydatalen);
|
||||||
if (!keydata)
|
if (!keydata)
|
||||||
{
|
{
|
||||||
rc = gpg_error (GPG_ERR_CARD);
|
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;
|
goto leave;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1086,7 +1093,7 @@ do_genkey (app_t app, ctrl_t ctrl, const char *keynostr, unsigned int flags,
|
|||||||
if (!m)
|
if (!m)
|
||||||
{
|
{
|
||||||
rc = gpg_error (GPG_ERR_CARD);
|
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;
|
goto leave;
|
||||||
}
|
}
|
||||||
/* log_printhex ("RSA n:", m, mlen); */
|
/* 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)
|
if (!e)
|
||||||
{
|
{
|
||||||
rc = gpg_error (GPG_ERR_CARD);
|
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;
|
goto leave;
|
||||||
}
|
}
|
||||||
/* log_printhex ("RSA e:", e, elen); */
|
/* 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];
|
ul = (value[0] << 16) | (value[1] << 8) | value[2];
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
log_error ("invalid structure of OpenPGP card (DO 0x93)\n");
|
log_error (_("invalid structure of OpenPGP card (DO 0x93)\n"));
|
||||||
ul = 0;
|
ul = 0;
|
||||||
}
|
}
|
||||||
return ul;
|
return ul;
|
||||||
@ -1164,14 +1171,14 @@ compare_fingerprint (app_t app, int keyno, unsigned char *sha1fpr)
|
|||||||
rc = get_cached_data (app, 0x006E, &buffer, &buflen);
|
rc = get_cached_data (app, 0x006E, &buffer, &buflen);
|
||||||
if (rc)
|
if (rc)
|
||||||
{
|
{
|
||||||
log_error ("error reading application data\n");
|
log_error (_("error reading application data\n"));
|
||||||
return gpg_error (GPG_ERR_GENERAL);
|
return gpg_error (GPG_ERR_GENERAL);
|
||||||
}
|
}
|
||||||
fpr = find_tlv (buffer, buflen, 0x00C5, &n);
|
fpr = find_tlv (buffer, buflen, 0x00C5, &n);
|
||||||
if (!fpr || n != 60)
|
if (!fpr || n != 60)
|
||||||
{
|
{
|
||||||
xfree (buffer);
|
xfree (buffer);
|
||||||
log_error ("error reading fingerprint DO\n");
|
log_error (_("error reading fingerprint DO\n"));
|
||||||
return gpg_error (GPG_ERR_GENERAL);
|
return gpg_error (GPG_ERR_GENERAL);
|
||||||
}
|
}
|
||||||
fpr += (keyno-1)*20;
|
fpr += (keyno-1)*20;
|
||||||
@ -1290,7 +1297,7 @@ do_sign (app_t app, const char *keyidstr, int hashalgo,
|
|||||||
memcpy (data+15, indata, indatalen);
|
memcpy (data+15, indata, indatalen);
|
||||||
|
|
||||||
sigcount = get_sig_counter (app);
|
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 )
|
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 char *default_reader_port;
|
||||||
static APP current_app;
|
static APP current_app;
|
||||||
|
|
||||||
@ -620,28 +626,69 @@ agent_scd_getattr (const char *name, struct agent_card_info_s *info)
|
|||||||
static int
|
static int
|
||||||
pin_cb (void *opaque, const char *info, char **retstr)
|
pin_cb (void *opaque, const char *info, char **retstr)
|
||||||
{
|
{
|
||||||
|
struct pin_cb_info_s *parm = opaque;
|
||||||
char *value;
|
char *value;
|
||||||
int canceled;
|
int canceled;
|
||||||
int isadmin = (info && strstr (info, "dmin"));
|
int isadmin = 0;
|
||||||
|
const char *again_text = NULL;
|
||||||
|
|
||||||
*retstr = NULL;
|
*retstr = NULL;
|
||||||
log_debug ("asking for PIN '%s'\n", info);
|
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())
|
if (is_status_enabled())
|
||||||
write_status_text (STATUS_NEED_PASSPHRASE_PIN,
|
write_status_text (STATUS_NEED_PASSPHRASE_PIN,
|
||||||
isadmin? "OPENPGP 3" : "OPENPGP 1");
|
isadmin? "OPENPGP 3" : "OPENPGP 1");
|
||||||
|
|
||||||
value = ask_passphrase (info,
|
value = ask_passphrase (info, again_text,
|
||||||
isadmin? "passphrase.adminpin.ask"
|
isadmin? "passphrase.adminpin.ask"
|
||||||
: "passphrase.pin.ask",
|
: "passphrase.pin.ask",
|
||||||
isadmin? _("Enter Admin PIN: ") : _("Enter PIN: "),
|
isadmin? _("Enter Admin PIN: ")
|
||||||
|
: _("Enter PIN: "),
|
||||||
&canceled);
|
&canceled);
|
||||||
|
again_text = NULL;
|
||||||
if (!value && canceled)
|
if (!value && canceled)
|
||||||
return -1;
|
return -1;
|
||||||
else if (!value)
|
else if (!value)
|
||||||
return G10ERR_GENERAL;
|
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;
|
*retstr = value;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -654,12 +701,15 @@ agent_scd_setattr (const char *name,
|
|||||||
const unsigned char *value, size_t valuelen)
|
const unsigned char *value, size_t valuelen)
|
||||||
{
|
{
|
||||||
APP app;
|
APP app;
|
||||||
|
struct pin_cb_info_s parm;
|
||||||
|
|
||||||
|
memset (&parm, 0, sizeof parm);
|
||||||
|
|
||||||
app = current_app? current_app : open_card ();
|
app = current_app? current_app : open_card ();
|
||||||
if (!app)
|
if (!app)
|
||||||
return gpg_error (GPG_ERR_CARD);
|
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;
|
const char *keyword = line;
|
||||||
int keywordlen;
|
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++)
|
for (keywordlen=0; *line && !spacep (line); line++, keywordlen++)
|
||||||
;
|
;
|
||||||
while (spacep (line))
|
while (spacep (line))
|
||||||
@ -722,6 +772,9 @@ agent_scd_genkey (struct agent_card_genkey_s *info, int keyno, int force)
|
|||||||
APP app;
|
APP app;
|
||||||
char keynostr[20];
|
char keynostr[20];
|
||||||
struct ctrl_ctx_s ctrl;
|
struct ctrl_ctx_s ctrl;
|
||||||
|
struct pin_cb_info_s parm;
|
||||||
|
|
||||||
|
memset (&parm, 0, sizeof parm);
|
||||||
|
|
||||||
app = current_app? current_app : open_card ();
|
app = current_app? current_app : open_card ();
|
||||||
if (!app)
|
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,
|
return app->fnc.genkey (app, &ctrl, keynostr,
|
||||||
force? 1:0,
|
force? 1:0,
|
||||||
pin_cb, NULL);
|
pin_cb, &parm);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Send a PKSIGN command to the SCdaemon. */
|
/* Send a PKSIGN command to the SCdaemon. */
|
||||||
@ -745,6 +798,9 @@ agent_scd_pksign (const char *serialno, int hashalgo,
|
|||||||
{
|
{
|
||||||
APP app;
|
APP app;
|
||||||
int rc;
|
int rc;
|
||||||
|
struct pin_cb_info_s parm;
|
||||||
|
|
||||||
|
memset (&parm, 0, sizeof parm);
|
||||||
|
|
||||||
*r_buf = NULL;
|
*r_buf = NULL;
|
||||||
*r_buflen = 0;
|
*r_buflen = 0;
|
||||||
@ -761,7 +817,7 @@ agent_scd_pksign (const char *serialno, int hashalgo,
|
|||||||
return rc;
|
return rc;
|
||||||
|
|
||||||
return app->fnc.sign (app, serialno, hashalgo,
|
return app->fnc.sign (app, serialno, hashalgo,
|
||||||
pin_cb, NULL,
|
pin_cb, &parm,
|
||||||
indata, indatalen,
|
indata, indatalen,
|
||||||
r_buf, r_buflen);
|
r_buf, r_buflen);
|
||||||
}
|
}
|
||||||
@ -775,6 +831,9 @@ agent_scd_pkdecrypt (const char *serialno,
|
|||||||
{
|
{
|
||||||
APP app;
|
APP app;
|
||||||
int rc;
|
int rc;
|
||||||
|
struct pin_cb_info_s parm;
|
||||||
|
|
||||||
|
memset (&parm, 0, sizeof parm);
|
||||||
|
|
||||||
*r_buf = NULL;
|
*r_buf = NULL;
|
||||||
*r_buflen = 0;
|
*r_buflen = 0;
|
||||||
@ -791,7 +850,7 @@ agent_scd_pkdecrypt (const char *serialno,
|
|||||||
return rc;
|
return rc;
|
||||||
|
|
||||||
return app->fnc.decipher (app, serialno,
|
return app->fnc.decipher (app, serialno,
|
||||||
pin_cb, NULL,
|
pin_cb, &parm,
|
||||||
indata, indatalen,
|
indata, indatalen,
|
||||||
r_buf, r_buflen);
|
r_buf, r_buflen);
|
||||||
}
|
}
|
||||||
@ -803,6 +862,10 @@ agent_scd_change_pin (int chvno)
|
|||||||
APP app;
|
APP app;
|
||||||
char chvnostr[20];
|
char chvnostr[20];
|
||||||
int reset = 0;
|
int reset = 0;
|
||||||
|
struct pin_cb_info_s parm;
|
||||||
|
|
||||||
|
memset (&parm, 0, sizeof parm);
|
||||||
|
parm.repeat = 1;
|
||||||
|
|
||||||
reset = (chvno >= 100);
|
reset = (chvno >= 100);
|
||||||
chvno %= 100;
|
chvno %= 100;
|
||||||
@ -813,7 +876,7 @@ agent_scd_change_pin (int chvno)
|
|||||||
|
|
||||||
sprintf (chvnostr, "%d", chvno);
|
sprintf (chvnostr, "%d", chvno);
|
||||||
return app->fnc.change_pin (app, NULL, chvnostr, reset,
|
return app->fnc.change_pin (app, NULL, chvnostr, reset,
|
||||||
pin_cb, NULL);
|
pin_cb, &parm);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Perform a CHECKPIN operation. SERIALNO should be the serial
|
/* Perform a CHECKPIN operation. SERIALNO should be the serial
|
||||||
@ -823,12 +886,15 @@ int
|
|||||||
agent_scd_checkpin (const char *serialnobuf)
|
agent_scd_checkpin (const char *serialnobuf)
|
||||||
{
|
{
|
||||||
APP app;
|
APP app;
|
||||||
|
struct pin_cb_info_s parm;
|
||||||
|
|
||||||
|
memset (&parm, 0, sizeof parm);
|
||||||
|
|
||||||
app = current_app? current_app : open_card ();
|
app = current_app? current_app : open_card ();
|
||||||
if (!app)
|
if (!app)
|
||||||
return gpg_error (GPG_ERR_CARD);
|
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)
|
const unsigned char *e, size_t elen)
|
||||||
{
|
{
|
||||||
APP app;
|
APP app;
|
||||||
|
struct pin_cb_info_s parm;
|
||||||
|
|
||||||
|
memset (&parm, 0, sizeof parm);
|
||||||
|
|
||||||
app = current_app? current_app : open_card ();
|
app = current_app? current_app : open_card ();
|
||||||
if (!app)
|
if (!app)
|
||||||
@ -848,5 +917,5 @@ agent_openpgp_storekey (int keyno,
|
|||||||
|
|
||||||
return app_openpgp_storekey (app, keyno, template, template_len,
|
return app_openpgp_storekey (app, keyno, template, template_len,
|
||||||
created_at, m, mlen, e, elen,
|
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
|
#ifdef HAVE_STAT
|
||||||
#include <sys/stat.h> /* for stat() */
|
#include <sys/stat.h> /* for stat() */
|
||||||
#endif
|
#endif
|
||||||
|
#include <fcntl.h>
|
||||||
|
|
||||||
#define INCLUDED_BY_MAIN_MODULE 1
|
#define INCLUDED_BY_MAIN_MODULE 1
|
||||||
#include "packet.h"
|
#include "packet.h"
|
||||||
@ -57,6 +58,12 @@
|
|||||||
#include "ccid-driver.h"
|
#include "ccid-driver.h"
|
||||||
#endif
|
#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
|
enum cmd_and_opt_values
|
||||||
@ -174,13 +181,9 @@ enum cmd_and_opt_values
|
|||||||
oDebugAll,
|
oDebugAll,
|
||||||
oDebugCCIDDriver,
|
oDebugCCIDDriver,
|
||||||
oStatusFD,
|
oStatusFD,
|
||||||
#ifdef __riscos__
|
|
||||||
oStatusFile,
|
oStatusFile,
|
||||||
#endif /* __riscos__ */
|
|
||||||
oAttributeFD,
|
oAttributeFD,
|
||||||
#ifdef __riscos__
|
|
||||||
oAttributeFile,
|
oAttributeFile,
|
||||||
#endif /* __riscos__ */
|
|
||||||
oSKComments,
|
oSKComments,
|
||||||
oNoSKComments,
|
oNoSKComments,
|
||||||
oEmitVersion,
|
oEmitVersion,
|
||||||
@ -205,13 +208,9 @@ enum cmd_and_opt_values
|
|||||||
oBZ2CompressLevel,
|
oBZ2CompressLevel,
|
||||||
oBZ2DecompressLowmem,
|
oBZ2DecompressLowmem,
|
||||||
oPasswdFD,
|
oPasswdFD,
|
||||||
#ifdef __riscos__
|
|
||||||
oPasswdFile,
|
oPasswdFile,
|
||||||
#endif /* __riscos__ */
|
|
||||||
oCommandFD,
|
oCommandFD,
|
||||||
#ifdef __riscos__
|
|
||||||
oCommandFile,
|
oCommandFile,
|
||||||
#endif /* __riscos__ */
|
|
||||||
oQuickRandom,
|
oQuickRandom,
|
||||||
oNoVerbose,
|
oNoVerbose,
|
||||||
oTrustDBName,
|
oTrustDBName,
|
||||||
@ -284,9 +283,7 @@ enum cmd_and_opt_values
|
|||||||
oHiddenEncryptTo,
|
oHiddenEncryptTo,
|
||||||
oNoEncryptTo,
|
oNoEncryptTo,
|
||||||
oLoggerFD,
|
oLoggerFD,
|
||||||
#ifdef __riscos__
|
|
||||||
oLoggerFile,
|
oLoggerFile,
|
||||||
#endif /* __riscos__ */
|
|
||||||
oUtf8Strings,
|
oUtf8Strings,
|
||||||
oNoUtf8Strings,
|
oNoUtf8Strings,
|
||||||
oDisableCipherAlgo,
|
oDisableCipherAlgo,
|
||||||
@ -487,13 +484,9 @@ static ARGPARSE_OPTS opts[] = {
|
|||||||
{ oDebug, "debug" ,4|16, "@"},
|
{ oDebug, "debug" ,4|16, "@"},
|
||||||
{ oDebugAll, "debug-all" ,0, "@"},
|
{ oDebugAll, "debug-all" ,0, "@"},
|
||||||
{ oStatusFD, "status-fd" ,1, "@"},
|
{ oStatusFD, "status-fd" ,1, "@"},
|
||||||
#ifdef __riscos__
|
|
||||||
{ oStatusFile, "status-file" ,2, "@"},
|
{ oStatusFile, "status-file" ,2, "@"},
|
||||||
#endif /* __riscos__ */
|
|
||||||
{ oAttributeFD, "attribute-fd" ,1, "@" },
|
{ oAttributeFD, "attribute-fd" ,1, "@" },
|
||||||
#ifdef __riscos__
|
|
||||||
{ oAttributeFile, "attribute-file" ,2, "@" },
|
{ oAttributeFile, "attribute-file" ,2, "@" },
|
||||||
#endif /* __riscos__ */
|
|
||||||
{ oNoSKComments, "no-sk-comments", 0, "@"},
|
{ oNoSKComments, "no-sk-comments", 0, "@"},
|
||||||
{ oSKComments, "sk-comments", 0, "@"},
|
{ oSKComments, "sk-comments", 0, "@"},
|
||||||
{ oCompletesNeeded, "completes-needed", 1, "@"},
|
{ oCompletesNeeded, "completes-needed", 1, "@"},
|
||||||
@ -554,17 +547,13 @@ static ARGPARSE_OPTS opts[] = {
|
|||||||
{ aPipeMode, "pipemode", 0, "@" },
|
{ aPipeMode, "pipemode", 0, "@" },
|
||||||
{ oKOption, NULL, 0, "@"},
|
{ oKOption, NULL, 0, "@"},
|
||||||
{ oPasswdFD, "passphrase-fd",1, "@" },
|
{ oPasswdFD, "passphrase-fd",1, "@" },
|
||||||
#ifdef __riscos__
|
|
||||||
{ oPasswdFile, "passphrase-file",2, "@" },
|
{ oPasswdFile, "passphrase-file",2, "@" },
|
||||||
#endif /* __riscos__ */
|
|
||||||
{ oCommandFD, "command-fd",1, "@" },
|
{ oCommandFD, "command-fd",1, "@" },
|
||||||
#ifdef __riscos__
|
|
||||||
{ oCommandFile, "command-file",2, "@" },
|
{ oCommandFile, "command-file",2, "@" },
|
||||||
#endif /* __riscos__ */
|
|
||||||
{ oQuickRandom, "quick-random", 0, "@"},
|
{ oQuickRandom, "quick-random", 0, "@"},
|
||||||
{ oNoVerbose, "no-verbose", 0, "@"},
|
{ oNoVerbose, "no-verbose", 0, "@"},
|
||||||
{ oTrustDBName, "trustdb-name", 2, "@" },
|
{ oTrustDBName, "trustdb-name", 2, "@" },
|
||||||
{ oNoSecmemWarn, "no-secmem-warning", 0, "@" }, /* used only by regression tests */
|
{ oNoSecmemWarn, "no-secmem-warning", 0, "@" },
|
||||||
{ oNoPermissionWarn, "no-permission-warning", 0, "@" },
|
{ oNoPermissionWarn, "no-permission-warning", 0, "@" },
|
||||||
{ oNoMDCWarn, "no-mdc-warning", 0, "@" },
|
{ oNoMDCWarn, "no-mdc-warning", 0, "@" },
|
||||||
{ oNoArmor, "no-armor", 0, "@"},
|
{ oNoArmor, "no-armor", 0, "@"},
|
||||||
@ -613,9 +602,7 @@ static ARGPARSE_OPTS opts[] = {
|
|||||||
{ oLockMultiple, "lock-multiple", 0, "@" },
|
{ oLockMultiple, "lock-multiple", 0, "@" },
|
||||||
{ oLockNever, "lock-never", 0, "@" },
|
{ oLockNever, "lock-never", 0, "@" },
|
||||||
{ oLoggerFD, "logger-fd",1, "@" },
|
{ oLoggerFD, "logger-fd",1, "@" },
|
||||||
#ifdef __riscos__
|
|
||||||
{ oLoggerFile, "logger-file",2, "@" },
|
{ oLoggerFile, "logger-file",2, "@" },
|
||||||
#endif /* __riscos__ */
|
|
||||||
{ oUseEmbeddedFilename, "use-embedded-filename", 0, "@" },
|
{ oUseEmbeddedFilename, "use-embedded-filename", 0, "@" },
|
||||||
{ oNoUseEmbeddedFilename, "no-use-embedded-filename", 0, "@" },
|
{ oNoUseEmbeddedFilename, "no-use-embedded-filename", 0, "@" },
|
||||||
{ oUtf8Strings, "utf8-strings", 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
|
static void
|
||||||
set_cmd( enum cmd_and_opt_values *ret_cmd, enum cmd_and_opt_values new_cmd )
|
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:
|
case oStatusFD:
|
||||||
set_status_fd( iobuf_translate_file_handle (pargs.r.ret_int, 1) );
|
set_status_fd( iobuf_translate_file_handle (pargs.r.ret_int, 1) );
|
||||||
break;
|
break;
|
||||||
#ifdef __riscos__
|
|
||||||
case oStatusFile:
|
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;
|
break;
|
||||||
#endif /* __riscos__ */
|
|
||||||
case oAttributeFD:
|
case oAttributeFD:
|
||||||
set_attrib_fd(iobuf_translate_file_handle (pargs.r.ret_int, 1));
|
set_attrib_fd(iobuf_translate_file_handle (pargs.r.ret_int, 1));
|
||||||
break;
|
break;
|
||||||
#ifdef __riscos__
|
|
||||||
case oAttributeFile:
|
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;
|
break;
|
||||||
#endif /* __riscos__ */
|
|
||||||
case oLoggerFD:
|
case oLoggerFD:
|
||||||
log_set_logfile( NULL,
|
log_set_logfile( NULL,
|
||||||
iobuf_translate_file_handle (pargs.r.ret_int, 1) );
|
iobuf_translate_file_handle (pargs.r.ret_int, 1));
|
||||||
break;
|
break;
|
||||||
#ifdef __riscos__
|
|
||||||
case oLoggerFile:
|
case oLoggerFile:
|
||||||
log_set_logfile( NULL,
|
log_set_logfile( NULL, open_info_file (pargs.r.ret_str, 1) );
|
||||||
iobuf_translate_file_handle ( riscos_fdopenfile (pargs.r.ret_str, 1), 1) );
|
|
||||||
break;
|
break;
|
||||||
#endif /* __riscos__ */
|
|
||||||
case oWithFingerprint:
|
case oWithFingerprint:
|
||||||
opt.with_fingerprint = 1;
|
opt.with_fingerprint = 1;
|
||||||
with_fpr=1; /*fall thru*/
|
with_fpr=1; /*fall thru*/
|
||||||
case oFingerprint: opt.fingerprint++; break;
|
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:
|
case oOptions:
|
||||||
/* config files may not be nested (silently ignore them) */
|
/* config files may not be nested (silently ignore them) */
|
||||||
if( !configfp ) {
|
if( !configfp ) {
|
||||||
@ -2212,21 +2240,21 @@ main( int argc, char **argv )
|
|||||||
pwfd = iobuf_translate_file_handle (pargs.r.ret_int, 0);
|
pwfd = iobuf_translate_file_handle (pargs.r.ret_int, 0);
|
||||||
opt.use_agent = 0;
|
opt.use_agent = 0;
|
||||||
break;
|
break;
|
||||||
#ifdef __riscos__
|
|
||||||
case oPasswdFile:
|
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;
|
break;
|
||||||
#endif /* __riscos__ */
|
|
||||||
case oCommandFD:
|
case oCommandFD:
|
||||||
opt.command_fd = iobuf_translate_file_handle (pargs.r.ret_int, 0);
|
opt.command_fd = iobuf_translate_file_handle (pargs.r.ret_int, 0);
|
||||||
break;
|
break;
|
||||||
#ifdef __riscos__
|
|
||||||
case oCommandFile:
|
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;
|
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:
|
case oCompressAlgo:
|
||||||
/* If it is all digits, stick a Z in front of it for
|
/* If it is all digits, stick a Z in front of it for
|
||||||
later. This is for backwards compatibility with
|
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);
|
int have_static_passphrase(void);
|
||||||
void read_passphrase_from_fd( int fd );
|
void read_passphrase_from_fd( int fd );
|
||||||
void passphrase_clear_cache ( u32 *keyid, int algo );
|
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);
|
const char *prompt, int *canceled);
|
||||||
DEK *passphrase_to_dek( u32 *keyid, int pubkey_algo,
|
DEK *passphrase_to_dek( u32 *keyid, int pubkey_algo,
|
||||||
int cipher_algo, STRING2KEY *s2k, int mode,
|
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;
|
size_t nleft = buflen;
|
||||||
int nread;
|
int nread;
|
||||||
char *p;
|
char *p;
|
||||||
|
|
||||||
p = buf;
|
p = buf;
|
||||||
while (nleft > 0)
|
while( nleft > 0 )
|
||||||
{
|
{
|
||||||
nread = read (fd, buf, nleft);
|
nread = read ( fd, buf, nleft );
|
||||||
if (nread < 0)
|
if( nread < 0 )
|
||||||
{
|
{
|
||||||
if (nread == EINTR)
|
if (errno == EINTR)
|
||||||
nread = 0;
|
nread = 0;
|
||||||
else {
|
else
|
||||||
log_error ("read() error: %s\n", strerror (errno));
|
{
|
||||||
return -1;
|
log_error ( "read() error: %s\n", strerror (errno) );
|
||||||
}
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (!nread)
|
else if (!nread)
|
||||||
break; /* EOF */
|
break; /* EOF */
|
||||||
@ -1030,6 +1031,7 @@ passphrase_clear_cache ( u32 *keyid, int algo )
|
|||||||
*/
|
*/
|
||||||
char *
|
char *
|
||||||
ask_passphrase (const char *description,
|
ask_passphrase (const char *description,
|
||||||
|
const char *tryagain_text,
|
||||||
const char *promptid,
|
const char *promptid,
|
||||||
const char *prompt, int *canceled)
|
const char *prompt, int *canceled)
|
||||||
{
|
{
|
||||||
@ -1044,7 +1046,9 @@ ask_passphrase (const char *description,
|
|||||||
agent_died:
|
agent_died:
|
||||||
if ( opt.use_agent )
|
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 (!pw)
|
||||||
{
|
{
|
||||||
if (!opt.use_agent)
|
if (!opt.use_agent)
|
||||||
@ -1063,6 +1067,8 @@ ask_passphrase (const char *description,
|
|||||||
pw = NULL;
|
pw = NULL;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
if (tryagain_text)
|
||||||
|
tty_printf(_("%s.\n"), tryagain_text);
|
||||||
pw = cpr_get_hidden(promptid? promptid : "passphrase.ask",
|
pw = cpr_get_hidden(promptid? promptid : "passphrase.ask",
|
||||||
prompt?prompt : _("Enter passphrase: ") );
|
prompt?prompt : _("Enter passphrase: ") );
|
||||||
tty_kill_prompt();
|
tty_kill_prompt();
|
||||||
@ -1177,7 +1183,7 @@ passphrase_to_dek( u32 *keyid, int pubkey_algo,
|
|||||||
|
|
||||||
agent_died:
|
agent_died:
|
||||||
if( next_pw ) {
|
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;
|
pw = next_pw;
|
||||||
next_pw = NULL;
|
next_pw = NULL;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user