aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2020-09-13 18:48:53 +0000
committerWerner Koch <[email protected]>2020-09-21 07:20:40 +0000
commitc772770574ea2d337f8745ff304b1b8acd8a2e4c (patch)
tree6ecbd302ef009cf7c2c17daf37f39948fc6d6947
parentagent: Fix regression for access through the extra secket. (diff)
downloadgnupg-c772770574ea2d337f8745ff304b1b8acd8a2e4c.tar.gz
gnupg-c772770574ea2d337f8745ff304b1b8acd8a2e4c.zip
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 <[email protected]>
-rw-r--r--kbx/backend-sqlite.c3
-rw-r--r--sm/delete.c2
-rw-r--r--sm/keydb.c32
3 files changed, 32 insertions, 5 deletions
diff --git a/kbx/backend-sqlite.c b/kbx/backend-sqlite.c
index 2b5da9134..ab68163ab 100644
--- a/kbx/backend-sqlite.c
+++ b/kbx/backend-sqlite.c
@@ -1522,6 +1522,9 @@ be_sqlite_delete (ctrl_t ctrl, backend_handle_t backend_hd,
("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);
diff --git a/sm/delete.c b/sm/delete.c
index 511ffb9b2..ccd389313 100644
--- a/sm/delete.c
+++ b/sm/delete.c
@@ -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)
diff --git a/sm/keydb.c b/sm/keydb.c
index 47f8a0bce..f7d815e65 100644
--- a/sm/keydb.c
+++ b/sm/keydb.c
@@ -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)":""); */
}
}