Support gpgme_op_apsswd for GPG.
This commit is contained in:
parent
77d8ea8916
commit
1b2fb1b737
@ -3744,6 +3744,9 @@ private key associated with @var{key}. The only allowed value for
|
|||||||
to ask for the old and the new passphrase. Thus this function is not
|
to ask for the old and the new passphrase. Thus this function is not
|
||||||
useful in a server application (where passphrases are not required
|
useful in a server application (where passphrases are not required
|
||||||
anyway).
|
anyway).
|
||||||
|
|
||||||
|
Note that old @code{gpg} engines (before version 2.0.15) do not support
|
||||||
|
this comamnd and will silently ignore it.
|
||||||
@end deftypefun
|
@end deftypefun
|
||||||
|
|
||||||
@deftypefun gpgme_error_t gpgme_op_passwd_start @
|
@deftypefun gpgme_error_t gpgme_op_passwd_start @
|
||||||
|
@ -1,3 +1,10 @@
|
|||||||
|
2010-01-08 Werner Koch <wk@g10code.com>
|
||||||
|
|
||||||
|
* engine-gpg.c (gpg_passwd): New.
|
||||||
|
(_gpgme_engine_ops_gpg): Register.
|
||||||
|
* passwd.c (parse_error): New.
|
||||||
|
(passwd_status_handler): Use it.
|
||||||
|
|
||||||
2010-01-07 Marcus Brinkmann <marcus@g10code.de>
|
2010-01-07 Marcus Brinkmann <marcus@g10code.de>
|
||||||
|
|
||||||
* gpgme-tool.c (result_xml_write_cb_t, struct result_xml_state):
|
* gpgme-tool.c (result_xml_write_cb_t, struct result_xml_state):
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/* context.h - Definitions for a GPGME context.
|
/* context.h - Definitions for a GPGME context.
|
||||||
Copyright (C) 2000 Werner Koch (dd9jn)
|
Copyright (C) 2000 Werner Koch (dd9jn)
|
||||||
Copyright (C) 2001, 2002, 2003, 2004, 2005 g10 Code GmbH
|
Copyright (C) 2001, 2002, 2003, 2004, 2005, 2010 g10 Code GmbH
|
||||||
|
|
||||||
This file is part of GPGME.
|
This file is part of GPGME.
|
||||||
|
|
||||||
@ -15,9 +15,8 @@
|
|||||||
Lesser General Public License for more details.
|
Lesser General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public
|
You should have received a copy of the GNU Lesser General Public
|
||||||
License along with this program; if not, write to the Free Software
|
License along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
*/
|
||||||
02111-1307, USA. */
|
|
||||||
|
|
||||||
#ifndef CONTEXT_H
|
#ifndef CONTEXT_H
|
||||||
#define CONTEXT_H
|
#define CONTEXT_H
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/* engine-gpg.c - Gpg Engine.
|
/* engine-gpg.c - Gpg Engine.
|
||||||
Copyright (C) 2000 Werner Koch (dd9jn)
|
Copyright (C) 2000 Werner Koch (dd9jn)
|
||||||
Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007,
|
Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007,
|
||||||
2009 g10 Code GmbH
|
2009, 2010 g10 Code GmbH
|
||||||
|
|
||||||
This file is part of GPGME.
|
This file is part of GPGME.
|
||||||
|
|
||||||
@ -1436,6 +1436,24 @@ gpg_delete (void *engine, gpgme_key_t key, int allow_secret)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static gpgme_error_t
|
||||||
|
gpg_passwd (void *engine, gpgme_key_t key, unsigned int flags)
|
||||||
|
{
|
||||||
|
engine_gpg_t gpg = engine;
|
||||||
|
gpgme_error_t err;
|
||||||
|
|
||||||
|
if (!key || !key->subkeys || !key->subkeys->fpr)
|
||||||
|
return gpg_error (GPG_ERR_INV_CERT_OBJ);
|
||||||
|
|
||||||
|
err = add_arg (gpg, "--passwd");
|
||||||
|
if (!err)
|
||||||
|
err = add_arg (gpg, key->subkeys->fpr);
|
||||||
|
if (!err)
|
||||||
|
start (gpg);
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static gpgme_error_t
|
static gpgme_error_t
|
||||||
append_args_from_signers (engine_gpg_t gpg, gpgme_ctx_t ctx /* FIXME */)
|
append_args_from_signers (engine_gpg_t gpg, gpgme_ctx_t ctx /* FIXME */)
|
||||||
{
|
{
|
||||||
@ -2370,5 +2388,6 @@ struct engine_ops _gpgme_engine_ops_gpg =
|
|||||||
gpg_set_io_cbs,
|
gpg_set_io_cbs,
|
||||||
gpg_io_event,
|
gpg_io_event,
|
||||||
gpg_cancel,
|
gpg_cancel,
|
||||||
NULL /* cancel_op */
|
NULL, /* cancel_op */
|
||||||
|
gpg_passwd
|
||||||
};
|
};
|
||||||
|
@ -1908,7 +1908,7 @@ gpgsm_passwd (void *engine, gpgme_key_t key, unsigned int flags)
|
|||||||
char *line;
|
char *line;
|
||||||
|
|
||||||
if (!key || !key->subkeys || !key->subkeys->fpr)
|
if (!key || !key->subkeys || !key->subkeys->fpr)
|
||||||
return gpg_error (GPG_ERR_INV_VALUE);
|
return gpg_error (GPG_ERR_INV_CERT_OBJ);
|
||||||
|
|
||||||
if (asprintf (&line, "PASSWD -- %s", key->subkeys->fpr) < 0)
|
if (asprintf (&line, "PASSWD -- %s", key->subkeys->fpr) < 0)
|
||||||
return gpg_error_from_syserror ();
|
return gpg_error_from_syserror ();
|
||||||
|
@ -1729,7 +1729,7 @@ gt_passwd (gpgme_tool_t gt, char *fpr)
|
|||||||
|
|
||||||
err = gpgme_get_key (gt->ctx, fpr, &key, 0);
|
err = gpgme_get_key (gt->ctx, fpr, &key, 0);
|
||||||
if (err)
|
if (err)
|
||||||
return err;
|
return gpg_err_code (err) == GPG_ERR_EOF? gpg_error (GPG_ERR_NO_PUBKEY):err;
|
||||||
|
|
||||||
err = gpgme_op_passwd (gt->ctx, key, 0);
|
err = gpgme_op_passwd (gt->ctx, key, 0);
|
||||||
gpgme_key_unref (key);
|
gpgme_key_unref (key);
|
||||||
|
52
src/passwd.c
52
src/passwd.c
@ -20,6 +20,7 @@
|
|||||||
#if HAVE_CONFIG_H
|
#if HAVE_CONFIG_H
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
#endif
|
#endif
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include "gpgme.h"
|
#include "gpgme.h"
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
@ -27,13 +28,56 @@
|
|||||||
#include "ops.h"
|
#include "ops.h"
|
||||||
|
|
||||||
|
|
||||||
|
/* Parse an error status line and return the error code. */
|
||||||
|
static gpgme_error_t
|
||||||
|
parse_error (char *args)
|
||||||
|
{
|
||||||
|
gpgme_error_t err;
|
||||||
|
char *where = strchr (args, ' ');
|
||||||
|
char *which;
|
||||||
|
|
||||||
|
if (where)
|
||||||
|
{
|
||||||
|
*where = '\0';
|
||||||
|
which = where + 1;
|
||||||
|
|
||||||
|
where = strchr (which, ' ');
|
||||||
|
if (where)
|
||||||
|
*where = '\0';
|
||||||
|
|
||||||
|
where = args;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return gpg_error (GPG_ERR_INV_ENGINE);
|
||||||
|
|
||||||
|
err = atoi (which);
|
||||||
|
|
||||||
|
if (!strcmp (where, "keyedit.passwd"))
|
||||||
|
return err;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static gpgme_error_t
|
static gpgme_error_t
|
||||||
passwd_status_handler (void *priv, gpgme_status_code_t code, char *args)
|
passwd_status_handler (void *priv, gpgme_status_code_t code, char *args)
|
||||||
{
|
{
|
||||||
(void)priv;
|
gpgme_ctx_t ctx = (gpgme_ctx_t) priv;
|
||||||
(void)code;
|
gpgme_error_t err = 0;
|
||||||
(void)args;
|
|
||||||
return 0;
|
(void)ctx;
|
||||||
|
|
||||||
|
switch (code)
|
||||||
|
{
|
||||||
|
case GPGME_STATUS_ERROR:
|
||||||
|
err = parse_error (args);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user