diff --git a/agent/ChangeLog b/agent/ChangeLog index a9e7be62b..68d06e9f5 100644 --- a/agent/ChangeLog +++ b/agent/ChangeLog @@ -1,3 +1,7 @@ +2008-12-10 Werner Koch + + * command.c (cmd_get_passphrase): Implement option --no-ask. + 2008-12-09 Werner Koch * gpg-agent.c (main): Call i18n_init before init_common_subsystems. diff --git a/agent/command.c b/agent/command.c index aaa2e4189..b2903f6c9 100644 --- a/agent/command.c +++ b/agent/command.c @@ -836,7 +836,7 @@ send_back_passphrase (assuan_context_t ctx, int via_data, const char *pw) } -/* GET_PASSPHRASE [--data] [--check] +/* GET_PASSPHRASE [--data] [--check] [--no-ask] [ ] This function is usually used to ask for a passphrase to be used @@ -853,6 +853,10 @@ send_back_passphrase (assuan_context_t ctx, int via_data, const char *pw) If the option "--check" is used the passphrase constraints checks as implemented by gpg-agent are applied. A check is not done if the passphrase has been found in the cache. + + If the option "--no-ask" is used and the passphrase is not in the + cache the user will not be asked to enter a passphrase but the error + code GPG_ERR_NO_DATA is returned. */ static int @@ -865,10 +869,11 @@ cmd_get_passphrase (assuan_context_t ctx, char *line) char *cacheid = NULL, *desc = NULL, *prompt = NULL, *errtext = NULL; char *p; void *cache_marker; - int opt_data, opt_check; + int opt_data, opt_check, opt_no_ask; opt_data = has_option (line, "--data"); opt_check = has_option (line, "--check"); + opt_no_ask = has_option (line, "--no-ask"); line = skip_options (line); cacheid = line; @@ -920,6 +925,8 @@ cmd_get_passphrase (assuan_context_t ctx, char *line) rc = send_back_passphrase (ctx, opt_data, pw); agent_unlock_cache_entry (&cache_marker); } + else if (opt_no_ask) + rc = gpg_error (GPG_ERR_NO_DATA); else { /* Note, that we only need to replace the + characters and diff --git a/doc/gpg-agent.texi b/doc/gpg-agent.texi index fdbbdae2f..2900154a9 100644 --- a/doc/gpg-agent.texi +++ b/doc/gpg-agent.texi @@ -1036,7 +1036,7 @@ special handling of passphrases. This command uses a syntax which helps clients to use the agent with minimum effort. @example - GET_PASSPHRASE [--data] [--check] @var{cache_id} [@var{error_message} @var{prompt} @var{description}] + GET_PASSPHRASE [--data] [--check] [--no-ask] @var{cache_id} [@var{error_message} @var{prompt} @var{description}] @end example @var{cache_id} is expected to be a string used to identify a cached @@ -1067,6 +1067,11 @@ If the option @option{--check} is used, the standard passphrase constraints checks are applied. A check is not done if the passphrase has been found in the cache. +If the option @option{--no-ask} is used and the passphrase is not in the +cache the user will not be asked to enter a passphrase but the error +code @code{GPG_ERR_NO_DATA} is returned. + + @example CLEAR_PASSPHRASE @var{cache_id} @end example