diff options
author | Werner Koch <wk@gnupg.org> | 2011-04-21 15:40:48 +0200 |
---|---|---|
committer | Werner Koch <wk@gnupg.org> | 2011-04-21 15:40:48 +0200 |
commit | 4caa768f1d3388f36a6de4be9f71d916696b9e2d (patch) | |
tree | 059a687105ad2fe2b63aa5cf9205c418f1dd7f27 | |
parent | 2011-04-20 Marcus Brinkmann <mb@g10code.com> (diff) | |
download | gnupg2-4caa768f1d3388f36a6de4be9f71d916696b9e2d.tar.xz gnupg2-4caa768f1d3388f36a6de4be9f71d916696b9e2d.zip |
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.
-rw-r--r-- | agent/ChangeLog | 8 | ||||
-rw-r--r-- | agent/agent.h | 9 | ||||
-rw-r--r-- | agent/command.c | 10 | ||||
-rw-r--r-- | agent/genkey.c | 4 | ||||
-rw-r--r-- | agent/gpg-agent.c | 1 | ||||
-rw-r--r-- | doc/gpg-agent.texi | 6 |
6 files changed, 31 insertions, 7 deletions
diff --git a/agent/ChangeLog b/agent/ChangeLog index e342b571f..9a6134d7f 100644 --- a/agent/ChangeLog +++ b/agent/ChangeLog @@ -1,3 +1,11 @@ +2011-04-21 Werner Koch <wk@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@g10code.com> * command.c (cmd_import_key): Release key from failed import diff --git a/agent/agent.h b/agent/agent.h index 20a617f78..16c9aba56 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 34617ade7..62bf14501 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 30e698f77..79b99e6e5 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 c64b32feb..87a4299ac 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 280670bd3..e965c5236 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 + +@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 |