core: Add cert-notation support and extended-edit
* src/context.h (gpgme_context): Add new flag for extended-edit. * src/engine-gpg.c (append_args_from_sig_notations): Add flags to control the kind of notations. (gpg_edit): Respect extended-edit and notations. (gpg_encrypt_sign, gpg_sign): Update call to append_args_from_sig_notations. * src/gpgme.c (gpgme_set_ctx_flag, gpgme_get_ctx_flag): Support extended-edit. * NEWS, doc/gpgme.texi: Mention extended-edit. -- This provides a way to get the extended key-edit interface without breaking bad state machines that rely on the current command flow. A use case for this is to enable multiple local signatures, which can be used together with annotations for: GnuPG-Bug-Id: T4734
This commit is contained in:
parent
9d83698818
commit
0224408c63
1
NEWS
1
NEWS
@ -1,6 +1,7 @@
|
||||
Noteworthy changes in version 1.14.0 (unreleased)
|
||||
-------------------------------------------------
|
||||
|
||||
* New context flag "extended-edit" to enable expert key edit. [#4734]
|
||||
|
||||
* Interface changes relative to the 1.13.1 release:
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
@ -3150,6 +3150,10 @@ trust-model changes the default trust-model for future operations.
|
||||
A change in the trust-model also can have unintended side effects, like
|
||||
rebuilding the trust-db.
|
||||
|
||||
@item "extended-edit"
|
||||
This flag passes the option @option{--expert} to gpg key edit. This
|
||||
can be used to get additional callbacks in @code{gpgme_op_edit}.
|
||||
|
||||
@end table
|
||||
|
||||
This function returns @code{0} on success.
|
||||
|
@ -128,6 +128,9 @@ struct gpgme_context
|
||||
* after the operation. */
|
||||
unsigned int ignore_mdc_error : 1;
|
||||
|
||||
/* Pass --expert to gpg edit key. */
|
||||
unsigned int extended_edit : 1;
|
||||
|
||||
/* Flags for keylist mode. */
|
||||
gpgme_keylist_mode_t keylist_mode;
|
||||
|
||||
|
@ -1848,8 +1848,13 @@ append_args_from_sender (engine_gpg_t gpg, gpgme_ctx_t ctx)
|
||||
}
|
||||
|
||||
|
||||
#define NOTATION_FLAG_SIG 1 /* Use --sig-notation (default)*/
|
||||
#define NOTATION_FLAG_CERT 2 /* Use --cert-notation */
|
||||
#define NOTATION_FLAG_SET 3 /* Use --set-notation */
|
||||
|
||||
static gpgme_error_t
|
||||
append_args_from_sig_notations (engine_gpg_t gpg, gpgme_ctx_t ctx /* FIXME */)
|
||||
append_args_from_sig_notations (engine_gpg_t gpg, gpgme_ctx_t ctx /* FIXME */,
|
||||
int flags)
|
||||
{
|
||||
gpgme_error_t err = 0;
|
||||
gpgme_sig_notation_t notation;
|
||||
@ -1890,7 +1895,14 @@ append_args_from_sig_notations (engine_gpg_t gpg, gpgme_ctx_t ctx /* FIXME */)
|
||||
}
|
||||
|
||||
if (!err)
|
||||
err = add_arg (gpg, "--sig-notation");
|
||||
{
|
||||
if ((flags & NOTATION_FLAG_SET))
|
||||
err = add_arg (gpg, "--set-notation");
|
||||
else if ((flags & NOTATION_FLAG_CERT))
|
||||
err = add_arg (gpg, "--cert-notation");
|
||||
else
|
||||
err = add_arg (gpg, "--sig-notation");
|
||||
}
|
||||
if (!err)
|
||||
err = add_arg (gpg, arg);
|
||||
|
||||
@ -1941,10 +1953,15 @@ gpg_edit (void *engine, int type, gpgme_key_t key, gpgme_data_t out,
|
||||
gpgme_error_t err;
|
||||
|
||||
err = add_arg (gpg, "--with-colons");
|
||||
|
||||
if (!err && ctx->extended_edit)
|
||||
err = add_arg (gpg, "--expert");
|
||||
if (!err)
|
||||
err = append_args_from_signers (gpg, ctx);
|
||||
if (!err)
|
||||
err = add_arg (gpg, type == 0 ? "--edit-key" : "--card-edit");
|
||||
err = append_args_from_sig_notations (gpg, ctx, NOTATION_FLAG_CERT);
|
||||
if (!err)
|
||||
err = add_arg (gpg, type == 0 ? "--edit-key" : "--card-edit");
|
||||
if (!err)
|
||||
err = add_data (gpg, out, 1, 1);
|
||||
if (!err)
|
||||
@ -2254,7 +2271,7 @@ gpg_encrypt_sign (void *engine, gpgme_key_t recp[],
|
||||
err = append_args_from_sender (gpg, ctx);
|
||||
|
||||
if (!err)
|
||||
err = append_args_from_sig_notations (gpg, ctx);
|
||||
err = append_args_from_sig_notations (gpg, ctx, NOTATION_FLAG_SIG);
|
||||
|
||||
/* Tell the gpg object about the data. */
|
||||
if (!err)
|
||||
@ -3228,7 +3245,7 @@ gpg_sign (void *engine, gpgme_data_t in, gpgme_data_t out,
|
||||
if (!err)
|
||||
err = append_args_from_sender (gpg, ctx);
|
||||
if (!err)
|
||||
err = append_args_from_sig_notations (gpg, ctx);
|
||||
err = append_args_from_sig_notations (gpg, ctx, NOTATION_FLAG_SIG);
|
||||
|
||||
if (gpgme_data_get_file_name (in))
|
||||
{
|
||||
|
@ -566,6 +566,10 @@ gpgme_set_ctx_flag (gpgme_ctx_t ctx, const char *name, const char *value)
|
||||
if (!ctx->trust_model)
|
||||
err = gpg_error_from_syserror ();
|
||||
}
|
||||
else if (!strcmp (name, "extended-edit"))
|
||||
{
|
||||
ctx->extended_edit = abool;
|
||||
}
|
||||
else
|
||||
err = gpg_error (GPG_ERR_UNKNOWN_NAME);
|
||||
|
||||
@ -623,6 +627,10 @@ gpgme_get_ctx_flag (gpgme_ctx_t ctx, const char *name)
|
||||
{
|
||||
return ctx->auto_key_locate? ctx->auto_key_locate : "";
|
||||
}
|
||||
else if (!strcmp (name, "extended-edit"))
|
||||
{
|
||||
return ctx->extended_edit ? "1":"";
|
||||
}
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user