[git] GnuPG - branch, master, updated. gnupg-2.1.10-96-g4966432

by Werner Koch cvs at cvs.gnupg.org
Fri Jan 8 06:47:26 CET 2016


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 Guard".

The branch, master has been updated
       via  496643291e1e346434e9c98405c5a370957eb7d3 (commit)
       via  833ba5faa1340aff80a205acbb701d4ae1d594d0 (commit)
      from  8fd406c317ad7c2e375ae4f7d20656dadf6d7fcc (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 496643291e1e346434e9c98405c5a370957eb7d3
Author: Werner Koch <wk at gnupg.org>
Date:   Fri Jan 8 06:42:29 2016 +0100

    common: New function get_assuan_server_version.
    
    * common/asshelp.c: Include membuf.h.
    (get_assuan_server_version): New.
    * g10/call-agent.c (agent_get_version): Use new function.
    --
    
    Signed-off-by: Werner Koch <wk at gnupg.org>

diff --git a/common/asshelp.c b/common/asshelp.c
index d33ffb5..f2b4402 100644
--- a/common/asshelp.c
+++ b/common/asshelp.c
@@ -42,6 +42,7 @@
 #include "exechelp.h"
 #include "sysutils.h"
 #include "status.h"
+#include "membuf.h"
 #include "asshelp.h"
 
 /* The type we use for lock_agent_spawning.  */
@@ -699,3 +700,40 @@ start_new_dirmngr (assuan_context_t *r_ctx,
   *r_ctx = ctx;
   return 0;
 }
+
+
+/* Return the version of a server using "GETINFO version".  On success
+   0 is returned and R_VERSION receives a malloced string with the
+   version which must be freed by the caller.  On error NULL is stored
+   at R_VERSION and an error code returned.  Mode is in general 0 but
+   certian values may be used to modify the used version command:
+
+      MODE == 0 = Use "GETINFO version"
+      MODE == 2 - Use "SCD GETINFO version"
+ */
+gpg_error_t
+get_assuan_server_version (assuan_context_t ctx, int mode, char **r_version)
+{
+  gpg_error_t err;
+  membuf_t data;
+
+  init_membuf (&data, 64);
+  err = assuan_transact (ctx,
+                         mode == 2? "SCD GETINFO version"
+                         /**/     : "GETINFO version",
+                         put_membuf_cb, &data,
+                         NULL, NULL, NULL, NULL);
+  if (err)
+    {
+      xfree (get_membuf (&data, NULL));
+      *r_version = NULL;
+    }
+  else
+    {
+      put_membuf (&data, "", 1);
+      *r_version = get_membuf (&data, NULL);
+      if (!*r_version)
+        err = gpg_error_from_syserror ();
+    }
+  return err;
+}
diff --git a/common/asshelp.h b/common/asshelp.h
index 35d2115..20414bd 100644
--- a/common/asshelp.h
+++ b/common/asshelp.h
@@ -74,6 +74,10 @@ start_new_dirmngr (assuan_context_t *r_ctx,
                    gpg_error_t (*status_cb)(ctrl_t, int, ...),
                    ctrl_t status_cb_arg);
 
+/* Return the version of a server using "GETINFO version".  */
+gpg_error_t get_assuan_server_version (assuan_context_t ctx,
+                                       int mode, char **r_version);
+
 
 /*-- asshelp2.c --*/
 
diff --git a/g10/call-agent.c b/g10/call-agent.c
index 363fc85..3600579 100644
--- a/g10/call-agent.c
+++ b/g10/call-agent.c
@@ -2408,27 +2408,11 @@ gpg_error_t
 agent_get_version (ctrl_t ctrl, char **r_version)
 {
   gpg_error_t err;
-  membuf_t data;
 
   err = start_agent (ctrl, 0);
   if (err)
     return err;
 
-  init_membuf (&data, 64);
-  err = assuan_transact (agent_ctx, "GETINFO version",
-                        put_membuf_cb, &data,
-                        NULL, NULL, NULL, NULL);
-  if (err)
-    {
-      xfree (get_membuf (&data, NULL));
-      *r_version = NULL;
-    }
-  else
-    {
-      put_membuf (&data, "", 1);
-      *r_version = get_membuf (&data, NULL);
-      if (!*r_version)
-        err = gpg_error_from_syserror ();
-    }
+  err = get_assuan_server_version (agent_ctx, 0, r_version);
   return err;
 }

commit 833ba5faa1340aff80a205acbb701d4ae1d594d0
Author: Werner Koch <wk at gnupg.org>
Date:   Fri Jan 8 06:33:27 2016 +0100

    common: New put_membuf_cb to replace static membuf_data_cb.
    
    * common/membuf.c (put_membuf_cb): New.
    * agent/call-scd.c (membuf_data_cb): Remove.  Change callers to use
    put_membuf_cb.
    * common/get-passphrase.c (membuf_data_cb): Ditto.
    * g10/call-agent.c (membuf_data_cb): Ditto.
    * sm/call-agent.c (membuf_data_cb): Ditto.
    --
    
    Signed-off-by: Werner Koch <wk at gnupg.org>

diff --git a/agent/call-scd.c b/agent/call-scd.c
index 9c4d7b1..b776840 100644
--- a/agent/call-scd.c
+++ b/agent/call-scd.c
@@ -113,8 +113,6 @@ static int primary_scd_ctx_reusable;
 
 
 /* Local prototypes.  */
-static gpg_error_t membuf_data_cb (void *opaque,
-				   const void *buffer, size_t length);
 
 
 
@@ -354,7 +352,7 @@ start_scd (ctrl_t ctrl)
     socket_name = NULL;
     init_membuf (&data, 256);
     assuan_transact (ctx, "GETINFO socket_name",
-                     membuf_data_cb, &data, NULL, NULL, NULL, NULL);
+                     put_membuf_cb, &data, NULL, NULL, NULL, NULL);
 
     databuf = get_membuf (&data, &datalen);
     if (databuf && datalen)
@@ -688,16 +686,6 @@ agent_card_serialno (ctrl_t ctrl, char **r_serialno)
 
 
 

-static gpg_error_t
-membuf_data_cb (void *opaque, const void *buffer, size_t length)
-{
-  membuf_t *data = opaque;
-
-  if (buffer)
-    put_membuf (data, buffer, length);
-  return 0;
-}
-
 /* Handle the NEEDPIN inquiry. */
 static gpg_error_t
 inq_needpin (void *opaque, const char *line)
@@ -855,7 +843,7 @@ agent_card_pksign (ctrl_t ctrl,
     snprintf (line, sizeof line, "PKSIGN %s %s",
               hash_algo_option (mdalgo), keyid);
   rc = assuan_transact (ctrl->scd_local->ctx, line,
-                        membuf_data_cb, &data,
+                        put_membuf_cb, &data,
                         inq_needpin, &inqparm,
                         NULL, NULL);
   if (inqparm.any_inq_seen && (gpg_err_code(rc) == GPG_ERR_CANCELED ||
@@ -944,7 +932,7 @@ agent_card_pkdecrypt (ctrl_t ctrl,
   snprintf (line, DIM(line)-1, "PKDECRYPT %s", keyid);
   line[DIM(line)-1] = 0;
   rc = assuan_transact (ctrl->scd_local->ctx, line,
-                        membuf_data_cb, &data,
+                        put_membuf_cb, &data,
                         inq_needpin, &inqparm,
                         padding_info_cb, r_padding);
   if (inqparm.any_inq_seen && (gpg_err_code(rc) == GPG_ERR_CANCELED ||
@@ -984,7 +972,7 @@ agent_card_readcert (ctrl_t ctrl,
   snprintf (line, DIM(line)-1, "READCERT %s", id);
   line[DIM(line)-1] = 0;
   rc = assuan_transact (ctrl->scd_local->ctx, line,
-                        membuf_data_cb, &data,
+                        put_membuf_cb, &data,
                         NULL, NULL,
                         NULL, NULL);
   if (rc)
@@ -1020,7 +1008,7 @@ agent_card_readkey (ctrl_t ctrl, const char *id, unsigned char **r_buf)
   snprintf (line, DIM(line)-1, "READKEY %s", id);
   line[DIM(line)-1] = 0;
   rc = assuan_transact (ctrl->scd_local->ctx, line,
-                        membuf_data_cb, &data,
+                        put_membuf_cb, &data,
                         NULL, NULL,
                         NULL, NULL);
   if (rc)
diff --git a/common/get-passphrase.c b/common/get-passphrase.c
index 53ce7d1..f1517fb 100644
--- a/common/get-passphrase.c
+++ b/common/get-passphrase.c
@@ -130,17 +130,6 @@ default_inq_cb (void *opaque, const char *line)
 }
 
 
-static gpg_error_t
-membuf_data_cb (void *opaque, const void *buffer, size_t length)
-{
-  membuf_t *data = opaque;
-
-  if (buffer)
-    put_membuf (data, buffer, length);
-  return 0;
-}
-
-
 /* Ask for a passphrase via gpg-agent.  On success the caller needs to
    free the string stored at R_PASSPHRASE.  On error NULL will be
    stored at R_PASSPHRASE and an appropriate gpg error code is
@@ -214,7 +203,7 @@ gnupg_get_passphrase (const char *cache_id,
   else
     init_membuf (&data, 64);
   err = assuan_transact (agent_ctx, line,
-                         membuf_data_cb, &data,
+                         put_membuf_cb, &data,
                          default_inq_cb, NULL, NULL, NULL);
 
   /* Older Pinentries return the old assuan error code for canceled
diff --git a/common/membuf.c b/common/membuf.c
index f4430a9..fde24f6 100644
--- a/common/membuf.c
+++ b/common/membuf.c
@@ -116,6 +116,20 @@ put_membuf (membuf_t *mb, const void *buf, size_t len)
 }
 
 
+/* A variant of put_membuf accepting a void * and returning a
+   gpg_error_t (which will always return 0) to be used as a generic
+   callback handler.  This function also allows buffer to be NULL.  */
+gpg_error_t
+put_membuf_cb (void *opaque, const void *buf, size_t len)
+{
+  membuf_t *data = opaque;
+
+  if (buf)
+    put_membuf (data, buf, len);
+  return 0;
+}
+
+
 void
 put_membuf_str (membuf_t *mb, const char *string)
 {
diff --git a/common/membuf.h b/common/membuf.h
index eb7d565..a1610b6 100644
--- a/common/membuf.h
+++ b/common/membuf.h
@@ -53,6 +53,7 @@ void init_membuf (membuf_t *mb, int initiallen);
 void init_membuf_secure (membuf_t *mb, int initiallen);
 void clear_membuf (membuf_t *mb, size_t amount);
 void put_membuf  (membuf_t *mb, const void *buf, size_t len);
+gpg_error_t put_membuf_cb (void *opaque, const void *buf, size_t len);
 void put_membuf_str (membuf_t *mb, const char *string);
 void put_membuf_printf (membuf_t *mb, const char *format,
                         ...) GPGRT_ATTR_PRINTF(2,3);
diff --git a/g10/call-agent.c b/g10/call-agent.c
index 26de72e..363fc85 100644
--- a/g10/call-agent.c
+++ b/g10/call-agent.c
@@ -137,18 +137,6 @@ status_sc_op_failure (int rc)
 }
 
 
-static gpg_error_t
-membuf_data_cb (void *opaque, const void *buffer, size_t length)
-{
-  membuf_t *data = opaque;
-
-  if (buffer)
-    put_membuf (data, buffer, length);
-  return 0;
-}
-
-
-
 /* This is the default inquiry callback.  It mainly handles the
    Pinentry notifications.  */
 static gpg_error_t
@@ -214,7 +202,7 @@ check_hijacking (assuan_context_t ctx)
   /* AGENT_ID is a command implemented by gnome-keyring-daemon.  It
      does not return any data but an OK line with a remark.  */
   if (assuan_transact (ctx, "AGENT_ID",
-                       membuf_data_cb, &mb, NULL, NULL, NULL, NULL))
+                       put_membuf_cb, &mb, NULL, NULL, NULL, NULL))
     {
       xfree (get_membuf (&mb, NULL));
       return; /* Error - Probably not hijacked.  */
@@ -780,7 +768,7 @@ agent_scd_apdu (const char *hexapdu, unsigned int *r_sw)
 
       snprintf (line, DIM(line)-1, "SCD APDU %s", hexapdu);
       err = assuan_transact (agent_ctx, line,
-                             membuf_data_cb, &mb, NULL, NULL, NULL, NULL);
+                             put_membuf_cb, &mb, NULL, NULL, NULL, NULL);
       if (!err)
         {
           data = get_membuf (&mb, &datalen);
@@ -1292,7 +1280,7 @@ agent_scd_readcert (const char *certidstr,
   snprintf (line, DIM(line)-1, "SCD READCERT %s", certidstr);
   line[DIM(line)-1] = 0;
   rc = assuan_transact (agent_ctx, line,
-                        membuf_data_cb, &data,
+                        put_membuf_cb, &data,
                         default_inq_cb, &dfltparm,
                         NULL, NULL);
   if (rc)
@@ -1455,7 +1443,7 @@ agent_get_passphrase (const char *cache_id,
 
   init_membuf_secure (&data, 64);
   rc = assuan_transact (agent_ctx, line,
-                        membuf_data_cb, &data,
+                        put_membuf_cb, &data,
                         default_inq_cb, &dfltparm,
                         NULL, NULL);
 
@@ -1553,7 +1541,7 @@ agent_get_s2k_count (unsigned long *r_count)
 
   init_membuf (&data, 32);
   err = assuan_transact (agent_ctx, "GETINFO s2k_count",
-                        membuf_data_cb, &data,
+                        put_membuf_cb, &data,
                         NULL, NULL, NULL, NULL);
   if (err)
     xfree (get_membuf (&data, NULL));
@@ -1825,7 +1813,7 @@ agent_genkey (ctrl_t ctrl, char **cache_nonce_addr,
   cn_parm.cache_nonce_addr = cache_nonce_addr;
   cn_parm.passwd_nonce_addr = NULL;
   err = assuan_transact (agent_ctx, line,
-                         membuf_data_cb, &data,
+                         put_membuf_cb, &data,
                          inq_genkey_parms, &gk_parm,
                          cache_nonce_status_cb, &cn_parm);
   if (err)
@@ -1879,7 +1867,7 @@ agent_readkey (ctrl_t ctrl, int fromcard, const char *hexkeygrip,
 
   init_membuf (&data, 1024);
   err = assuan_transact (agent_ctx, line,
-                         membuf_data_cb, &data,
+                         put_membuf_cb, &data,
                          default_inq_cb, &dfltparm,
                          NULL, NULL);
   if (err)
@@ -1967,7 +1955,7 @@ agent_pksign (ctrl_t ctrl, const char *cache_nonce,
             cache_nonce? " -- ":"",
             cache_nonce? cache_nonce:"");
   err = assuan_transact (agent_ctx, line,
-                         membuf_data_cb, &data,
+                         put_membuf_cb, &data,
                          default_inq_cb, &dfltparm,
                          NULL, NULL);
   if (err)
@@ -2097,7 +2085,7 @@ agent_pkdecrypt (ctrl_t ctrl, const char *keygrip, const char *desc,
     if (err)
       return err;
     err = assuan_transact (agent_ctx, "PKDECRYPT",
-                           membuf_data_cb, &data,
+                           put_membuf_cb, &data,
                            inq_ciphertext_cb, &parm,
                            padding_info_cb, r_padding);
     xfree (parm.ciphertext);
@@ -2177,7 +2165,7 @@ agent_keywrap_key (ctrl_t ctrl, int forexport, void **r_kek, size_t *r_keklen)
 
   init_membuf_secure (&data, 64);
   err = assuan_transact (agent_ctx, line,
-                         membuf_data_cb, &data,
+                         put_membuf_cb, &data,
                          default_inq_cb, &dfltparm,
                          NULL, NULL);
   if (err)
@@ -2309,7 +2297,7 @@ agent_export_key (ctrl_t ctrl, const char *hexkeygrip, const char *desc,
   cn_parm.cache_nonce_addr = cache_nonce_addr;
   cn_parm.passwd_nonce_addr = NULL;
   err = assuan_transact (agent_ctx, line,
-                         membuf_data_cb, &data,
+                         put_membuf_cb, &data,
                          default_inq_cb, &dfltparm,
                          cache_nonce_status_cb, &cn_parm);
   if (err)
@@ -2428,7 +2416,7 @@ agent_get_version (ctrl_t ctrl, char **r_version)
 
   init_membuf (&data, 64);
   err = assuan_transact (agent_ctx, "GETINFO version",
-                        membuf_data_cb, &data,
+                        put_membuf_cb, &data,
                         NULL, NULL, NULL, NULL);
   if (err)
     {
diff --git a/sm/call-agent.c b/sm/call-agent.c
index c1457b6..b881fb8 100644
--- a/sm/call-agent.c
+++ b/sm/call-agent.c
@@ -128,18 +128,6 @@ start_agent (ctrl_t ctrl)
 }
 
 
-
-static gpg_error_t
-membuf_data_cb (void *opaque, const void *buffer, size_t length)
-{
-  membuf_t *data = opaque;
-
-  if (buffer)
-    put_membuf (data, buffer, length);
-  return 0;
-}
-
-
 /* This is the default inquiry callback.  It mainly handles the
    Pinentry notifications.  */
 static gpg_error_t
@@ -215,7 +203,7 @@ gpgsm_agent_pksign (ctrl_t ctrl, const char *keygrip, const char *desc,
 
   init_membuf (&data, 1024);
   rc = assuan_transact (agent_ctx, "PKSIGN",
-                        membuf_data_cb, &data, default_inq_cb, ctrl,
+                        put_membuf_cb, &data, default_inq_cb, ctrl,
                         NULL, NULL);
   if (rc)
     {
@@ -282,7 +270,7 @@ gpgsm_scd_pksign (ctrl_t ctrl, const char *keyid, const char *desc,
   snprintf (line, DIM(line)-1, "SCD PKSIGN %s %s", hashopt, keyid);
   line[DIM(line)-1] = 0;
   rc = assuan_transact (agent_ctx, line,
-                        membuf_data_cb, &data, default_inq_cb, ctrl,
+                        put_membuf_cb, &data, default_inq_cb, ctrl,
                         NULL, NULL);
   if (rc)
     {
@@ -392,7 +380,7 @@ gpgsm_agent_pkdecrypt (ctrl_t ctrl, const char *keygrip, const char *desc,
   cipher_parm.ciphertext = ciphertext;
   cipher_parm.ciphertextlen = ciphertextlen;
   rc = assuan_transact (agent_ctx, "PKDECRYPT",
-                        membuf_data_cb, &data,
+                        put_membuf_cb, &data,
                         inq_ciphertext_cb, &cipher_parm, NULL, NULL);
   if (rc)
     {
@@ -487,7 +475,7 @@ gpgsm_agent_genkey (ctrl_t ctrl,
   if (!gk_parm.sexplen)
     return gpg_error (GPG_ERR_INV_VALUE);
   rc = assuan_transact (agent_ctx, "GENKEY",
-                        membuf_data_cb, &data,
+                        put_membuf_cb, &data,
                         inq_genkey_parms, &gk_parm, NULL, NULL);
   if (rc)
     {
@@ -536,7 +524,7 @@ gpgsm_agent_readkey (ctrl_t ctrl, int fromcard, const char *hexkeygrip,
 
   init_membuf (&data, 1024);
   rc = assuan_transact (agent_ctx, line,
-                        membuf_data_cb, &data,
+                        put_membuf_cb, &data,
                         default_inq_cb, ctrl, NULL, NULL);
   if (rc)
     {
@@ -1117,7 +1105,7 @@ gpgsm_agent_ask_passphrase (ctrl_t ctrl, const char *desc_msg, int repeat,
 
   init_membuf_secure (&data, 64);
   err = assuan_transact (agent_ctx, line,
-                         membuf_data_cb, &data,
+                         put_membuf_cb, &data,
                          default_inq_cb, NULL, NULL, NULL);
 
   if (err)
@@ -1157,7 +1145,7 @@ gpgsm_agent_keywrap_key (ctrl_t ctrl, int forexport,
 
   init_membuf_secure (&data, 64);
   err = assuan_transact (agent_ctx, line,
-                         membuf_data_cb, &data,
+                         put_membuf_cb, &data,
                          default_inq_cb, ctrl, NULL, NULL);
   if (err)
     {
@@ -1251,7 +1239,7 @@ gpgsm_agent_export_key (ctrl_t ctrl, const char *keygrip, const char *desc,
 
   init_membuf_secure (&data, 1024);
   err = assuan_transact (agent_ctx, line,
-                         membuf_data_cb, &data,
+                         put_membuf_cb, &data,
                          default_inq_cb, ctrl, NULL, NULL);
   if (err)
     {

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

Summary of changes:
 agent/call-scd.c        | 22 +++++----------------
 common/asshelp.c        | 38 ++++++++++++++++++++++++++++++++++++
 common/asshelp.h        |  4 ++++
 common/get-passphrase.c | 13 +------------
 common/membuf.c         | 14 +++++++++++++
 common/membuf.h         |  1 +
 g10/call-agent.c        | 52 ++++++++++++-------------------------------------
 sm/call-agent.c         | 28 ++++++++------------------
 8 files changed, 83 insertions(+), 89 deletions(-)


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




More information about the Gnupg-commits mailing list