mirror of
git://git.gnupg.org/gnupg.git
synced 2025-05-14 08:13:25 +02:00
gpg: Read the UBID from the keybox and detect wrong blob type.
* g10/keydb-private.h (struct keydb_handle_s): Add fields for UBID. * g10/call-keyboxd.c (search_status_cb): New. (keydb_search): Set new UBID fields. -- The UBID is not yet used but may come handy later. Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
parent
c7293a4d12
commit
63dbc817e7
@ -779,6 +779,7 @@ keydb_update_keyblock (ctrl_t ctrl, KEYDB_HANDLE hd, kbnode_t kb)
|
|||||||
* came is used. If there was no previous search result (or
|
* came is used. If there was no previous search result (or
|
||||||
* keydb_search_reset was called), then the keyring / keybox where the
|
* keydb_search_reset was called), then the keyring / keybox where the
|
||||||
* next search would start is used (i.e., the current file position).
|
* next search would start is used (i.e., the current file position).
|
||||||
|
* In keyboxd mode the keyboxd decides where to store it.
|
||||||
*
|
*
|
||||||
* Note: this doesn't do anything if --dry-run was specified.
|
* Note: this doesn't do anything if --dry-run was specified.
|
||||||
*
|
*
|
||||||
@ -853,7 +854,7 @@ keydb_search_reset (KEYDB_HANDLE hd)
|
|||||||
goto leave;
|
goto leave;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* All we need todo is to tell search that a reset is pending. Noet
|
/* All we need todo is to tell search that a reset is pending. Note
|
||||||
* that keydb_new sets this flag as well. */
|
* that keydb_new sets this flag as well. */
|
||||||
hd->kbl->need_search_reset = 1;
|
hd->kbl->need_search_reset = 1;
|
||||||
err = 0;
|
err = 0;
|
||||||
@ -863,6 +864,35 @@ keydb_search_reset (KEYDB_HANDLE hd)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Status callback for SEARCH and NEXT operaions. */
|
||||||
|
static gpg_error_t
|
||||||
|
search_status_cb (void *opaque, const char *line)
|
||||||
|
{
|
||||||
|
KEYDB_HANDLE hd = opaque;
|
||||||
|
gpg_error_t err = 0;
|
||||||
|
const char *s;
|
||||||
|
|
||||||
|
if ((s = has_leading_keyword (line, "PUBKEY_INFO")))
|
||||||
|
{
|
||||||
|
if (atoi (s) != PUBKEY_TYPE_OPGP)
|
||||||
|
err = gpg_error (GPG_ERR_WRONG_BLOB_TYPE);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
hd->last_ubid_valid = 0;
|
||||||
|
while (*s && !spacep (s))
|
||||||
|
s++;
|
||||||
|
if (hex2fixedbuf (s, hd->last_ubid, sizeof hd->last_ubid))
|
||||||
|
hd->last_ubid_valid = 1;
|
||||||
|
else
|
||||||
|
err = gpg_error (GPG_ERR_INV_VALUE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Search the database for keys matching the search description. If
|
/* Search the database for keys matching the search description. If
|
||||||
* the DB contains any legacy keys, these are silently ignored.
|
* the DB contains any legacy keys, these are silently ignored.
|
||||||
*
|
*
|
||||||
@ -1040,19 +1070,20 @@ keydb_search (KEYDB_HANDLE hd, KEYDB_SEARCH_DESC *desc,
|
|||||||
}
|
}
|
||||||
|
|
||||||
do_search:
|
do_search:
|
||||||
|
hd->last_ubid_valid = 0;
|
||||||
if (hd->kbl->datastream.fp)
|
if (hd->kbl->datastream.fp)
|
||||||
{
|
{
|
||||||
/* log_debug ("Sending command '%s'\n", line); */
|
/* log_debug ("Sending command '%s'\n", line); */
|
||||||
err = assuan_transact (hd->kbl->ctx, line,
|
err = assuan_transact (hd->kbl->ctx, line,
|
||||||
NULL, NULL,
|
NULL, NULL,
|
||||||
NULL, NULL,
|
NULL, NULL,
|
||||||
NULL, NULL);
|
search_status_cb, hd);
|
||||||
if (err)
|
if (err)
|
||||||
{
|
{
|
||||||
/* log_debug ("Finished command with error: %s\n", gpg_strerror (err)); */
|
/* log_debug ("Finished command with error: %s\n", gpg_strerror (err)); */
|
||||||
/* Fixme: On unexpected errors we need a way to cancek the
|
/* Fixme: On unexpected errors we need a way to cancel the
|
||||||
* data stream. Probly it will be best to closeand reopen
|
* data stream. Probably it will be best to close and
|
||||||
* it. */
|
* reopen it. */
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -1086,7 +1117,7 @@ keydb_search (KEYDB_HANDLE hd, KEYDB_SEARCH_DESC *desc,
|
|||||||
err = assuan_transact (hd->kbl->ctx, line,
|
err = assuan_transact (hd->kbl->ctx, line,
|
||||||
put_membuf_cb, &data,
|
put_membuf_cb, &data,
|
||||||
NULL, NULL,
|
NULL, NULL,
|
||||||
NULL, NULL);
|
search_status_cb, hd);
|
||||||
if (err)
|
if (err)
|
||||||
{
|
{
|
||||||
xfree (get_membuf (&data, &len));
|
xfree (get_membuf (&data, &len));
|
||||||
@ -1104,6 +1135,8 @@ keydb_search (KEYDB_HANDLE hd, KEYDB_SEARCH_DESC *desc,
|
|||||||
xfree (buffer);
|
xfree (buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* if (hd->last_ubid_valid) */
|
||||||
|
/* log_printhex (hd->last_ubid, 20, "found UBID:"); */
|
||||||
|
|
||||||
leave:
|
leave:
|
||||||
if (DBG_CLOCK)
|
if (DBG_CLOCK)
|
||||||
|
@ -92,10 +92,16 @@ struct keydb_handle_s
|
|||||||
/* A shallow pointer with the CTRL used to create this handle. */
|
/* A shallow pointer with the CTRL used to create this handle. */
|
||||||
ctrl_t ctrl;
|
ctrl_t ctrl;
|
||||||
|
|
||||||
/* Connection info which also keep the local state. (This is points
|
/* Connection info which also keeps the local state. (This points
|
||||||
* into the CTRL->keybox_local list.) */
|
* into the CTRL->keybox_local list.) */
|
||||||
keyboxd_local_t kbl;
|
keyboxd_local_t kbl;
|
||||||
|
|
||||||
|
/* Various flags. */
|
||||||
|
unsigned int last_ubid_valid:1;
|
||||||
|
|
||||||
|
/* The UBID of the last returned keyblock. */
|
||||||
|
unsigned char last_ubid[20];
|
||||||
|
|
||||||
/* END USE_KEYBOXD */
|
/* END USE_KEYBOXD */
|
||||||
|
|
||||||
/* BEGIN !USE_KEYBOXD */
|
/* BEGIN !USE_KEYBOXD */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user