aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--camel/ChangeLog5
-rw-r--r--camel/camel-gpg-context.c26
2 files changed, 25 insertions, 6 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog
index 2c0cb7f432..a857f41559 100644
--- a/camel/ChangeLog
+++ b/camel/ChangeLog
@@ -1,5 +1,10 @@
2002-08-19 Jeffrey Stedfast <fejj@ximian.com>
+ * camel-gpg-context.c (gpg_sign): If the diagnostics are empty,
+ just explain that gpg failed to execute.
+ (gpg_encrypt): Same.
+ (gpg_decrypt): And here too.
+
* tests/lib/camel-test.c (camel_test_init): Updated to pass the
needed arguments to camel_init() and to init gthreads before camel
(since camel expectes it to be initialised already).
diff --git a/camel/camel-gpg-context.c b/camel/camel-gpg-context.c
index 290f921eaf..9b586e5f9b 100644
--- a/camel/camel-gpg-context.c
+++ b/camel/camel-gpg-context.c
@@ -566,12 +566,16 @@ static int
gpg_ctx_op_start (struct _GpgCtx *gpg)
{
char *status_fd = NULL, *passwd_fd = NULL;
- int i, maxfd, fds[10];
+ int i, maxfd, errnosave, fds[10];
GPtrArray *argv;
+ struct stat st;
for (i = 0; i < 10; i++)
fds[i] = -1;
+ if (stat (gpg->path, &st) == -1)
+ goto exception;
+
maxfd = gpg->need_passwd ? 10 : 8;
for (i = 0; i < maxfd; i += 2) {
if (pipe (fds + i) == -1)
@@ -645,11 +649,15 @@ gpg_ctx_op_start (struct _GpgCtx *gpg)
exception:
+ errnosave = errno;
+
for (i = 0; i < 10; i++) {
if (fds[i] != -1)
close (fds[i]);
}
+ errno = errnosave;
+
return -1;
}
@@ -1207,8 +1215,8 @@ gpg_sign (CamelCipherContext *context, const char *userid, CamelCipherHash hash,
gpg_ctx_set_ostream (gpg, ostream);
if (gpg_ctx_op_start (gpg) == -1) {
- camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Failed to execute gpg."));
+ camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
+ _("Failed to execute gpg: %s"), g_strerror (errno));
gpg_ctx_free (gpg);
return -1;
@@ -1236,7 +1244,9 @@ gpg_sign (CamelCipherContext *context, const char *userid, CamelCipherHash hash,
char *diagnostics;
diagnostics = gpg_ctx_get_diagnostics (gpg);
- camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM, diagnostics);
+ camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM,
+ diagnostics && *diagnostics ? diagnostics :
+ _("Failed to execute gpg."));
g_free (diagnostics);
gpg_ctx_free (gpg);
@@ -1417,7 +1427,9 @@ gpg_encrypt (CamelCipherContext *context, gboolean sign, const char *userid,
char *diagnostics;
diagnostics = gpg_ctx_get_diagnostics (gpg);
- camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM, diagnostics);
+ camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM,
+ diagnostics && *diagnostics ? diagnostics :
+ _("Failed to execute gpg."));
g_free (diagnostics);
gpg_ctx_free (gpg);
@@ -1473,7 +1485,9 @@ gpg_decrypt (CamelCipherContext *context, CamelStream *istream,
char *diagnostics;
diagnostics = gpg_ctx_get_diagnostics (gpg);
- camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM, diagnostics);
+ camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM,
+ diagnostics && *diagnostics ? diagnostics :
+ _("Failed to execute gpg."));
g_free (diagnostics);
gpg_ctx_free (gpg);