[git] GPA - branch, master, updated. gpa-0.9.4-38-g6e65e5c

by Werner Koch cvs at cvs.gnupg.org
Thu Jun 26 17:58:42 CEST 2014


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "The GNU Privacy Assistant".

The branch, master has been updated
       via  6e65e5c676fcc8ba4035dbe9b97c0769e2d3eb40 (commit)
       via  19d034eb12437ac752db589f25a6355566bcddfd (commit)
      from  80dd3c0d4c3b11e2e84dcb55644643f22cbdd8d3 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 6e65e5c676fcc8ba4035dbe9b97c0769e2d3eb40
Author: Werner Koch <wk at gnupg.org>
Date:   Wed Jun 25 20:25:28 2014 +0200

    Use the gpgme spawn protocol to backup a key.
    
    * src/gpgmetools.c (gpa_backup_key): Rewrite.

diff --git a/src/gpgmetools.c b/src/gpgmetools.c
index 621ea23..3b2eba9 100644
--- a/src/gpgmetools.c
+++ b/src/gpgmetools.c
@@ -1,6 +1,6 @@
 /* gpgmetools.h - Additional gpgme support functions for GPA.
    Copyright (C) 2002 Miguel Coca.
-   Copyright (C) 2005, 2008, 2009, 2012 g10 Code GmbH.
+   Copyright (C) 2005, 2008, 2009, 2012, 2014 g10 Code GmbH.
 
    This file is part of GPA
 
@@ -528,48 +528,47 @@ get_gpg_connect_agent_path (void)
 gboolean
 gpa_backup_key (const gchar *fpr, const char *filename, int is_x509)
 {
-  gchar *header, *pub_key, *sec_key;
-  gchar *err;
-  FILE *file;
-  gint ret_code;
-  gchar *header_argv[] =
+  const char *header_argv[] =
     {
-      NULL, "--batch", "--no-tty", "--fingerprint", (gchar*) fpr, NULL
+      "", "--batch", "--no-tty", "--fingerprint",
+      (char*) fpr, NULL
     };
-  gchar *pub_argv[] =
+  const char *pub_argv[] =
     {
-      NULL, "--batch", "--no-tty", "--armor", "--export", (gchar*) fpr, NULL
+      "", "--batch", "--no-tty", "--armor", "--export",
+      (char*) fpr, NULL
     };
-  gchar *sec_argv[] =
+  const char *sec_argv[] =
     {
-      NULL, "--batch", "--no-tty", "--armor", "--export-secret-key",
-      (gchar*) fpr, NULL
+      "", "--batch", "--no-tty", "--armor", "--export-secret-key",
+      (char*) fpr, NULL
     };
-  gchar *seccms_argv[] =
+  const char *seccms_argv[] =
     {
-      NULL, "--batch", "--no-tty", "--armor", "--export-secret-key-p12",
-      (gchar*) fpr, NULL
+      "", "--batch", "--no-tty", "--armor", "--export-secret-key-p12",
+      (char*) fpr, NULL
     };
-  const gchar *path;
-  mode_t mask;
+  gpg_error_t err;
+  FILE *fp;
+  gpgme_data_t dfp = NULL;
+  const char *pgm;
+  gpgme_ctx_t ctx = NULL;
+  int result = FALSE;
 
   /* Get the gpg path.  */
   if (is_x509)
-    path = get_gpgsm_path ();
+    pgm = get_gpgsm_path ();
   else
-    path = get_gpg_path ();
-  g_return_val_if_fail (path && *path, FALSE);
-
-  /* Add the executable to the arg arrays */
-  header_argv[0] = (gchar*) path;
-  pub_argv[0] = (gchar*) path;
-  sec_argv[0] = (gchar*) path;
-  seccms_argv[0] = (gchar*) path;
+    pgm = get_gpg_path ();
+  g_return_val_if_fail (pgm && *pgm, FALSE);
+
   /* Open the file */
-  mask = umask (0077);
-  file = g_fopen (filename, "w");
-  umask (mask);
-  if (!file)
+  {
+    mode_t mask = umask (0077);
+    fp = g_fopen (filename, "w");
+    umask (mask);
+  }
+  if (!fp)
     {
       gchar message[256];
       g_snprintf (message, sizeof(message), "%s: %s",
@@ -577,48 +576,62 @@ gpa_backup_key (const gchar *fpr, const char *filename, int is_x509)
       gpa_window_error (message, NULL);
       return FALSE;
     }
-  /* Get the keys and write them into the file */
+
   fputs (_(
     "************************************************************************\n"
     "* WARNING: This file is a backup of your secret key. Please keep it in *\n"
     "* a safe place.                                                        *\n"
     "************************************************************************\n"
-    "\n"), file);
+    "\n"), fp);
 
-  fputs (_("The key backed up in this file is:\n\n"), file);
-  if( !g_spawn_sync (NULL, header_argv, NULL, 0, NULL, NULL, &header,
-		     &err, &ret_code, NULL))
+  fputs (_("The key backed up in this file is:\n\n"), fp);
+  fflush (fp);
+
+  err = gpgme_data_new_from_stream (&dfp, fp);
+  if (err)
     {
-      return FALSE;
+      g_message ("error creating data object '%s': %s",
+                 filename, gpg_strerror (err));
+      goto leave;
     }
-  fputs (header, file);
-  g_free (err);
-  g_free (header);
-  fputs ("\n", file);
-  if( !g_spawn_sync (NULL, pub_argv, NULL, 0, NULL, NULL, &pub_key,
-                     &err, &ret_code, NULL))
+
+  ctx = gpa_gpgme_new ();
+  gpgme_set_protocol (ctx, GPGME_PROTOCOL_SPAWN);
+
+  err = gpgme_op_spawn (ctx, pgm, header_argv, NULL, dfp, NULL,
+                        GPGME_SPAWN_DETACHED|GPGME_SPAWN_ALLOW_SET_FG);
+  if (err)
     {
-      fclose (file);
-      return FALSE;
+      g_message ("error running '%s' (1): %s", pgm, gpg_strerror (err));
+      goto leave;
     }
-  fputs (pub_key, file);
-  g_free (err);
-  g_free (pub_key);
-  fputs ("\n", file);
-  if( !g_spawn_sync (NULL,
-                     is_x509? seccms_argv : sec_argv,
-                     NULL, 0, NULL, NULL, &sec_key,
-		     &err, &ret_code, NULL))
+  gpgme_data_write (dfp, "\n", 1);
+
+  err = gpgme_op_spawn (ctx, pgm, pub_argv, NULL, dfp, NULL,
+                        GPGME_SPAWN_DETACHED|GPGME_SPAWN_ALLOW_SET_FG);
+  if (err)
     {
-      fclose (file);
-      return FALSE;
+      g_message ("error running '%s' (2): %s", pgm, gpg_strerror (err));
+      goto leave;
     }
-  fputs (sec_key, file);
-  g_free (err);
-  g_free (sec_key);
+  gpgme_data_write (dfp, "\n", 1);
 
-  fclose (file);
-  return TRUE;
+  err = gpgme_op_spawn (ctx, pgm, is_x509? seccms_argv : sec_argv,
+                        NULL, dfp, NULL,
+                        GPGME_SPAWN_DETACHED|GPGME_SPAWN_ALLOW_SET_FG);
+  if (err)
+    {
+      g_message ("error running '%s' (3): %s", pgm, gpg_strerror (err));
+      goto leave;
+    }
+
+  result = TRUE;
+
+ leave:
+  gpgme_release (ctx);
+  gpgme_data_release (dfp);
+  fclose (fp);
+  return result;
 }
 
 

commit 19d034eb12437ac752db589f25a6355566bcddfd
Author: Werner Koch <wk at gnupg.org>
Date:   Wed Jun 25 20:25:28 2014 +0200

    Make sure that a new secret key is shown without a restart.
    
    * src/keymanager.c (key_manager_refresh): Hack to show a new secret
    key.

diff --git a/src/keymanager.c b/src/keymanager.c
index 7b9fe97..d5c9f96 100644
--- a/src/keymanager.c
+++ b/src/keymanager.c
@@ -854,6 +854,10 @@ key_manager_refresh (GtkAction *action, gpointer param)
 {
   GpaKeyManager *self = param;
 
+  /* Hack: To force reloading of secret keys we claim that a secret
+     key has been imported.  */
+  gpa_keylist_imported_secret_key (self->keylist);
+
   gpa_keylist_start_reload (self->keylist);
 }
 

-----------------------------------------------------------------------

Summary of changes:
 src/gpgmetools.c |  131 ++++++++++++++++++++++++++++++------------------------
 src/keymanager.c |    4 ++
 2 files changed, 76 insertions(+), 59 deletions(-)


hooks/post-receive
-- 
The GNU Privacy Assistant
http://git.gnupg.org




More information about the Gnupg-commits mailing list