[git] Pinentry - branch, master, updated. pinentry-0.9.2-36-g72b653d

by Neal H. Walfield cvs at cvs.gnupg.org
Tue May 19 11:14:36 CEST 2015


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 standard pinentry collection".

The branch, master has been updated
       via  72b653d8088ce508ab688c68d88c363832d50eb7 (commit)
      from  516e01049e9829020b40ddbcf387d4c5c05b1c3f (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 72b653d8088ce508ab688c68d88c363832d50eb7
Author: Neal H. Walfield <neal at gnu.org>
Date:   Tue May 19 11:14:33 2015 +0200

    Provide an Assuan command to clear a cached password.
    
    * pinentry/password-cache.c (password_cache_clear): New function.
    * pinentry/password-cache.h (password_cache_clear): New declaration.
    * pinentry/pinentry.c (cmd_getinfo): New function.
    (register_commands): Have the Assuan command "CLEARPASSPHRASE" call
    it.

diff --git a/pinentry/password-cache.c b/pinentry/password-cache.c
index 3548cdf..ba06b13 100644
--- a/pinentry/password-cache.c
+++ b/pinentry/password-cache.c
@@ -135,3 +135,29 @@ password_cache_lookup (const char *keygrip)
   return NULL;
 #endif
 }
+
+/* Try and remove the cached password for key grip.  Returns -1 on
+   error, 0 if the key is not found and 1 if the password was
+   removed.  */
+int
+password_cache_clear (const char *keygrip)
+{
+#ifdef HAVE_LIBSECRET
+  GError *error = NULL;
+  int removed = secret_password_clear_sync (gpg_schema (), NULL, &error,
+					    "keygrip", keygrip, NULL);
+  if (error != NULL)
+    {
+      printf("Failed to clear password for key %s with secret service: %s\n",
+	     keygrip, error->message);
+      debug(error->message);
+      g_error_free (error);
+      return -1;
+    }
+  if (removed)
+    return 1;
+  return 0;
+#else
+  return -1;
+#endif
+}
diff --git a/pinentry/password-cache.h b/pinentry/password-cache.h
index 7c6cd5a..0bc8788 100644
--- a/pinentry/password-cache.h
+++ b/pinentry/password-cache.h
@@ -24,4 +24,6 @@ void password_cache_save (const char *key_grip, const char *password);
 
 char *password_cache_lookup (const char *key_grip);
 
+int password_cache_clear (const char *keygrip);
+
 #endif
diff --git a/pinentry/pinentry.c b/pinentry/pinentry.c
index 811cee4..9a6a090 100644
--- a/pinentry/pinentry.c
+++ b/pinentry/pinentry.c
@@ -1301,6 +1301,30 @@ cmd_getinfo (assuan_context_t ctx, char *line)
   return rc;
 }
 
+/* CLEARPASSPHRASE <cacheid>
+
+   Clear the cache passphrase associated with the key identified by
+   cacheid.
+ */
+static int
+cmd_clear_passphrase (ASSUAN_CONTEXT ctx, char *line)
+{
+  if (! line)
+    return ASSUAN_Invalid_Value;
+
+  /* Remove leading and trailing white space.  */
+  while (*line == ' ')
+    line ++;
+  while (line[strlen (line) - 1] == ' ')
+    line[strlen (line) - 1] = 0;
+
+  switch (password_cache_clear (line))
+    {
+    case 1: return 0;
+    case 0: return ASSUAN_Invalid_Value;
+    default: return ASSUAN_General_Error;
+    }
+}
 
 /* Tell the assuan library about our commands.  */
 static int
@@ -1330,6 +1354,7 @@ register_commands (ASSUAN_CONTEXT ctx)
       { "GETINFO",    0,  cmd_getinfo },
       { "SETTITLE",   0,  cmd_settitle },
       { "SETTIMEOUT",   0,  cmd_settimeout },
+      { "CLEARPASSPHRASE", 0, cmd_clear_passphrase },
       { NULL }
     };
   int i, j, rc;

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

Summary of changes:
 pinentry/password-cache.c | 26 ++++++++++++++++++++++++++
 pinentry/password-cache.h |  2 ++
 pinentry/pinentry.c       | 25 +++++++++++++++++++++++++
 3 files changed, 53 insertions(+)


hooks/post-receive
-- 
The standard pinentry collection
http://git.gnupg.org




More information about the Gnupg-commits mailing list