2007-02-23 [colin] 2.7.2cvs63
authorColin Leroy <colin@colino.net>
Fri, 23 Feb 2007 07:25:36 +0000 (07:25 +0000)
committerColin Leroy <colin@colino.net>
Fri, 23 Feb 2007 07:25:36 +0000 (07:25 +0000)
* src/plugins/pgpcore/prefs_gpg.c
* src/plugins/pgpcore/prefs_gpg.h
* src/plugins/pgpcore/sgpgme.c
* src/plugins/pgpinline/pgpinline.c
* src/plugins/pgpmime/pgpmime.c
Try harder to respect user's choice wrt
gpg-agent even with gpg2, by unsetting
GPG_AGENT_INFO when necessary.

ChangeLog
PATCHSETS
configure.ac
src/plugins/pgpcore/prefs_gpg.c
src/plugins/pgpcore/prefs_gpg.h
src/plugins/pgpcore/sgpgme.c
src/plugins/pgpinline/pgpinline.c
src/plugins/pgpmime/pgpmime.c

index 6bbebce..3e31755 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2007-02-23 [colin]     2.7.2cvs63
+
+       * src/plugins/pgpcore/prefs_gpg.c
+       * src/plugins/pgpcore/prefs_gpg.h
+       * src/plugins/pgpcore/sgpgme.c
+       * src/plugins/pgpinline/pgpinline.c
+       * src/plugins/pgpmime/pgpmime.c
+               Try harder to respect user's choice wrt
+               gpg-agent even with gpg2, by unsetting
+               GPG_AGENT_INFO when necessary.
+
 2007-02-22 [paul]      2.7.2cvs62
 
        * src/plugins/pgpcore/sgpgme.c
index aff1c74..1cb32d1 100644 (file)
--- a/PATCHSETS
+++ b/PATCHSETS
 ( cvs diff -u -r 1.115.2.137 -r 1.115.2.138 src/main.c;  cvs diff -u -r 1.150.2.92 -r 1.150.2.93 src/procmsg.c;  cvs diff -u -r 1.1.2.62 -r 1.1.2.63 src/gtk/quicksearch.c;  cvs diff -u -r 1.1.2.23 -r 1.1.2.24 src/plugins/pgpcore/passphrase.c;  ) > 2.7.2cvs60.patchset
 ( cvs diff -u -r 1.1.2.63 -r 1.1.2.64 src/gtk/quicksearch.c;  ) > 2.7.2cvs61.patchset
 ( cvs diff -u -r 1.1.2.24 -r 1.1.2.25 src/plugins/pgpcore/passphrase.c;  cvs diff -u -r 1.1.2.41 -r 1.1.2.42 src/plugins/pgpcore/sgpgme.c;  cvs diff -u -r 1.1.2.8 -r 1.1.2.9 src/plugins/pgpcore/sgpgme.h;  cvs diff -u -r 1.1.2.29 -r 1.1.2.30 src/plugins/pgpinline/pgpinline.c;  cvs diff -u -r 1.1.2.45 -r 1.1.2.46 src/plugins/pgpmime/pgpmime.c;  ) > 2.7.2cvs62.patchset
+( cvs diff -u -r 1.1.2.20 -r 1.1.2.21 src/plugins/pgpcore/prefs_gpg.c;  cvs diff -u -r 1.1.2.8 -r 1.1.2.9 src/plugins/pgpcore/prefs_gpg.h;  cvs diff -u -r 1.1.2.42 -r 1.1.2.43 src/plugins/pgpcore/sgpgme.c;  cvs diff -u -r 1.1.2.30 -r 1.1.2.31 src/plugins/pgpinline/pgpinline.c;  cvs diff -u -r 1.1.2.46 -r 1.1.2.47 src/plugins/pgpmime/pgpmime.c;  ) > 2.7.2cvs63.patchset
index a594fc5..fdb049f 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=7
 MICRO_VERSION=2
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=62
+EXTRA_VERSION=63
 EXTRA_RELEASE=
 EXTRA_GTK2_VERSION=
 
index b6bb239..fca79db 100644 (file)
@@ -53,6 +53,8 @@ static PrefParam param[] = {
        {NULL, NULL, NULL, P_OTHER, NULL, NULL, NULL}
 };
 
+static gchar *saved_gpg_agent_info = NULL;
+
 struct GPGPage
 {
        PrefsPage page;
@@ -103,7 +105,7 @@ static void prefs_gpg_create_widget_func(PrefsPage *_page,
 
        PACK_CHECK_BUTTON (vbox2, checkbtn_use_gpg_agent,
                        _("Use gpg-agent to manage passwords"));
-       if (!getenv("GPG_AGENT_INFO"))
+       if (saved_gpg_agent_info == NULL)
                gtk_widget_set_sensitive(checkbtn_use_gpg_agent, FALSE);
 
        PACK_CHECK_BUTTON (vbox2, checkbtn_store_passphrase,
@@ -200,6 +202,8 @@ static void prefs_gpg_save_func(PrefsPage *_page)
        config->gpg_warning = 
                gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->checkbtn_gpg_warning));
 
+       prefs_gpg_enable_agent(config->use_gpg_agent);
+
        prefs_gpg_save_config();
 }
 
@@ -512,10 +516,29 @@ void prefs_gpg_account_free_config(GPGAccountConfig *config)
 static struct GPGPage gpg_page;
 static struct GPGAccountPage gpg_account_page;
 
+void prefs_gpg_enable_agent(gboolean enable)
+{
+       if (enable) {
+               if (saved_gpg_agent_info) {
+                       g_setenv("GPG_AGENT_INFO",
+                                saved_gpg_agent_info, TRUE);
+                       debug_print("set GPG_AGENT_INFO=%s\n", 
+                               saved_gpg_agent_info);
+               } else { 
+                       debug_print("Can't enable gpg agent (no GPG_AGENT_INFO)\n");
+               }
+       } else {
+                       g_unsetenv("GPG_AGENT_INFO");
+                       debug_print("unset GPG_AGENT_INFO=%s\n", 
+                               saved_gpg_agent_info);
+       }
+}
+
 void prefs_gpg_init()
 {
        static gchar *path[3];
        gchar *rcpath;
+       gchar *tmp = NULL;
 
        prefs_set_default(param);
        rcpath = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, COMMON_RC, NULL);
@@ -541,10 +564,17 @@ void prefs_gpg_init()
         gpg_account_page.page.weight = 30.0;
 
         prefs_account_register_page((PrefsPage *) &gpg_account_page);
+       
+       tmp = g_getenv("GPG_AGENT_INFO");
+       if (tmp)
+               saved_gpg_agent_info = g_strdup(tmp);
+
+       prefs_gpg_enable_agent(prefs_gpg_get_config()->use_gpg_agent);
 }
 
 void prefs_gpg_done()
 {
        prefs_gtk_unregister_page((PrefsPage *) &gpg_page);
        prefs_account_unregister_page((PrefsPage *) &gpg_account_page);
+       prefs_gpg_enable_agent(TRUE);
 }
index 6cb7711..cd76461 100644 (file)
@@ -52,3 +52,4 @@ struct GPGConfig *prefs_gpg_get_config(void);
 struct GPGAccountConfig *prefs_gpg_account_get_config(PrefsAccount *account);
 void prefs_gpg_account_set_config(PrefsAccount *account, GPGAccountConfig *config);
 void prefs_gpg_account_free_config(GPGAccountConfig *config);
+void prefs_gpg_enable_agent(gboolean enable);
index a0cf3c1..d6fe770 100644 (file)
@@ -379,11 +379,13 @@ gpgme_data_t sgpgme_decrypt_verify(gpgme_data_t cipher, gpgme_verify_result_t *s
        }
        
        if (gpgme_get_protocol(ctx) == GPGME_PROTOCOL_OpenPGP) {
+               prefs_gpg_enable_agent(prefs_gpg_get_config()->use_gpg_agent);
                if (!getenv("GPG_AGENT_INFO") || !prefs_gpg_get_config()->use_gpg_agent) {
                        info.c = ctx;
                        gpgme_set_passphrase_cb (ctx, gpgmegtk_passphrase_cb, &info);
                }
        } else {
+               prefs_gpg_enable_agent(TRUE);
                info.c = ctx;
                gpgme_set_passphrase_cb (ctx, NULL, &info);
        }
index d52e46a..3c171d7 100644 (file)
@@ -540,6 +540,7 @@ static gboolean pgpinline_sign(MimeInfo *mimeinfo, PrefsAccount *account)
                return FALSE;
        }
 
+       prefs_gpg_enable_agent(prefs_gpg_get_config()->use_gpg_agent);
        if (!getenv("GPG_AGENT_INFO") || !prefs_gpg_get_config()->use_gpg_agent) {
                info.c = ctx;
                gpgme_set_passphrase_cb (ctx, gpgmegtk_passphrase_cb, &info);
index 4e51cd8..7669d76 100644 (file)
@@ -477,6 +477,7 @@ gboolean pgpmime_sign(MimeInfo *mimeinfo, PrefsAccount *account)
                return FALSE;
        }
 
+       prefs_gpg_enable_agent(prefs_gpg_get_config()->use_gpg_agent);
        if (getenv("GPG_AGENT_INFO") && prefs_gpg_get_config()->use_gpg_agent) {
                debug_print("GPG_AGENT_INFO environment defined, running without passphrase callback\n");
        } else {