Add option --no-ask for GET_PASSPHRASE.

This commit is contained in:
Werner Koch 2008-12-10 12:41:15 +00:00
parent c3e097f29f
commit c3752d1057
3 changed files with 19 additions and 3 deletions

View File

@ -1,3 +1,7 @@
2008-12-10 Werner Koch <wk@g10code.com>
* command.c (cmd_get_passphrase): Implement option --no-ask.
2008-12-09 Werner Koch <wk@g10code.com>
* gpg-agent.c (main): Call i18n_init before init_common_subsystems.

View File

@ -836,7 +836,7 @@ send_back_passphrase (assuan_context_t ctx, int via_data, const char *pw)
}
/* GET_PASSPHRASE [--data] [--check] <cache_id>
/* GET_PASSPHRASE [--data] [--check] [--no-ask] <cache_id>
[<error_message> <prompt> <description>]
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

View File

@ -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