aboutsummaryrefslogtreecommitdiffhomepage
path: root/notmuch-show.c
diff options
context:
space:
mode:
authorJameson Graef Rollins <jrollins@finestructure.net>2012-05-26 11:45:45 -0700
committerDavid Bremner <bremner@debian.org>2012-06-10 20:09:09 -0300
commitb2c8fdee53a1b06dd19fafe23e53ac8555d294af (patch)
treee424d4388245ed4f28b6d828f73baee0a5f8fcd2 /notmuch-show.c
parent90822ffdb830060c6f1d73ad1f6c7964c9f20ad4 (diff)
cli: new crypto verify flag to handle verification
Use this flag rather than depend on the existence of an initialized gpgctx, to determine whether we should verify a multipart/signed. We will be moving to create the ctx lazily, so we don't want to depend on it being previously initialized if it's not needed.
Diffstat (limited to 'notmuch-show.c')
-rw-r--r--notmuch-show.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/notmuch-show.c b/notmuch-show.c
index fb5e9b60..3c067924 100644
--- a/notmuch-show.c
+++ b/notmuch-show.c
@@ -987,11 +987,11 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[]))
.part = -1,
.omit_excluded = TRUE,
.crypto = {
+ .verify = FALSE,
.decrypt = FALSE
}
};
int format_sel = NOTMUCH_FORMAT_NOT_SPECIFIED;
- notmuch_bool_t verify = FALSE;
int exclude = EXCLUDE_TRUE;
notmuch_opt_desc_t options[] = {
@@ -1008,7 +1008,7 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[]))
{ NOTMUCH_OPT_INT, &params.part, "part", 'p', 0 },
{ NOTMUCH_OPT_BOOLEAN, &params.entire_thread, "entire-thread", 't', 0 },
{ NOTMUCH_OPT_BOOLEAN, &params.crypto.decrypt, "decrypt", 'd', 0 },
- { NOTMUCH_OPT_BOOLEAN, &verify, "verify", 'v', 0 },
+ { NOTMUCH_OPT_BOOLEAN, &params.crypto.verify, "verify", 'v', 0 },
{ 0, 0, 0, 0, 0 }
};
@@ -1018,6 +1018,10 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[]))
return 1;
}
+ /* decryption implies verification */
+ if (params.crypto.decrypt)
+ params.crypto.verify = TRUE;
+
if (format_sel == NOTMUCH_FORMAT_NOT_SPECIFIED) {
/* if part was requested and format was not specified, use format=raw */
if (params.part >= 0)
@@ -1052,7 +1056,7 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[]))
break;
}
- if (params.crypto.decrypt || verify) {
+ if (params.crypto.decrypt || params.crypto.verify) {
#ifdef GMIME_ATLEAST_26
/* TODO: GMimePasswordRequestFunc */
params.crypto.gpgctx = g_mime_gpg_context_new (NULL, "gpg");
@@ -1063,6 +1067,10 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[]))
if (params.crypto.gpgctx) {
g_mime_gpg_context_set_always_trust ((GMimeGpgContext*) params.crypto.gpgctx, FALSE);
} else {
+ /* If we fail to create the gpgctx set the verify and
+ * decrypt flags to FALSE so we don't try to do any
+ * further verification or decryption */
+ params.crypto.verify = FALSE;
params.crypto.decrypt = FALSE;
fprintf (stderr, "Failed to construct gpg context.\n");
}