Ask GpgME for path to gpg executable for manual key import.
authorAndrej Kacian <ticho@claws-mail.org>
Mon, 2 May 2016 18:54:19 +0000 (20:54 +0200)
committerAndrej Kacian <ticho@claws-mail.org>
Tue, 3 May 2016 07:28:10 +0000 (09:28 +0200)
src/plugins/pgpcore/pgp_viewer.c

index a24b6e0f16356d6a5436f4d846d8dd33d4b7036a..1108c85a1f43be0d7e6990da1bc96267f62de652 100644 (file)
@@ -67,6 +67,23 @@ static GtkWidget *pgp_get_widget(MimeViewer *_viewer)
        return GTK_WIDGET(viewer->textview->vbox);
 }
 
+static gchar *_get_gpg_executable_name()
+{
+       gpgme_engine_info_t e;
+
+       if (!gpgme_get_engine_info(&e)) {
+               while (e != NULL) {
+                       if (e->protocol == GPGME_PROTOCOL_OpenPGP
+                                       && e->file_name != NULL) {
+                               debug_print("Found gpg executable: '%s'\n", e->file_name);
+                               return e->file_name;
+                       }
+               }
+       }
+
+       return NULL;
+}
+
 static void pgpview_show_mime_part(TextView *textview, MimeInfo *partinfo)
 {
        GtkTextView *text;
@@ -119,7 +136,9 @@ static void pgpview_show_mime_part(TextView *textview, MimeInfo *partinfo)
        }
        gpgme_get_key(ctx, sig->fpr, &key, 0);
        if (!key) {
-               gchar *cmd = g_strdup_printf("gpg --no-tty --recv-keys %s", sig->fpr);
+               gchar *gpgbin = _get_gpg_executable_name();
+               gchar *cmd = g_strdup_printf("\"%s\" --no-tty --recv-keys %s",
+                               (gpgbin ? gpgbin : "gpg"), sig->fpr);
                AlertValue val = G_ALERTDEFAULT;
                if (!prefs_common_get_prefs()->work_offline) {
                        val = alertpanel(_("Key import"),