[git] GnuPG - branch, master, updated. post-nuke-of-trailing-ws-31-g3582e2e

by Ben Kibbey cvs at cvs.gnupg.org
Fri Mar 4 10:04:27 CET 2011


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  3582e2efa4cf1fd955d8ebe848e0a996ab15305e (commit)
      from  b786f0e12b93d8d61eea18c934f5731fe86402d3 (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 3582e2efa4cf1fd955d8ebe848e0a996ab15305e
Author: Ben Kibbey <bjk at luxsci.net>
Date:   Thu Mar 3 22:20:08 2011 -0500

    Added option --inquire to PRESET_PASSPHRASE. Note that the inquired passphrase will be truncated to the first encountered null byte.

diff --git a/agent/ChangeLog b/agent/ChangeLog
index de5f3da..f4be533 100644
--- a/agent/ChangeLog
+++ b/agent/ChangeLog
@@ -1,3 +1,7 @@
+2011-03-03  Ben Kibbey  <bjk at luxsci.net>
+
+	* command.c (cmd_preset_passphrase): Add option --inquire.
+
 2011-03-03  Werner Koch  <wk at g10code.com>
 
 	* gpg-agent.c: Add option --allow-loopback-pinentry.
diff --git a/agent/command.c b/agent/command.c
index b4b9b9e..9df72aa 100644
--- a/agent/command.c
+++ b/agent/command.c
@@ -1528,25 +1528,29 @@ cmd_passwd (assuan_context_t ctx, char *line)
 
 
 static const char hlp_preset_passphrase[] =
-  "PRESET_PASSPHRASE <string_or_keygrip> <timeout> <hexstring>\n"
+  "PRESET_PASSPHRASE [--inquire] <string_or_keygrip> <timeout> [<hexstring>]\n"
   "\n"
   "Set the cached passphrase/PIN for the key identified by the keygrip\n"
   "to passwd for the given time, where -1 means infinite and 0 means\n"
   "the default (currently only a timeout of -1 is allowed, which means\n"
   "to never expire it).  If passwd is not provided, ask for it via the\n"
-  "pinentry module.";
+  "pinentry module unless --inquire is passed in which case the passphrase\n"
+  "is retrieved from the client via a server inquire.\n";
 static gpg_error_t
 cmd_preset_passphrase (assuan_context_t ctx, char *line)
 {
   int rc;
   char *grip_clear = NULL;
-  char *passphrase = NULL;
+  unsigned char *passphrase = NULL;
   int ttl;
   size_t len;
+  int opt_inquire;
 
   if (!opt.allow_preset_passphrase)
     return set_error (GPG_ERR_NOT_SUPPORTED, "no --allow-preset-passphrase");
 
+  opt_inquire = has_option (line, "--inquire");
+  line = skip_options (line);
   grip_clear = line;
   while (*line && (*line != ' ' && *line != '\t'))
     line++;
@@ -1577,17 +1581,35 @@ cmd_preset_passphrase (assuan_context_t ctx, char *line)
      required.  */
   if (*line)
     {
+      if (opt_inquire)
+        {
+	  rc = set_error (GPG_ERR_ASS_PARAMETER,
+                          "both --inquire and passphrase specified");
+	  goto leave;
+	}
+
       /* Do in-place conversion.  */
       passphrase = line;
       if (!hex2str (passphrase, passphrase, strlen (passphrase)+1, NULL))
         rc = set_error (GPG_ERR_ASS_PARAMETER, "invalid hexstring");
     }
+  else if (opt_inquire)
+    {
+      /* Note that the passphrase will be truncated at any null byte and the
+       * limit is 480 characters. */
+      rc = assuan_inquire (ctx, "PASSPHRASE", &passphrase, &len, 480);
+    }
   else
     rc = set_error (GPG_ERR_NOT_IMPLEMENTED, "passphrase is required");
 
   if (!rc)
-    rc = agent_put_cache (grip_clear, CACHE_MODE_ANY, passphrase, ttl);
+    {
+      rc = agent_put_cache (grip_clear, CACHE_MODE_ANY, passphrase, ttl);
+      if (opt_inquire)
+	xfree (passphrase);
+    }
 
+leave:
   return leave_cmd (ctx, rc);
 }
 

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

Summary of changes:
 agent/ChangeLog |    4 ++++
 agent/command.c |   30 ++++++++++++++++++++++++++----
 2 files changed, 30 insertions(+), 4 deletions(-)


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




More information about the Gnupg-commits mailing list