[git] GnuPG - branch, master, updated. post-nuke-of-trailing-ws-47-g4caa768

by Werner Koch cvs at cvs.gnupg.org
Thu Apr 21 16:10:36 CEST 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  4caa768f1d3388f36a6de4be9f71d916696b9e2d (commit)
      from  dd491d290ad973fd1b73ab83ad0139449008c62a (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 4caa768f1d3388f36a6de4be9f71d916696b9e2d
Author: Werner Koch <wk at gnupg.org>
Date:   Thu Apr 21 15:40:48 2011 +0200

    Add OPTION:cache-ttl-opt-preset to gpg-agent.
    
    This option may be used to change the default ttl values use with the
    --preset option of GENKEY and PASSWD.

diff --git a/agent/ChangeLog b/agent/ChangeLog
index e342b57..9a6134d 100644
--- a/agent/ChangeLog
+++ b/agent/ChangeLog
@@ -1,3 +1,11 @@
+2011-04-21  Werner Koch  <wk at g10code.com>
+
+	* agent.h (server_control_s): Add field cache_ttl_opt_preset.
+	* gpg-agent.c (agent_init_default_ctrl): Init this field.
+	* genkey.c (agent_genkey): Use this new variable.
+	* command.c (cmd_passwd): Ditto.
+	(option_handler): Add new option cache-ttl-opt-preset.
+
 2011-04-20  Marcus Brinkmann  <mb at g10code.com>
 
 	* command.c (cmd_import_key): Release key from failed import
diff --git a/agent/agent.h b/agent/agent.h
index 20a617f..16c9aba 100644
--- a/agent/agent.h
+++ b/agent/agent.h
@@ -1,5 +1,5 @@
 /* agent.h - Global definitions for the agent
- *	Copyright (C) 2001, 2002, 2003, 2005 Free Software Foundation, Inc.
+ * Copyright (C) 2001, 2002, 2003, 2005, 2011 Free Software Foundation, Inc.
  *
  * This file is part of GnuPG.
  *
@@ -164,6 +164,10 @@ struct server_control_s
   /* The current pinentry mode.  */
   pinentry_mode_t pinentry_mode;
 
+  /* The TTL used for the --preset option of certain commands.  */
+  int cache_ttl_opt_preset;
+
+  /* Information on the currently used digest (for signing commands).  */
   struct {
     int algo;
     unsigned char value[MAX_DIGEST_LEN];
@@ -220,7 +224,8 @@ cache_mode_t;
 /* The TTL is seconds used for adding a new nonce mode cache item.  */
 #define CACHE_TTL_NONCE 120
 
-/* The TTL in seconds used by the --preset option of some commands.  */
+/* The TTL in seconds used by the --preset option of some commands.
+   This is the default value changeable by an OPTION command.  */
 #define CACHE_TTL_OPT_PRESET 900
 
 
diff --git a/agent/command.c b/agent/command.c
index 34617ad..62bf145 100644
--- a/agent/command.c
+++ b/agent/command.c
@@ -1,6 +1,6 @@
 /* command.c - gpg-agent command handler
- * Copyright (C) 2001, 2002, 2003, 2004, 2005,
- *               2006, 2008, 2009, 2010  Free Software Foundation, Inc.
+ * Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2008, 2009, 2010,
+ *               2011  Free Software Foundation, Inc.
  *
  * This file is part of GnuPG.
  *
@@ -1535,7 +1535,7 @@ cmd_passwd (assuan_context_t ctx, char *line)
 	  char hexgrip[40+1];
 	  bin2hex(grip, 20, hexgrip);
 	  err = agent_put_cache (hexgrip, CACHE_MODE_ANY, newpass,
-		  CACHE_TTL_OPT_PRESET);
+                                 ctrl->cache_ttl_opt_preset);
       }
       xfree (newpass);
     }
@@ -2470,6 +2470,10 @@ option_handler (assuan_context_t ctx, const char *key, const char *value)
       else
         err = gpg_error (GPG_ERR_INV_VALUE);
     }
+  else if (!strcmp (key, "cache-ttl-opt-preset"))
+    {
+      ctrl->cache_ttl_opt_preset = *value? atoi (value) : 0;
+    }
   else
     err = gpg_error (GPG_ERR_UNKNOWN_OPTION);
 
diff --git a/agent/genkey.c b/agent/genkey.c
index 30e698f..79b99e6 100644
--- a/agent/genkey.c
+++ b/agent/genkey.c
@@ -432,7 +432,7 @@ agent_genkey (ctrl_t ctrl, const char *cache_nonce,
       if (cache_nonce
           && !no_protection
           && !agent_put_cache (cache_nonce, CACHE_MODE_NONCE,
-                               passphrase, CACHE_TTL_OPT_PRESET))
+                               passphrase, ctrl->cache_ttl_opt_preset))
         agent_write_status (ctrl, "CACHE_NONCE", cache_nonce, NULL);
       if (preset && !no_protection)
 	{
@@ -442,7 +442,7 @@ agent_genkey (ctrl_t ctrl, const char *cache_nonce,
 	    {
 	      bin2hex(grip, 20, hexgrip);
 	      rc = agent_put_cache (hexgrip, CACHE_MODE_ANY, passphrase,
-                                    CACHE_TTL_OPT_PRESET);
+                                    ctrl->cache_ttl_opt_preset);
 	    }
 	}
     }
diff --git a/agent/gpg-agent.c b/agent/gpg-agent.c
index c64b32f..87a4299 100644
--- a/agent/gpg-agent.c
+++ b/agent/gpg-agent.c
@@ -1315,6 +1315,7 @@ agent_init_default_ctrl (ctrl_t ctrl)
   ctrl->lc_messages = default_lc_messages? xtrystrdup (default_lc_messages)
                                     /**/ : NULL;
 
+  ctrl->cache_ttl_opt_preset = CACHE_TTL_OPT_PRESET;
 }
 
 
diff --git a/doc/gpg-agent.texi b/doc/gpg-agent.texi
index 280670b..e965c52 100644
--- a/doc/gpg-agent.texi
+++ b/doc/gpg-agent.texi
@@ -1348,6 +1348,12 @@ following values are defined:
   Use the @xref{option --allow-loopback-pinentry}.
 
   @end table
+
+ at item cache-ttl-opt-preset
+This option sets the cache TTL for new entries created by GENKEY and
+PASSWD commands when using the @option{--preset} option.  It it is not
+used a default value is used.
+
 @end table
 
 

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

Summary of changes:
 agent/ChangeLog    |    8 ++++++++
 agent/agent.h      |    9 +++++++--
 agent/command.c    |   10 +++++++---
 agent/genkey.c     |    4 ++--
 agent/gpg-agent.c  |    1 +
 doc/gpg-agent.texi |    6 ++++++
 6 files changed, 31 insertions(+), 7 deletions(-)


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




More information about the Gnupg-commits mailing list