diff options
Diffstat (limited to 'camel/camel-gpg-context.c')
-rw-r--r-- | camel/camel-gpg-context.c | 37 |
1 files changed, 21 insertions, 16 deletions
diff --git a/camel/camel-gpg-context.c b/camel/camel-gpg-context.c index 0483e8a16b..2ff800615d 100644 --- a/camel/camel-gpg-context.c +++ b/camel/camel-gpg-context.c @@ -300,7 +300,7 @@ gpg_ctx_new (CamelSession *session) camel_object_ref (CAMEL_OBJECT (session)); gpg->userid_hint = g_hash_table_new (g_str_hash, g_str_equal); gpg->complete = FALSE; - gpg->seen_eof1 = FALSE; + gpg->seen_eof1 = TRUE; gpg->seen_eof2 = FALSE; gpg->pid = (pid_t) -1; gpg->exit_status = 0; @@ -424,6 +424,7 @@ gpg_ctx_set_ostream (struct _GpgCtx *gpg, CamelStream *ostream) if (gpg->ostream) camel_object_unref (CAMEL_OBJECT (gpg->ostream)); gpg->ostream = ostream; + gpg->seen_eof1 = FALSE; } static const char * @@ -875,11 +876,6 @@ gpg_ctx_parse_status (struct _GpgCtx *gpg, CamelException *ex) } else if (!strncmp (status, "ULTIMATE", 8)) { gpg->trust = GPG_TRUST_ULTIMATE; } - - /* Since verifying a signature will never produce output - on gpg's stdout descriptor, we use this EOF bit for - making sure that we get a TRUST metric. */ - gpg->seen_eof1 = TRUE; } else if (!strncmp (status, "VALIDSIG", 8)) { gpg->validsig = TRUE; } else if (!strncmp (status, "BADSIG", 6)) { @@ -908,11 +904,7 @@ gpg_ctx_parse_status (struct _GpgCtx *gpg, CamelException *ex) } break; case GPG_CTX_MODE_IMPORT: - /* hack to work around the fact that gpg - doesn't write anything to stdout when - importing keys */ - if (!strncmp (status, "IMPORT_RES", 10)) - gpg->seen_eof1 = TRUE; + /* noop */ break; case GPG_CTX_MODE_EXPORT: /* noop */ @@ -969,12 +961,21 @@ gpg_ctx_op_step (struct _GpgCtx *gpg, CamelException *ex) retry: FD_ZERO (&rdset); - FD_SET (gpg->stdout_fd, &rdset); - FD_SET (gpg->stderr_fd, &rdset); - FD_SET (gpg->status_fd, &rdset); - maxfd = MAX (gpg->stdout_fd, gpg->stderr_fd); - maxfd = MAX (maxfd, gpg->status_fd); + if (!gpg->seen_eof1) { + FD_SET (gpg->stdout_fd, &rdset); + maxfd = MAX (maxfd, gpg->stdout_fd); + } + + if (!gpg->seen_eof2) { + FD_SET (gpg->stderr_fd, &rdset); + maxfd = MAX (maxfd, gpg->stderr_fd); + } + + if (!gpg->complete) { + FD_SET (gpg->status_fd, &rdset); + maxfd = MAX (maxfd, gpg->status_fd); + } if (gpg->stdin_fd != -1 || gpg->passwd_fd != -1) { FD_ZERO (&wrset); @@ -990,6 +991,8 @@ gpg_ctx_op_step (struct _GpgCtx *gpg, CamelException *ex) wrsetp = &wrset; } + g_assert (maxfd > 0); + timeout.tv_sec = 10; /* timeout in seconds */ timeout.tv_usec = 0; @@ -1184,6 +1187,7 @@ gpg_ctx_op_complete (struct _GpgCtx *gpg) return gpg->complete && gpg->seen_eof1 && gpg->seen_eof2; } +#if 0 static gboolean gpg_ctx_op_exited (struct _GpgCtx *gpg) { @@ -1202,6 +1206,7 @@ gpg_ctx_op_exited (struct _GpgCtx *gpg) return FALSE; } +#endif static void gpg_ctx_op_cancel (struct _GpgCtx *gpg) |