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

gpg: expand GPG groups when resolving a key

* g10/expand-group.c: New
* g10/pkclist.c: Extract expand_group and expand_id into expand-group.c.
* g10/keydb.h: Add prototypes of expand_id and expand_group.
* g10/getkey.c: Use expand_group before resolving key references.
* g10/Makefile.am: Compile expand-group.c.
--

When searching a key by its name, try to expand the provided name in
case it is a GPG group reference. This GPG group resolution is performed
before the individual keys are verified.

This allows key listing using a GPG group reference. In particular, this
modification fixes the encryption to group support in KDE's Kmail which
is broken since version 18.04.

Signed-off-by: Stephan Mueller <stephan.mueller@atsec.com>

- Changed new filename to use a dash instead of an underscore.
- Indendation changes.

Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
Stephan Mueller 2019-02-19 08:14:41 +01:00 committed by Werner Koch
parent d9c4c3776b
commit e825aea2ba
No known key found for this signature in database
GPG key ID: E3FDFF218E45B72B
5 changed files with 99 additions and 52 deletions

View file

@ -729,7 +729,7 @@ key_byname (ctrl_t ctrl, GETKEY_CTX *retctx, strlist_t namelist,
{
int rc = 0;
int n;
strlist_t r;
strlist_t r, namelist_expanded = NULL, link = NULL;
GETKEY_CTX ctx;
KBNODE help_kb = NULL;
KBNODE found_key = NULL;
@ -758,6 +758,19 @@ key_byname (ctrl_t ctrl, GETKEY_CTX *retctx, strlist_t namelist,
}
else
{
namelist_expanded = expand_group (namelist);
/* Chain namelist and namelist_expanded */
for (r = namelist; r; r = r->next)
{
if (!r->next)
{
r->next = namelist_expanded;
link = r;
break;
}
}
/* Build the search context. */
for (n = 0, r = namelist; r; r = r->next)
n++;
@ -779,7 +792,8 @@ key_byname (ctrl_t ctrl, GETKEY_CTX *retctx, strlist_t namelist,
if (err)
{
xfree (ctx);
return gpg_err_code (err); /* FIXME: remove gpg_err_code. */
rc = gpg_err_code (err); /* FIXME: remove gpg_err_code. */
goto leave;
}
if (!include_unusable
&& ctx->items[n].mode != KEYDB_SEARCH_MODE_SHORT_KID
@ -798,7 +812,7 @@ key_byname (ctrl_t ctrl, GETKEY_CTX *retctx, strlist_t namelist,
{
rc = gpg_error_from_syserror ();
getkey_end (ctrl, ctx);
return rc;
goto leave;
}
if (!ret_kb)
@ -829,6 +843,12 @@ key_byname (ctrl_t ctrl, GETKEY_CTX *retctx, strlist_t namelist,
getkey_end (ctrl, ctx);
}
leave:
if (namelist_expanded)
free_strlist(namelist_expanded);
/* Un-chain namelist and namelist_expanded */
if (link)
link->next = NULL;
return rc;
}