diff options
author | Werner Koch <[email protected]> | 2004-12-09 16:57:30 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 2004-12-09 16:57:30 +0000 |
commit | 9e52cf2758b4a572746c0746ae0b8cec5dbfba67 (patch) | |
tree | 75199febee7f8fed7e43363ae2b6488b3741a244 /g10/passphrase.c | |
parent | * keygen.c (ask_algo): Add a choose-your-own-capabilities option for DSA. (diff) | |
download | gnupg-9e52cf2758b4a572746c0746ae0b8cec5dbfba67.tar.gz gnupg-9e52cf2758b4a572746c0746ae0b8cec5dbfba67.zip |
* passphrase.c (agent_get_passphrase): New args CUSTOM_PROMPT and
CUSTOM_DESCRIPTION. Changed all callers.
* app-openpgp.c (do_getattr, do_learn_status, do_setattr): Support
the new private DOs.
(do_change_pin): Add a "N" prefix to the strings so that the
callback can act accordingly for a new PIN. Unfortunately this
breaks existing translations but I see no wother way to overvome
this.
* cardglue.c (learn_status_cb): Ditto.
(agent_release_card_info): Ditto.
(struct pin_cb_info_s): Removed and changed all users.
(pin_cb): Reworked.
* card-util.c (card_status): Print them
(card_edit): New command PRIVATEDO.
(change_private_do): New.
Diffstat (limited to 'g10/passphrase.c')
-rw-r--r-- | g10/passphrase.c | 49 |
1 files changed, 39 insertions, 10 deletions
diff --git a/g10/passphrase.c b/g10/passphrase.c index d63ba6719..3b1491878 100644 --- a/g10/passphrase.c +++ b/g10/passphrase.c @@ -630,7 +630,8 @@ agent_close ( int fd ) */ static char * agent_get_passphrase ( u32 *keyid, int mode, const char *tryagain_text, - int *canceled) + const char *custom_description, + const char *custom_prompt, int *canceled) { #if defined(__riscos__) return NULL; @@ -648,6 +649,7 @@ agent_get_passphrase ( u32 *keyid, int mode, const char *tryagain_text, int prot; char *orig_codeset = NULL; + log_debug ("agent_get_passphrase tryagin='%s' prompt='%s'\n", tryagain_text, custom_prompt); if (canceled) *canceled = 0; @@ -663,7 +665,7 @@ agent_get_passphrase ( u32 *keyid, int mode, const char *tryagain_text, } #ifdef ENABLE_NLS - /* The Assuan agent protol requires us to trasnmit utf-8 strings */ + /* The Assuan agent protol requires us to transmit utf-8 strings */ orig_codeset = bind_textdomain_codeset (PACKAGE, NULL); #ifdef HAVE_LANGINFO_CODESET if (!orig_codeset) @@ -680,7 +682,9 @@ agent_get_passphrase ( u32 *keyid, int mode, const char *tryagain_text, if ( (fd = agent_open (&prot)) == -1 ) goto failure; - if ( !mode && pk && keyid ) + if (custom_description) + atext = native_to_utf8 (custom_description); + else if ( !mode && pk && keyid ) { char *uid; size_t uidlen; @@ -818,9 +822,12 @@ agent_get_passphrase ( u32 *keyid, int mode, const char *tryagain_text, tryagain_text = _(tryagain_text); /* We allocate 2 time the needed space for atext so that there - is nenough space for escaping */ + is enough space for escaping */ line = m_alloc (15 + 46 - + 3*strlen (tryagain_text) + 3*strlen (atext) + 2); + + 3*strlen (tryagain_text) + + 3*strlen (atext) + + 3*strlen (custom_prompt? custom_prompt:"") + + 2); strcpy (line, "GET_PASSPHRASE "); p = line+15; if (!mode && have_fpr) @@ -844,7 +851,28 @@ agent_get_passphrase ( u32 *keyid, int mode, const char *tryagain_text, *p++ = *s; } *p++ = ' '; - *p++ = 'X'; /* Use the standard prompt */ + + /* The prompt. */ + if (custom_prompt) + { + char *tmp = native_to_utf8 (custom_prompt); + for (i=0, s=tmp; *s; s++) + { + if (*s < ' ' || *s == '+') + { + sprintf (p, "%%%02X", *s); + p += 3; + } + else if (*s == ' ') + *p++ = '+'; + else + *p++ = *s; + } + xfree (tmp); + } + else + *p++ = 'X'; /* Use the standard prompt */ + *p++ = ' '; /* copy description */ for (i=0, s= atext; *s; s++) @@ -1047,7 +1075,7 @@ ask_passphrase (const char *description, if ( opt.use_agent ) { pw = agent_get_passphrase (NULL, 0, - tryagain_text? tryagain_text :description, + tryagain_text, description, prompt, canceled ); if (!pw) { @@ -1188,9 +1216,9 @@ passphrase_to_dek( u32 *keyid, int pubkey_algo, next_pw = NULL; } else if ( opt.use_agent ) { - /* Divert to teh gpg-agent. */ + /* Divert to the gpg-agent. */ pw = agent_get_passphrase ( keyid, mode == 2? 1: 0, - tryagain_text, canceled ); + tryagain_text, NULL, NULL, canceled ); if (!pw) { if (!opt.use_agent) @@ -1198,7 +1226,8 @@ passphrase_to_dek( u32 *keyid, int pubkey_algo, pw = m_strdup (""); } if( *pw && mode == 2 ) { - char *pw2 = agent_get_passphrase ( keyid, 2, NULL, canceled ); + char *pw2 = agent_get_passphrase ( keyid, 2, NULL, NULL, + NULL, canceled ); if (!pw2) { if (!opt.use_agent) |