From 7b861945fdc71fd3c82c91f824172dadd2220fa0 Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Tue, 2 Oct 2018 11:18:00 +0200 Subject: [PATCH] core: add experimental GPGME_EXPORT_MODE_NOUID. * src/gpgme.h.in (GPGME_EXPORT_MODE_NOUID): New. * src/export.c (export_start): Adjust option check. * src/engine-gpg.c (export_common): Implement option. Signed-off-by: Werner Koch --- doc/gpgme.texi | 4 ++++ src/engine-gpg.c | 9 ++++++++- src/export.c | 1 + src/gpgme.h.in | 1 + 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/doc/gpgme.texi b/doc/gpgme.texi index 426ae7a0..d99e9bb7 100644 --- a/doc/gpgme.texi +++ b/doc/gpgme.texi @@ -4663,6 +4663,10 @@ If this flag is used with @code{GPGME_EXPORT_MODE_SECRET} for an X.509 key the export format will be changed to PKCS#12 which also includes the certificate. This flag may not be used with OpenPGP. +@item GPGME_EXPORT_MODE_NOUID +@since{1.12.0 - experimental} +Do not export user ids. Works only with certain gpg version. + @end table diff --git a/src/engine-gpg.c b/src/engine-gpg.c index be78957f..9a5927cc 100644 --- a/src/engine-gpg.c +++ b/src/engine-gpg.c @@ -2241,7 +2241,14 @@ export_common (engine_gpg_t gpg, gpgme_export_mode_t mode, return gpg_error (GPG_ERR_NOT_SUPPORTED); if ((mode & GPGME_EXPORT_MODE_MINIMAL)) - err = add_arg (gpg, "--export-options=export-minimal"); + { + if ((mode & GPGME_EXPORT_MODE_NOUID)) + err = add_arg (gpg, "--export-options=export-minimal,export-drop-uids"); + else + err = add_arg (gpg, "--export-options=export-minimal"); + } + else if ((mode & GPGME_EXPORT_MODE_NOUID)) + err = add_arg (gpg, "--export-options=export-drop-uids"); if (err) ; diff --git a/src/export.c b/src/export.c index cd94050d..f460e853 100644 --- a/src/export.c +++ b/src/export.c @@ -123,6 +123,7 @@ export_start (gpgme_ctx_t ctx, int synchronous, const char *pattern, |GPGME_EXPORT_MODE_MINIMAL |GPGME_EXPORT_MODE_SECRET |GPGME_EXPORT_MODE_RAW + |GPGME_EXPORT_MODE_NOUID |GPGME_EXPORT_MODE_PKCS12))) return gpg_error (GPG_ERR_INV_VALUE); /* Invalid flags in MODE. */ diff --git a/src/gpgme.h.in b/src/gpgme.h.in index 9c9ea5af..17315939 100644 --- a/src/gpgme.h.in +++ b/src/gpgme.h.in @@ -405,6 +405,7 @@ gpgme_pinentry_mode_t; #define GPGME_EXPORT_MODE_SECRET 16 #define GPGME_EXPORT_MODE_RAW 32 #define GPGME_EXPORT_MODE_PKCS12 64 +#define GPGME_EXPORT_MODE_NOUID 128 typedef unsigned int gpgme_export_mode_t;