1
0
Fork 0
mirror of git://git.gnupg.org/gnupg.git synced 2025-07-02 22:46:30 +02:00

gpg: New option --import-filter

* g10/gpg.c (oImportFilter): New.
(opts): Add --import-filter.
(main): Handle option.
* g10/import.c: Include recsel.h, init.h, and mbox-util.h.
(import_keep_uid): New global var.
(cleanup_import_globals): New.
(parse_and_set_import_filter): New.
(filter_getval): New.
(apply_keep_uid_filter): New.
(import_one): Apply filter if set.
--

Funny new option.  It can for example be used to export a key with
only one user id:

  gpg --no-options --import --import-options import-export \
      --import-filter keep-uid='mbox=wk@gnupg.org'         \
     < full-key.pub > key-with-one-uid.pub

More features will eventually be added.

Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
Werner Koch 2016-07-01 16:24:04 +02:00
parent f015552374
commit 5137bf73cc
No known key found for this signature in database
GPG key ID: E3FDFF218E45B72B
4 changed files with 182 additions and 1 deletions

View file

@ -2218,6 +2218,45 @@ opposite meaning. The options are:
Defaults to no.
@end table
@item --import-filter @code{@var{name}=@var{expr}}
@opindex import-filter
This option defines an import filter which is implied to the imported
keyblock right before it will be stored. @var{name} defines the type
of filter to use, @var{expr} the expression to evaluate. The option
can be used several times which then appends more expression to the
same @var{name}.
@noindent
The available filter types are:
@table @asis
@item keep-uid
This filter will keep a user id packet and its dependent packets in
the keyblock if the expression evaluates to true.
@end table
The syntax for the expression is defined in the appendix (FIXME). The
property names for the expressions depend on the actual filter type
and are indicated in the following table.
The available properties are:
@table @asis
@item uid
A string with the user id. (keep-uid)
@item mbox
The addr-spec part of a user id with mailbox or the empty string.
(keep-uid)
@item primary
Boolean indicating whether the user id is the primary one. (keep-uid)
@end table
@item --export-options @code{parameters}
@opindex export-options
This is a space or comma delimited string that gives options for