From ed7bf140341ff3fe7ae9d5168ac76a4cd0141da5 Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Mon, 14 Dec 2009 12:33:23 +0000 Subject: add new gpgsm server command PASSWD --- sm/ChangeLog | 5 +++++ sm/server.c | 35 ++++++++++++++++++++++++++++++++++- 2 files changed, 39 insertions(+), 1 deletion(-) (limited to 'sm') 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 + + * server.c (cmd_passwd): New. + (register_commands): Register new command. + 2009-12-10 Werner Koch * 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 \n" "\n" @@ -1141,6 +1140,39 @@ cmd_getinfo (assuan_context_t ctx, char *line) } +static const char hlp_passwd[] = + "PASSWD \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; -- cgit v1.2.3