1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-12-22 10:19:57 +01:00

gpg: Set the found-by flags in the keyblock in keyboxd mode.

* g10/keydb-private.h (struct keydb_handle_s): Add fields to return
the ordinals of the last found blob.
* g10/call-keyboxd.c (keydb_get_keyblock): Pass them to the keyblock
parser.

Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
Werner Koch 2020-09-22 16:20:41 +02:00
parent b810320b1b
commit 1835097561
No known key found for this signature in database
GPG Key ID: E3FDFF218E45B72B
2 changed files with 34 additions and 8 deletions

View File

@ -313,7 +313,6 @@ gpg_error_t
keydb_get_keyblock (KEYDB_HANDLE hd, kbnode_t *ret_kb) keydb_get_keyblock (KEYDB_HANDLE hd, kbnode_t *ret_kb)
{ {
gpg_error_t err; gpg_error_t err;
int pk_no, uid_no;
*ret_kb = NULL; *ret_kb = NULL;
@ -331,8 +330,9 @@ keydb_get_keyblock (KEYDB_HANDLE hd, kbnode_t *ret_kb)
if (hd->kbl->search_result) if (hd->kbl->search_result)
{ {
pk_no = uid_no = 0; /*FIXME: Get this from the keyboxd. */ err = keydb_parse_keyblock (hd->kbl->search_result,
err = keydb_parse_keyblock (hd->kbl->search_result, pk_no, uid_no, hd->last_ubid_valid? hd->last_pk_no : 0,
hd->last_ubid_valid? hd->last_uid_no : 0,
ret_kb); ret_kb);
/* In contrast to the old code we close the iobuf here and thus /* In contrast to the old code we close the iobuf here and thus
* this function may be called only once to get a keyblock. */ * this function may be called only once to get a keyblock. */
@ -579,6 +579,7 @@ search_status_cb (void *opaque, const char *line)
KEYDB_HANDLE hd = opaque; KEYDB_HANDLE hd = opaque;
gpg_error_t err = 0; gpg_error_t err = 0;
const char *s; const char *s;
unsigned int n;
if ((s = has_leading_keyword (line, "PUBKEY_INFO"))) if ((s = has_leading_keyword (line, "PUBKEY_INFO")))
{ {
@ -589,10 +590,29 @@ search_status_cb (void *opaque, const char *line)
hd->last_ubid_valid = 0; hd->last_ubid_valid = 0;
while (*s && !spacep (s)) while (*s && !spacep (s))
s++; s++;
if (hex2fixedbuf (s, hd->last_ubid, sizeof hd->last_ubid)) if (!(n=hex2fixedbuf (s, hd->last_ubid, sizeof hd->last_ubid)))
hd->last_ubid_valid = 1;
else
err = gpg_error (GPG_ERR_INV_VALUE); err = gpg_error (GPG_ERR_INV_VALUE);
else
{
hd->last_ubid_valid = 1;
hd->last_uid_no = 0;
hd->last_pk_no = 0;
s += n;
while (*s && !spacep (s))
s++;
while (spacep (s))
s++;
if (*s)
{
hd->last_uid_no = atoi (s);
while (*s && !spacep (s))
s++;
while (spacep (s))
s++;
if (*s)
hd->last_pk_no = atoi (s);
}
}
} }
} }
@ -779,8 +799,9 @@ keydb_search (KEYDB_HANDLE hd, KEYDB_SEARCH_DESC *desc,
{ {
hd->kbl->search_result = iobuf_temp_with_content (buffer, len); hd->kbl->search_result = iobuf_temp_with_content (buffer, len);
xfree (buffer); xfree (buffer);
/* if (hd->last_ubid_valid) */ if (DBG_LOOKUP && hd->last_ubid_valid)
/* log_printhex (hd->last_ubid, 20, "found UBID:"); */ log_printhex (hd->last_ubid, 20, "found UBID (%d,%d):",
hd->last_uid_no, hd->last_pk_no);
} }
leave: leave:

View File

@ -102,6 +102,11 @@ struct keydb_handle_s
/* The UBID of the last returned keyblock. */ /* The UBID of the last returned keyblock. */
unsigned char last_ubid[UBID_LEN]; unsigned char last_ubid[UBID_LEN];
/* The ordinals from the last search operations; valid if
* last_ubid_valid is set. */
int last_uid_no;
int last_pk_no;
/* END USE_KEYBOXD */ /* END USE_KEYBOXD */
/* BEGIN !USE_KEYBOXD */ /* BEGIN !USE_KEYBOXD */