Browse Source

2009-09-23 Marcus Brinkmann <marcus@g10code.de>

	* configure.ac (NEED_LIBASSUAN_VERSION): Update to 1.1.0.
	(_ASSUAN_ONLY_GPG_ERROR): Remove.
	* src/p11-initialize.c: Update to new Assuan interface.
	* src/debug.c (_scute_debug_init): Remove call to
	assuan_set_assuan_log_stream.
	* src/agent.c (agent_connect): Allocate assuan context before
	connecting to server.  Release it on error.
	* src/cert-gpgsm.c (export_cert_compat, export_cert)
	(scute_gpgsm_search_certs_by_grip)
	(scute_gpgsm_search_certs_by_fpr): Likewise.
Marcus Brinkmann 16 years ago
parent
commit
3e9b25729c
6 changed files with 73 additions and 21 deletions
  1. 13 0
      ChangeLog
  2. 1 3
      configure.ac
  3. 12 5
      src/agent.c
  4. 46 8
      src/cert-gpgsm.c
  5. 0 2
      src/debug.c
  6. 1 3
      src/p11-initialize.c

+ 13 - 0
ChangeLog

@@ -1,3 +1,16 @@
+2009-09-23  Marcus Brinkmann  <marcus@g10code.de>
+
+	* configure.ac (NEED_LIBASSUAN_VERSION): Update to 1.1.0.
+	(_ASSUAN_ONLY_GPG_ERROR): Remove.
+	* src/p11-initialize.c: Update to new Assuan interface.
+	* src/debug.c (_scute_debug_init): Remove call to
+	assuan_set_assuan_log_stream.
+	* src/agent.c (agent_connect): Allocate assuan context before
+	connecting to server.  Release it on error.
+	* src/cert-gpgsm.c (export_cert_compat, export_cert)
+	(scute_gpgsm_search_certs_by_grip)
+	(scute_gpgsm_search_certs_by_fpr): Likewise.
+
 2009-07-22  Stef Walter  <stef@memberwebs.com>
 
 	* src/pkcs11.h: Make all constants UL that should be.

+ 1 - 3
configure.ac

@@ -70,7 +70,7 @@ VERSION_MAJOR=1
 VERSION_MINOR=0
 
 NEED_GPG_ERROR_VERSION=1.4
-NEED_LIBASSUAN_VERSION=0.6.10
+NEED_LIBASSUAN_VERSION=1.1.0
 NEED_GPGSM_VERSION=1.9.6
 # Some status variables to give feedback at the end of a configure run.
 have_gpg_error=no
@@ -124,8 +124,6 @@ AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version of this package])
 AC_DEFINE_UNQUOTED(VERSION_MAJOR, $VERSION_MAJOR, [Major version number])
 AC_DEFINE_UNQUOTED(VERSION_MINOR, $VERSION_MINOR, [Minor version number])
 
-AC_DEFINE_UNQUOTED(_ASSUAN_ONLY_GPG_ERRORS, 1, [Disable backward compatibility])
-
 # Don't default to build static libs.
 # FIXME: Caution: Evil hack ahead.  Libtool does not support linking a
 # static library to a shared library.  But for libassuan, we need this.

+ 12 - 5
src/agent.c

@@ -239,6 +239,11 @@ agent_connect (assuan_context_t *ctx_r)
   gpg_error_t err = 0;
   char *infostr;
   char *ptr;
+  assuan_context_t ctx = NULL;
+
+  err = assuan_new (&ctx);
+  if (err)
+    return err;
 
  restart:
 
@@ -253,8 +258,7 @@ agent_connect (assuan_context_t *ctx_r)
       if (! sockname)
 	return gpg_error_from_errno (errno);
 
-      err = assuan_socket_connect (ctx_r, sockname, 0);
-
+      err = assuan_socket_connect (ctx, sockname, 0);
       if (err)
         {
 	  const char *agent_program;
@@ -312,7 +316,7 @@ agent_connect (assuan_context_t *ctx_r)
             no_close_list[i] = -1;
             
             /* Connect to the agent and perform initial handshaking. */
-            err = assuan_pipe_connect (ctx_r, agent_program, argv,
+            err = assuan_pipe_connect (ctx, agent_program, argv,
 				       no_close_list);
           }
 #endif /*!HAVE_W32_SYSTEM*/
@@ -350,7 +354,7 @@ agent_connect (assuan_context_t *ctx_r)
 	  goto restart;
 	}
       
-      err = assuan_socket_connect (ctx_r, infostr, pid);
+      err = assuan_socket_connect (ctx, infostr, pid);
       free (infostr);
       if (err)
 	{
@@ -362,6 +366,7 @@ agent_connect (assuan_context_t *ctx_r)
 
   if (err)
     {
+      assuan_release (ctx);
       DEBUG (DBG_CRIT, "cannot connect to GPG agent: %s", gpg_strerror (err));
       return gpg_error (GPG_ERR_NO_AGENT);
     }
@@ -369,6 +374,8 @@ agent_connect (assuan_context_t *ctx_r)
   if (_scute_debug_flags & DBG_ASSUAN)
     assuan_set_log_stream (*ctx_r, _scute_debug_stream);
 
+  *ctx_r = ctx;
+
   return 0;
 }
 
@@ -1178,6 +1185,6 @@ scute_agent_finalize (void)
     }
 
   DEBUG (DBG_INFO, "releasing agent context");
-  assuan_disconnect (agent_ctx);
+  assuan_release (agent_ctx);
   agent_ctx = NULL;
 }

+ 46 - 8
src/cert-gpgsm.c

@@ -559,12 +559,23 @@ export_cert_compat (char *fpr, struct cert *cert)
   child_fds[0] = output_fds[1];
   child_fds[1] = -1;
 
-  err = assuan_pipe_connect_ext (&ctx, get_gpgsm_path (), argv, child_fds,
+  err = assuan_new (&ctx);
+  if (err)
+    {
+      close (output_fds[0]);
+      close (output_fds[1]);
+      DEBUG (DBG_CRIT, "failed to allocate assuan context: %s\n",
+	     gpg_strerror (err));
+      return err;
+    }
+
+  err = assuan_pipe_connect_ext (ctx, get_gpgsm_path (), argv, child_fds,
 				 NULL, NULL, 128);
   close (output_fds[1]);
   if (err)
     {
       close (output_fds[0]);
+      assuan_release (ctx);
       DEBUG (DBG_CRIT, "failed to spawn %s\n", get_gpgsm_path ());
       return err;
     }
@@ -594,7 +605,7 @@ export_cert_compat (char *fpr, struct cert *cert)
     err = gpg_error (GPG_ERR_GENERAL);
 
  export_out:
-  assuan_disconnect (ctx);
+  assuan_release (ctx);
   close (output_fds[0]);
   return err;
 }
@@ -651,10 +662,19 @@ export_cert (char *fpr, struct cert *cert)
   char cmd[COMMANDLINELEN];
   struct export_hook exp;
 
-  err = assuan_pipe_connect_ext (&ctx, get_gpgsm_path (), argv, NULL,
+  err = assuan_new (&ctx);
+  if (err)
+    {
+      DEBUG (DBG_CRIT, "failed to allocate assuan context: %s",
+	     gpg_strerror (err));
+      return err;
+    }
+
+  err = assuan_pipe_connect_ext (ctx, get_gpgsm_path (), argv, NULL,
 				 NULL, NULL, 128);
   if (err)
     {
+      assuan_release (ctx);
       DEBUG (DBG_CRIT, "spawning %s\n", get_gpgsm_path ());
       return err;
     }
@@ -666,7 +686,7 @@ export_cert (char *fpr, struct cert *cert)
   snprintf (cmd, sizeof (cmd), "EXPORT --data -- %s\n", cert->fpr);
   err = assuan_transact (ctx, cmd, export_cert_cb, &exp,
 			 NULL, NULL, NULL, NULL);
-  assuan_disconnect (ctx);
+  assuan_release (ctx);
 
   if (!err)
     {
@@ -729,10 +749,19 @@ scute_gpgsm_search_certs_by_grip (const char *grip,
   const char *argv[] = { "gpgsm", "--server", NULL };
   struct search_ctx_by_field search;
 
-  err = assuan_pipe_connect_ext (&ctx, get_gpgsm_path (), argv, NULL,
+  err = assuan_new (&ctx);
+  if (err)
+    {
+      DEBUG (DBG_CRIT, "failed to allocate assuan context: %s",
+	     gpg_strerror (err));
+      return err;
+    }
+
+  err = assuan_pipe_connect_ext (ctx, get_gpgsm_path (), argv, NULL,
 				 NULL, NULL, 128);
   if (err)
     {
+      assuan_release (ctx);
       DEBUG (DBG_CRIT, "spawning %s\n", get_gpgsm_path ());
       return err;
     }
@@ -743,7 +772,7 @@ scute_gpgsm_search_certs_by_grip (const char *grip,
   search.search_cb_hook = search_cb_hook;
 
   err = scute_gpgsm_search_certs (ctx, &search_certs_by_field, &search);
-  assuan_disconnect (ctx);
+  assuan_release (ctx);
   return err;
 }
 
@@ -760,10 +789,19 @@ scute_gpgsm_search_certs_by_fpr (const char *fpr,
   const char *argv[] = { "gpgsm", "--server", NULL };
   struct search_ctx_by_field search;
 
-  err = assuan_pipe_connect_ext (&ctx, get_gpgsm_path (), argv, NULL,
+  err = assuan_new (&ctx);
+  if (err)
+    {
+      DEBUG (DBG_CRIT, "failed to allocate assuan context: %s",
+	     gpg_strerror (err));
+      return err;
+    }
+
+  err = assuan_pipe_connect_ext (ctx, get_gpgsm_path (), argv, NULL,
 				 NULL, NULL, 128);
   if (err)
     {
+      assuan_release (ctx);
       DEBUG (DBG_CRIT, "failed to spawn %s\n", get_gpgsm_path ());
       return err;
     }
@@ -774,6 +812,6 @@ scute_gpgsm_search_certs_by_fpr (const char *fpr,
   search.search_cb_hook = search_cb_hook;
 
   err = scute_gpgsm_search_certs (ctx, &search_certs_by_field, &search);
-  assuan_disconnect (ctx);
+  assuan_release (ctx);
   return err;
 }

+ 0 - 2
src/debug.c

@@ -137,7 +137,5 @@ _scute_debug_init (void)
 
       assuan_set_assuan_log_prefix ("scute-assuan");
       _scute_debug_stream = stream;
-      if (_scute_debug_flags & DBG_ASSUAN)
-	assuan_set_assuan_log_stream (stream);
     }
 }

+ 1 - 3
src/p11-initialize.c

@@ -53,9 +53,7 @@ CK_DEFINE_FUNCTION(CK_RV, C_Initialize) (CK_VOID_PTR pInitArgs)
   /* This is one of the few functions which do not need to take the
      global lock.  */
 
-  /* Set the assuan error source, so that gpg_error_t becomes a valid
-     substitute for assuan_error_t.  */
-  assuan_set_assuan_err_source (GPG_ERR_SOURCE_ANY);
+  assuan_set_gpg_err_source (GPG_ERR_SOURCE_ANY);
 
   _scute_debug_init ();