aboutsummaryrefslogtreecommitdiffstats
path: root/g10/export.c
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2020-03-13 12:17:51 +0000
committerWerner Koch <[email protected]>2020-03-13 12:19:31 +0000
commit32493ce50ad880de7b548d7870c6040a8233a8f5 (patch)
tree61ae869cc0e4c550c257bf2001723aaf735df605 /g10/export.c
parentdoc: Add a comment to explain the signature postscript. (diff)
downloadgnupg-32493ce50ad880de7b548d7870c6040a8233a8f5.tar.gz
gnupg-32493ce50ad880de7b548d7870c6040a8233a8f5.zip
gpg: Add property "fpr" for use by --export-filter.
* g10/export.c (push_export_filters): New. (pop_export_filters): New. (export_pubkey_buffer): Add args prefix and prefixlen. Adjust callers. * g10/import.c (impex_filter_getval): Add property "fpr". * g10/main.h (struct impex_filter_parm_s): Add field hexfpr. -- The push and pop feature will help us to use the export filter internally in gpg. Same for the export_pubkey_buffer change. GnuPG-bug-id: 4856 Signed-off-by: Werner Koch <[email protected]>
Diffstat (limited to 'g10/export.c')
-rw-r--r--g10/export.c52
1 files changed, 51 insertions, 1 deletions
diff --git a/g10/export.c b/g10/export.c
index 052e16717..a76a7da84 100644
--- a/g10/export.c
+++ b/g10/export.c
@@ -73,6 +73,17 @@ static recsel_expr_t export_keep_uid;
static recsel_expr_t export_drop_subkey;
+/* An object used for a linked list to implement the
+ * push_export_filter/pop_export_filters functions. */
+struct export_filter_attic_s
+{
+ struct export_filter_attic_s *next;
+ recsel_expr_t export_keep_uid;
+ recsel_expr_t export_drop_subkey;
+};
+static struct export_filter_attic_s *export_filter_attic;
+
+
/* Local prototypes. */
static int do_export (ctrl_t ctrl, strlist_t users, int secret,
@@ -198,6 +209,41 @@ parse_and_set_export_filter (const char *string)
}
+/* Push the current export filters onto a stack so that new export
+ * filters can be defined which will be active until the next
+ * pop_export_filters or another push_export_filters. */
+void
+push_export_filters (void)
+{
+ struct export_filter_attic_s *item;
+
+ item = xcalloc (1, sizeof *item);
+ item->export_keep_uid = export_keep_uid;
+ export_keep_uid = NULL;
+ item->export_drop_subkey = export_drop_subkey;
+ export_drop_subkey = NULL;
+ item->next = export_filter_attic;
+ export_filter_attic = item;
+}
+
+
+/* Revert the last push_export_filters. */
+void
+pop_export_filters (void)
+{
+ struct export_filter_attic_s *item;
+
+ item = export_filter_attic;
+ if (!item)
+ BUG (); /* No corresponding push. */
+ export_filter_attic = item->next;
+ cleanup_export_globals ();
+ export_keep_uid = item->export_keep_uid;
+ export_drop_subkey = item->export_drop_subkey;
+}
+
+
+
/* Create a new export stats object initialized to zero. On error
returns NULL and sets ERRNO. */
export_stats_t
@@ -292,10 +338,12 @@ export_secsubkeys (ctrl_t ctrl, strlist_t users, unsigned int options,
/*
* Export a single key into a memory buffer. STATS is either an
- * export stats object for update or NULL.
+ * export stats object for update or NULL. If PREFIX is not NULL
+ * PREFIXLEN bytes from PREFIX are prepended to the R_DATA.
*/
gpg_error_t
export_pubkey_buffer (ctrl_t ctrl, const char *keyspec, unsigned int options,
+ const void *prefix, size_t prefixlen,
export_stats_t stats,
kbnode_t *r_keyblock, void **r_data, size_t *r_datalen)
{
@@ -313,6 +361,8 @@ export_pubkey_buffer (ctrl_t ctrl, const char *keyspec, unsigned int options,
return gpg_error_from_syserror ();
iobuf = iobuf_temp ();
+ if (prefix && prefixlen)
+ iobuf_write (iobuf, prefix, prefixlen);
err = do_export_stream (ctrl, iobuf, helplist, 0, r_keyblock, options,
stats, &any);
if (!err && !any)