diff options
| author | Jeffrey Stedfast <fejj@novell.com> | 2006-05-01 14:16:33 +0000 |
|---|---|---|
| committer | Jeffrey Stedfast <fejj@src.gnome.org> | 2006-05-01 14:16:33 +0000 |
| commit | fb678f7d050331130dda5acf178ce362dbce267f (patch) | |
| tree | 98798fcadba05702dd50fb0ba6924436ef53e7ad /camel | |
| parent | d22b7e971724c7dd5568d69342a0b99975c4f65b (diff) | |
| download | evolution-data-server-fb678f7d050331130dda5acf178ce362dbce267f.tar.gz | |
Handle prompts from GnuPG asking for the user's PIN for their SmartCard.
2006-05-01 Jeffrey Stedfast <fejj@novell.com>
* camel-gpg-context.c (gpg_ctx_parse_status): Handle prompts from
GnuPG asking for the user's PIN for their SmartCard. Fixes bug
#335386.
Diffstat (limited to 'camel')
| -rw-r--r-- | camel/ChangeLog | 17 | ||||
| -rw-r--r-- | camel/camel-gpg-context.c | 81 |
2 files changed, 65 insertions, 33 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog index 2191b5e9b..51d5ee5b9 100644 --- a/camel/ChangeLog +++ b/camel/ChangeLog @@ -1,3 +1,9 @@ +2006-05-01 Jeffrey Stedfast <fejj@novell.com> + + * camel-gpg-context.c (gpg_ctx_parse_status): Handle prompts from + GnuPG asking for the user's PIN for their SmartCard. Fixes bug + #335386. + 2006-04-19 Jeffrey Stedfast <fejj@novell.com> * camel-mime-filter-pgp.c (filter_run): You cannot CANNOT modify @@ -36,14 +42,15 @@ ** See bug 272307 - * camel-mime-utils.c: (header_decode_mailbox): - Do not decode_lwsp if there is a space in mail id, just append it. - Also do not truncate address if addr is not NULL. + * camel-mime-utils.c (header_decode_mailbox): Do not decode_lwsp + if there is a space in mail id, just append it. Also do not + truncate address if addr is not NULL. 2006-03-20 Srinivasa Ragavan <sragavan@novell.com> - * camel-gpg-context.c: (gpg_ctx_parse_status): Added flag to ask for - pass phrase. + * camel-gpg-context.c (gpg_ctx_parse_status): Added flag to ask + for pass phrase. + * camel-session.h: Added the flag for passphrase. 2006-03-20 Srinivasa Ragavan <sragavan@novell.com> diff --git a/camel/camel-gpg-context.c b/camel/camel-gpg-context.c index 59b4d7238..8b685f8ef 100644 --- a/camel/camel-gpg-context.c +++ b/camel/camel-gpg-context.c @@ -794,46 +794,71 @@ gpg_ctx_parse_status (struct _GpgCtx *gpg, CamelException *ex) g_free (gpg->need_id); gpg->need_id = userid; - } else if (!strncmp (status, "GET_HIDDEN passphrase.enter", 27)) { + } else if (!strncmp (status, "NEED_PASSPHRASE_PIN ", 20)) { + char *userid; + + status += 20; + + status = next_token (status, &userid); + if (!userid) { + camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM, + _("Failed to parse gpg passphrase request.")); + return -1; + } + + g_free (gpg->need_id); + gpg->need_id = userid; + } else if (!strncmp (status, "GET_HIDDEN ", 11)) { char *prompt, *passwd; const char *name; - - if (gpg->need_id) { - name = g_hash_table_lookup (gpg->userid_hint, gpg->need_id); - if (!name) - name = gpg->need_id; - - prompt = g_strdup_printf (_("You need a passphrase to unlock the key for\n" - "user: \"%s\""), name); - } else { + guint32 flags; + + status += 11; + + if (gpg->need_id && !(name = g_hash_table_lookup (gpg->userid_hint, gpg->need_id))) + name = gpg->need_id; + else name = ""; + + if (!strncmp (status, "passphrase.pin.ask", 18)) { + prompt = g_strdup_printf (_("You need a PIN to unlock the key for your\n" + "SmartCard: \"%s\""), name); + } else if (!strncmp (status, "passphrase.enter", 16)) { prompt = g_strdup_printf (_("You need a passphrase to unlock the key for\n" - "user: \"%s\""), name); + "user: \"%s\""), name); + } else { + next_token (status, &prompt); + camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, + _("Unexpected request from GnuPG for `%s'"), prompt); + g_free (prompt); + return -1; } - if ((passwd = camel_session_get_password (gpg->session, NULL, NULL, prompt, gpg->need_id, CAMEL_SESSION_PASSWORD_SECRET|CAMEL_SESSION_PASSPHRASE, ex)) && !gpg->utf8) { - char *opasswd = passwd; - - if ((passwd = g_locale_to_utf8 (passwd, -1, &nread, &nwritten, NULL))) { - memset (opasswd, 0, strlen (opasswd)); - g_free (opasswd); - } else { - passwd = opasswd; + flags = CAMEL_SESSION_PASSWORD_SECRET | CAMEL_SESSION_PASSPHRASE; + if ((passwd = camel_session_get_password (gpg->session, NULL, NULL, prompt, gpg->need_id, flags, ex))) { + if (!gpg->utf8) { + char *opasswd = passwd; + + if ((passwd = g_locale_to_utf8 (passwd, -1, &nread, &nwritten, NULL))) { + memset (opasswd, 0, strlen (opasswd)); + g_free (opasswd); + } else { + passwd = opasswd; + } } - } - g_free (prompt); - - if (passwd == NULL) { + + gpg->passwd = g_strdup_printf ("%s\n", passwd); + memset (passwd, 0, strlen (passwd)); + g_free (passwd); + + gpg->send_passwd = TRUE; + } else { if (!camel_exception_is_set (ex)) camel_exception_set (ex, CAMEL_EXCEPTION_USER_CANCEL, _("Cancelled.")); return -1; } - gpg->passwd = g_strdup_printf ("%s\n", passwd); - memset (passwd, 0, strlen (passwd)); - g_free (passwd); - - gpg->send_passwd = TRUE; + g_free (prompt); } else if (!strncmp (status, "GOOD_PASSPHRASE", 15)) { gpg->bad_passwds = 0; } else if (!strncmp (status, "BAD_PASSPHRASE", 14)) { |
