From 34d9defc42bacfaf2bb1ce70b2c3f0fdf0a106c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ingo=20Kl=C3=B6cker?= Date: Tue, 22 Jun 2021 16:23:26 +0200 Subject: core: Allow specifying an expiration date for key signatures * src/context.h (struct gpgme_context): Add 'cert_expire'. * src/engine-gpg.c (append_args_from_cert_expire): New. (gpg_edit): Set option according to the new flag. * src/gpgme.c (gpgme_release): Free 'cert_expire'. (gpgme_set_ctx_flag, gpgme_get_ctx_flag): Add "cert-expire". * tests/gpg/Makefile.am (c_tests): Add new test. (gpg.conf): Write "allow-weak-key-signatures" to gpg.conf. * tests/gpg/t-edit-sign.c: New. -- The new context flag "cert-expire" allows setting the expiration date for key signatures created with gpgme_op_interact. GnuPG-bug-id: 5336, 5505 --- src/gpgme.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/gpgme.c') diff --git a/src/gpgme.c b/src/gpgme.c index 8bc11d51..255d1165 100644 --- a/src/gpgme.c +++ b/src/gpgme.c @@ -253,6 +253,7 @@ gpgme_release (gpgme_ctx_t ctx) free (ctx->request_origin); free (ctx->auto_key_locate); free (ctx->trust_model); + free (ctx->cert_expire); _gpgme_engine_info_release (ctx->engine_info); ctx->engine_info = NULL; DESTROY_LOCK (ctx->lock); @@ -578,6 +579,13 @@ gpgme_set_ctx_flag (gpgme_ctx_t ctx, const char *name, const char *value) { ctx->extended_edit = abool; } + else if (!strcmp (name, "cert-expire")) + { + free (ctx->cert_expire); + ctx->cert_expire = strdup (value); + if (!ctx->cert_expire) + err = gpg_error_from_syserror (); + } else err = gpg_error (GPG_ERR_UNKNOWN_NAME); @@ -647,6 +655,10 @@ gpgme_get_ctx_flag (gpgme_ctx_t ctx, const char *name) { return ctx->extended_edit ? "1":""; } + else if (!strcmp (name, "cert-expire")) + { + return ctx->cert_expire? ctx->cert_expire : ""; + } else return NULL; } -- cgit v1.2.3