aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeffrey Stedfast <fejj@src.gnome.org>2002-06-22 16:07:08 +0800
committerJeffrey Stedfast <fejj@src.gnome.org>2002-06-22 16:07:08 +0800
commit4af1937ad505b032e35a0a8e5a409418f6a72a1f (patch)
tree03dd276306c2e706cfb1d051a640dac611248d3b
parente005e8b08e970048ffa70774554743ca9f98ce21 (diff)
downloadgsoc2013-evolution-4af1937ad505b032e35a0a8e5a409418f6a72a1f.tar
gsoc2013-evolution-4af1937ad505b032e35a0a8e5a409418f6a72a1f.tar.gz
gsoc2013-evolution-4af1937ad505b032e35a0a8e5a409418f6a72a1f.tar.bz2
gsoc2013-evolution-4af1937ad505b032e35a0a8e5a409418f6a72a1f.tar.lz
gsoc2013-evolution-4af1937ad505b032e35a0a8e5a409418f6a72a1f.tar.xz
gsoc2013-evolution-4af1937ad505b032e35a0a8e5a409418f6a72a1f.tar.zst
gsoc2013-evolution-4af1937ad505b032e35a0a8e5a409418f6a72a1f.zip
more fixes, now verifying works and signing almost works as well, except gpg is running out of memory for me? not sure if that is a gpg or evo bug
svn path=/trunk/; revision=17256
-rw-r--r--camel/camel-gpg-context.c37
1 files changed, 30 insertions, 7 deletions
diff --git a/camel/camel-gpg-context.c b/camel/camel-gpg-context.c
index 08be942188..033d470b81 100644
--- a/camel/camel-gpg-context.c
+++ b/camel/camel-gpg-context.c
@@ -440,6 +440,11 @@ gpg_ctx_get_argv (struct _GpgCtx *gpg, int status_fd, char **sfd, int passwd_fd,
*sfd = buf = g_strdup_printf ("--status-fd=%d", status_fd);
g_ptr_array_add (argv, buf);
+ if (gpg->need_passwd && passwd_fd != -1) {
+ *pfd = buf = g_strdup_printf ("--passphrase-fd=%d", passwd_fd);
+ g_ptr_array_add (argv, buf);
+ }
+
switch (gpg->mode) {
case GPG_CTX_MODE_SIGN:
g_ptr_array_add (argv, "--sign");
@@ -493,11 +498,6 @@ gpg_ctx_get_argv (struct _GpgCtx *gpg, int status_fd, char **sfd, int passwd_fd,
break;
}
- if (gpg->need_passwd && passwd_fd != -1) {
- *pfd = buf = g_strdup_printf ("--passphrase-fd=%d", passwd_fd);
- g_ptr_array_add (argv, buf);
- }
-
printf ("gpg command-line: ");
for (i = 0; i < argv->len; i++)
printf ("%s ", argv->pdata[i]);
@@ -835,6 +835,7 @@ gpg_ctx_op_step (struct _GpgCtx *gpg, CamelException *ex)
ssize_t nread;
printf ("reading from gpg's status-fd...\n");
+ fflush (stdout);
nread = read (gpg->status_fd, buffer, sizeof (buffer));
if (nread == -1)
@@ -875,12 +876,34 @@ gpg_ctx_op_step (struct _GpgCtx *gpg, CamelException *ex)
g_byte_array_append (gpg->diagnostics, buffer, nread);
}
- if (wrsetp && FD_ISSET (gpg->passwd_fd, &wrset) && gpg->passwd_fd != -1 && gpg->need_passwd && gpg->passwd) {
+ if (wrsetp && gpg->passwd_fd != -1 && FD_ISSET (gpg->passwd_fd, &wrset) && gpg->need_passwd) {
ssize_t w, nwritten = 0;
size_t n;
printf ("sending gpg our passphrase...\n");
+ if (!gpg->passwd) {
+ const char *name, *userid;
+ char *prompt;
+
+ userid = gpg->userid;
+ if (userid) {
+ name = g_hash_table_lookup (gpg->userid_hint, gpg->userid);
+ if (name == NULL)
+ name = gpg->userid;
+ } else {
+ name = "GnuPG";
+ userid = "passphrase";
+ }
+
+ prompt = g_strdup_printf (_("You need a passphrase to unlock the key for\n"
+ "user: \"%s\""), name);
+
+ gpg->passwd = camel_session_get_password (gpg->session, prompt, TRUE, NULL,
+ userid, ex);
+ g_free (prompt);
+ }
+
/* send the passphrase to gpg */
n = strlen (gpg->passwd);
do {
@@ -896,7 +919,7 @@ gpg_ctx_op_step (struct _GpgCtx *gpg, CamelException *ex)
goto exception;
}
- if (wrsetp && FD_ISSET (gpg->stdin, &wrset) && gpg->stdin != -1) {
+ if (wrsetp && gpg->stdin != -1 && FD_ISSET (gpg->stdin, &wrset)) {
char buffer[4096];
ssize_t nread;