[PATCH] Always return the empty string if decryption tries to demand a password

Daniel Kahn Gillmor dkg at fifthhorseman.net
Fri Jun 3 16:03:08 PDT 2011


The notmuch binary is not in the business of doing interactive
prompting with the user.  If credentials are needed for decryption,
they should be supplied to the decrypting processes some other way
(e.g. gpg-agent).

Previously, we returned a NULL function pointer for the
request_passwd() function, which may have cause segmentation faults
with some versions of gmime.
---
 notmuch-gmime-session.c |   17 ++++++++++++++++-
 1 files changed, 16 insertions(+), 1 deletions(-)

diff --git a/notmuch-gmime-session.c b/notmuch-gmime-session.c
index d83d9b3..33f2817 100644
--- a/notmuch-gmime-session.c
+++ b/notmuch-gmime-session.c
@@ -39,11 +39,26 @@ notmuch_gmime_session_get_type (void)
     return type;
 }
 
+/* 
+   notmuch never prompts the user for a password.  It always returns
+   an empty string (could it return a NULL pointer instead?)
+
+   If credentials are needed for crypto, they should be supplied via
+   other mechanisms (e.g. gpg-agent, etc)
+ */
+static char *never_request_passwd (unused (GMimeSession *session), unused (const char *prompt),
+				   unused (gboolean secret), unused (const char *item),
+				   unused (GError **err)) {
+    fprintf (stderr, "Credentials needed for crypto; Please use gpg-agent.\n");
+    return g_strdup ("");
+}
+
+
 static void
 notmuch_gmime_session_class_init (NotmuchGmimeSessionClass *klass)
 {
     GMimeSessionClass *session_class = GMIME_SESSION_CLASS (klass);
     parent_class = g_type_class_ref (GMIME_TYPE_SESSION);
-    session_class->request_passwd = NULL;
+    session_class->request_passwd = never_request_passwd;
 }
 /* END CRUFTY BOILERPLATE */
-- 
1.7.4.4



More information about the notmuch mailing list