sm: Implement delete key in keyboxd mode

* sm/keydb.c (keydb_delete): Implement keyboxd mode.
(keydb_update_cert): Disable unused function.
* kbx/backend-sqlite.c (be_sqlite_delete): Delete from issuer.
--

Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
Werner Koch 2020-09-13 20:48:53 +02:00
parent 8a84a71f3a
commit c772770574
No known key found for this signature in database
GPG Key ID: E3FDFF218E45B72B
3 changed files with 32 additions and 5 deletions

View File

@ -1520,6 +1520,9 @@ be_sqlite_delete (ctrl_t ctrl, backend_handle_t backend_hd,
if (!err)
err = run_sql_statement_bind_ubid
("DELETE from fingerprint WHERE ubid = :1", ubid);
if (!err)
err = run_sql_statement_bind_ubid
("DELETE from issuer WHERE ubid = :1", ubid);
if (!err)
err = run_sql_statement_bind_ubid
("DELETE from pubkey WHERE ubid = :1", ubid);

View File

@ -112,7 +112,7 @@ delete_one (ctrl_t ctrl, const char *username)
goto leave;
}
/* We need to search again to get back to the right position. Neo
/* We need to search again to get back to the right position. Note
* that the lock is kept until the KH is released. */
rc = keydb_lock (kh);
if (rc)

View File

@ -1,6 +1,6 @@
/* keydb.c - key database dispatcher
* Copyright (C) 2001, 2003, 2004 Free Software Foundation, Inc.
* Copyright (C) 2014 g10 Code GmbH
* Copyright (C) 2014, 2020 g10 Code GmbH
*
* This file is part of GnuPG.
*
@ -109,6 +109,7 @@ struct keydb_handle {
/* Various flags. */
unsigned int last_ubid_valid:1;
unsigned int last_is_ephemeral; /* Last found key is ephemeral. */
/* The UBID of the last returned keyblock. */
unsigned char last_ubid[UBID_LEN];
@ -1217,6 +1218,10 @@ keydb_insert_cert (KEYDB_HANDLE hd, ksba_cert_t cert)
gpg_error_t
keydb_update_cert (KEYDB_HANDLE hd, ksba_cert_t cert)
{
(void)hd;
(void)cert;
return GPG_ERR_BUG;
#if 0
gpg_error_t err;
unsigned char digest[20];
@ -1260,6 +1265,7 @@ keydb_update_cert (KEYDB_HANDLE hd, ksba_cert_t cert)
if (DBG_CLOCK)
log_clock ("%s: leave (err=%s)\n", __func__, gpg_strerror (err));
return err;
#endif /*0*/
}
@ -1274,7 +1280,7 @@ keydb_delete (KEYDB_HANDLE hd)
if (!hd)
return gpg_error (GPG_ERR_INV_VALUE);
if ( hd->found < 0 || hd->found >= hd->used)
if (!hd->use_keyboxd && (hd->found < 0 || hd->found >= hd->used))
return gpg_error (GPG_ERR_NOT_FOUND);
if (opt.dry_run)
@ -1285,7 +1291,21 @@ keydb_delete (KEYDB_HANDLE hd)
if (hd->use_keyboxd)
{
/* FIXME */
unsigned char hexubid[UBID_LEN * 2 + 1];
char line[ASSUAN_LINELENGTH];
if (!hd->last_ubid_valid)
{
err = gpg_error (GPG_ERR_VALUE_NOT_FOUND);
goto leave;
}
bin2hex (hd->last_ubid, UBID_LEN, hexubid);
snprintf (line, sizeof line, "DELETE %s", hexubid);
err = assuan_transact (hd->kbl->ctx, line,
NULL, NULL,
NULL, NULL,
NULL, NULL);
goto leave;
}
@ -1506,6 +1526,9 @@ search_status_cb (void *opaque, const char *line)
hd->last_ubid_valid = 1;
else
err = gpg_error (GPG_ERR_INV_VALUE);
while (spacep (s))
s++;
hd->last_is_ephemeral = (*s == 'e');
}
}
@ -1717,7 +1740,8 @@ keydb_search (ctrl_t ctrl, KEYDB_HANDLE hd,
&hd->kbl->search_result.len)))
{
/* if (hd->last_ubid_valid) */
/* log_printhex (hd->last_ubid, 20, "found UBID:"); */
/* log_printhex (hd->last_ubid, 20, "found UBID%s:", */
/* hd->last_is_ephemeral? "(ephemeral)":""); */
}
}