crypto: prefer gpg2

Can't say I fully understand what's going on, but it seems gpg-before-2
has some trouble with its agent, at least when using
gnome-session (which stopped using gnome-keyring as a gpg-agent since
Fedora 23 at least).

Sanity seems to be restored when preferring gpg2 instead. "gpg" is used
when gpg2 isn't there; and there's the MU_GPG_PATH env variable to
override all of that.
This commit is contained in:
djcb 2016-07-24 16:00:04 +03:00
parent 538b7e5292
commit c9f8ac5beb
2 changed files with 17 additions and 11 deletions

View File

@ -1,5 +1,5 @@
/* /*
** Copyright (C) 2012-2013 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl> ** Copyright (C) 2012-2016 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
** **
** This program is free software; you can redistribute it and/or modify it ** This program is free software; you can redistribute it and/or modify it
** under the terms of the GNU General Public License as published by the ** under the terms of the GNU General Public License as published by the
@ -65,7 +65,7 @@ password_requester (GMimeCryptoContext *ctx, const char *user_id,
written = g_mime_stream_write_string (response, "\n"); written = g_mime_stream_write_string (response, "\n");
if (written == -1) if (written == -1)
mu_util_g_set_error (err, MU_ERROR_CRYPTO, mu_util_g_set_error (err, MU_ERROR_CRYPTO,
"writing password to mime stream failed"); "writing password to mime stream failed");
/* it seems that GMime tries to flush the fd; however, this /* it seems that GMime tries to flush the fd; however, this
* does not work for pipes/sockets, causing getting a password * does not work for pipes/sockets, causing getting a password
@ -116,8 +116,8 @@ get_gpg (GError **err)
return g_strdup (envpath); return g_strdup (envpath);
} }
if (!(path = g_find_program_in_path ("gpg")) && if (!(path = g_find_program_in_path ("gpg2")) &&
!(path = g_find_program_in_path ("gpg2"))) { !(path = g_find_program_in_path ("gpg"))) {
mu_util_g_set_error (err, MU_ERROR, "gpg/gpg2 not found"); mu_util_g_set_error (err, MU_ERROR, "gpg/gpg2 not found");
return NULL; return NULL;
} else } else
@ -357,7 +357,7 @@ mu_msg_part_sig_status_report_destroy (MuMsgPartSigStatusReport *report)
static inline void static inline void
tag_with_sig_status(GObject *part, tag_with_sig_status(GObject *part,
MuMsgPartSigStatusReport *report) MuMsgPartSigStatusReport *report)
{ {
g_object_set_data_full g_object_set_data_full
(part, SIG_STATUS_REPORT, report, (part, SIG_STATUS_REPORT, report,
@ -402,7 +402,7 @@ mu_msg_crypto_verify_part (GMimeMultipartSigned *sig, MuMsgOptions opts,
static inline void static inline void
check_decrypt_result(GMimeMultipartEncrypted *part, GMimeDecryptResult *res, check_decrypt_result(GMimeMultipartEncrypted *part, GMimeDecryptResult *res,
GError **err) GError **err)
{ {
GMimeSignatureList *sigs; GMimeSignatureList *sigs;
MuMsgPartSigStatusReport *report; MuMsgPartSigStatusReport *report;
@ -420,7 +420,7 @@ check_decrypt_result(GMimeMultipartEncrypted *part, GMimeDecryptResult *res,
else { else {
if (err && !*err) if (err && !*err)
mu_util_g_set_error (err, MU_ERROR_CRYPTO, mu_util_g_set_error (err, MU_ERROR_CRYPTO,
"verification failed"); "verification failed");
} }
g_object_unref (res); g_object_unref (res);
} }

View File

@ -1,6 +1,6 @@
/* -*-mode: c; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-*/ /* -*-mode: c; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-*/
/* /*
** Copyright (C) 2010-2013 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl> ** Copyright (C) 2010-2016 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
** **
** This program is free software; you can redistribute it and/or modify it ** This program is free software; you can redistribute it and/or modify it
** under the terms of the GNU General Public License as published by the ** under the terms of the GNU General Public License as published by the
@ -80,10 +80,14 @@ each_part (MuMsg *msg, MuMsgPart *part, gchar **attach)
static gchar * static gchar *
get_attach_str (MuMsg *msg, MuConfig *opts) get_attach_str (MuMsg *msg, MuConfig *opts)
{ {
gchar *attach; gchar *attach;
MuMsgOptions msgopts;
msgopts = mu_config_get_msg_options(opts) |
MU_MSG_OPTION_CONSOLE_PASSWORD;
attach = NULL; attach = NULL;
mu_msg_part_foreach (msg, mu_config_get_msg_options(opts), mu_msg_part_foreach (msg, msgopts,
(MuMsgPartForeachFunc)each_part, &attach); (MuMsgPartForeachFunc)each_part, &attach);
return attach; return attach;
} }
@ -494,7 +498,9 @@ mu_cmd_verify (MuConfig *opts, GError **err)
if (!msg) if (!msg)
return MU_ERROR; return MU_ERROR;
msgopts = mu_config_get_msg_options (opts) | MU_MSG_OPTION_VERIFY; msgopts = mu_config_get_msg_options (opts)
| MU_MSG_OPTION_VERIFY
| MU_MSG_OPTION_CONSOLE_PASSWORD;
vdata.report = NULL; vdata.report = NULL;
vdata.combined_status = MU_MSG_PART_SIG_STATUS_UNSIGNED; vdata.combined_status = MU_MSG_PART_SIG_STATUS_UNSIGNED;