From 8c9f8d7f6ad3e1fb76d8e8d38596c49e8cff74fb Mon Sep 17 00:00:00 2001 From: Ben Kibbey Date: Thu, 28 Feb 2008 20:10:42 -0500 Subject: [PATCH] Added OPTION ITERATIONS to set the encryption iterations for the current file. This will also send the CONFIG status message. --- COMMANDS | 20 +++++++++++--------- src/commands.c | 21 ++++++++++++++++++--- 2 files changed, 29 insertions(+), 12 deletions(-) diff --git a/COMMANDS b/COMMANDS index 3113b018..4a8384c5 100644 --- a/COMMANDS +++ b/COMMANDS @@ -174,15 +174,17 @@ pinentry options: NAME VALUE Description ---------|----------|---------------------------------------------------- - PINENTRY 0|1 When 0, disable use of pinentry. The default is 1. - PATH Full path to the pinentry binary. The default is - specified at compile time (/usr/bin/pinentry). - TTYNAME Same as the --ttyname option to pinentry(1). - TTYTYPE Same as the --ttytype option to pinentry(1). - DISPLAY Same as the --display option to pinentry(1). - TITLE Sets the title string of the dialog. - PROMPT Sets the prompt string of the dialog. - DESC Sets the error or description string of the dialog. + PINENTRY 0|1 When 0, disable use of pinentry. The default is 1. + PATH Full path to the pinentry binary. The default is + specified at compile time (/usr/bin/pinentry). + TTYNAME Same as the --ttyname option to pinentry(1). + TTYTYPE Same as the --ttytype option to pinentry(1). + DISPLAY Same as the --display option to pinentry(1). + TITLE Sets the title string of the dialog. + PROMPT Sets the prompt string of the dialog. + DESC Sets the error or description string of the dialog. + ITERATIONS The number of encrypting iterations for the opened + file. When pinentry is used with the SAVE command the key will be asked for confirmation. If the confirmation fails, the process is started over again diff --git a/src/commands.c b/src/commands.c index 13ee847a..db4e1798 100644 --- a/src/commands.c +++ b/src/commands.c @@ -2516,8 +2516,24 @@ static int option_handler(assuan_context_t ctx, const gchar *name, if (g_strcasecmp(name, (gchar *)"client") == 0) return parse_client_option(ctx, value); + if (g_strcasecmp(name, (gchar *)"iterations") == 0) { + long n; + gchar *p = NULL; + + if (!client->filename) + return assuan_set_error(ctx, EPWMD_NO_FILE, pwmd_strerror(EPWMD_NO_FILE)); + + errno = 0; + n = strtol(value, &p, 10); + + if (errno || (p && *p)) + return gpg_err_make(PWMD_ERR_SOURCE, GPG_ERR_INV_VALUE); + + g_key_file_set_integer(keyfileh, client->filename, "iterations", n); + send_status(ctx, STATUS_CONFIG); + } #ifdef WITH_PINENTRY - if (g_strcasecmp(name, (gchar *)"ttyname") == 0) { + else if (g_strcasecmp(name, (gchar *)"ttyname") == 0) { g_free(client->pinentry->ttyname); client->pinentry->ttyname = g_strdup(value); } @@ -2571,10 +2587,9 @@ static int option_handler(assuan_context_t ctx, const gchar *name, client->pinentry->enable = n == 0 ? FALSE : TRUE; } +#else else return gpg_err_make(PWMD_ERR_SOURCE, GPG_ERR_UNKNOWN_OPTION); -#else - return gpg_err_make(PWMD_ERR_SOURCE, GPG_ERR_NOT_IMPLEMENTED); #endif log_write("OPTION %s=%s", name, value); -- 2.11.4.GIT