From fe1705221d9ac161e12296899834e042c65ec6fe Mon Sep 17 00:00:00 2001 From: Ben Kibbey Date: Sun, 23 Nov 2008 08:10:37 -0500 Subject: [PATCH] When "key_file" is specified in the configuration and the cache entry gets removed for some reason, the client must provide a key to use along with the OPEN or SAVE commands. If not specified, GPG_ERR_WRONG_KEY_USAGE is returned. This won't affect the "key" configuration parameter. It'll still try to use pinentry. --- src/commands.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/commands.c b/src/commands.c index 7499100b..f2f6f8de 100644 --- a/src/commands.c +++ b/src/commands.c @@ -721,6 +721,15 @@ static int open_command(assuan_context_t ctx, char *line) * to finish the command. */ if (!req[1] || !*req[1]) { + gchar *tmp = get_key_file_string(filename, "key_file"); + + if (tmp) { + g_free(tmp); + cleanup_client(client); + g_free(fh); + return send_error(ctx, GPG_ERR_WRONG_KEY_USAGE); + } + #ifdef WITH_PINENTRY gboolean b = get_key_file_boolean(filename, "enable_pinentry"); @@ -1256,7 +1265,15 @@ static int save_command(assuan_context_t ctx, char *line) if (cache_get_key(client->md5file, shakey) == FALSE || memcmp(shakey, tmp, sizeof(shakey)) == 0) { + gchar *tmp = get_key_file_string(client->filename, "key_file"); + CACHE_UNLOCK; + + if (tmp) { + g_free(tmp); + return send_error(ctx, GPG_ERR_WRONG_KEY_USAGE); + } + #ifdef WITH_PINENTRY if (get_key_file_boolean(client->filename, "enable_pinentry") == FALSE) { gcry_md_hash_buffer(GCRY_MD_SHA256, shakey, "", 1); -- 2.11.4.GIT