summaryrefslogtreecommitdiffstats
path: root/sm
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>2009-12-14 13:33:23 +0100
committerWerner Koch <wk@gnupg.org>2009-12-14 13:33:23 +0100
commited7bf140341ff3fe7ae9d5168ac76a4cd0141da5 (patch)
tree9f697bd1702d99eaefd12959f01af04d807f57c2 /sm
parentAdd option --cert-extension. (diff)
downloadgnupg2-ed7bf140341ff3fe7ae9d5168ac76a4cd0141da5.tar.xz
gnupg2-ed7bf140341ff3fe7ae9d5168ac76a4cd0141da5.zip
add new gpgsm server command PASSWD
Diffstat (limited to 'sm')
-rw-r--r--sm/ChangeLog5
-rw-r--r--sm/server.c35
2 files changed, 39 insertions, 1 deletions
diff --git a/sm/ChangeLog b/sm/ChangeLog
index 5ddec9ca1..6b52cd811 100644
--- a/sm/ChangeLog
+++ b/sm/ChangeLog
@@ -1,3 +1,8 @@
+2009-12-14 Werner Koch <wk@g10code.com>
+
+ * server.c (cmd_passwd): New.
+ (register_commands): Register new command.
+
2009-12-10 Werner Koch <wk@g10code.com>
* gpgsm.c: Add option --ignore-cert-extension.
diff --git a/sm/server.c b/sm/server.c
index ad39e93f4..de245f5ad 100644
--- a/sm/server.c
+++ b/sm/server.c
@@ -1068,7 +1068,6 @@ cmd_getauditlog (assuan_context_t ctx, char *line)
return rc;
}
-
static const char hlp_getinfo[] =
"GETINFO <what>\n"
"\n"
@@ -1141,6 +1140,39 @@ cmd_getinfo (assuan_context_t ctx, char *line)
}
+static const char hlp_passwd[] =
+ "PASSWD <userID>\n"
+ "\n"
+ "Change the passphrase of the secret key for USERID.";
+static gpg_error_t
+cmd_passwd (assuan_context_t ctx, char *line)
+{
+ ctrl_t ctrl = assuan_get_pointer (ctx);
+ gpg_error_t err;
+ ksba_cert_t cert = NULL;
+ char *grip = NULL;
+
+ line = skip_options (line);
+
+ err = gpgsm_find_cert (line, NULL, &cert);
+ if (err)
+ ;
+ else if (!(grip = gpgsm_get_keygrip_hexstring (cert)))
+ err = gpg_error (GPG_ERR_INTERNAL);
+ else
+ {
+ char *desc = gpgsm_format_keydesc (cert);
+ err = gpgsm_agent_passwd (ctrl, grip, desc);
+ xfree (desc);
+ }
+
+ xfree (grip);
+ ksba_cert_release (cert);
+
+ return err;
+}
+
+
/* Return true if the command CMD implements the option OPT. */
static int
@@ -1184,6 +1216,7 @@ register_commands (assuan_context_t ctx)
{ "DELKEYS", cmd_delkeys, hlp_delkeys },
{ "GETAUDITLOG", cmd_getauditlog, hlp_getauditlog },
{ "GETINFO", cmd_getinfo, hlp_getinfo },
+ { "PASSWD", cmd_passwd, hlp_passwd },
{ NULL }
};
int i, rc;