aboutsummaryrefslogtreecommitdiffstats
path: root/kbx
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2020-09-24 08:27:19 +0000
committerWerner Koch <[email protected]>2020-09-24 08:37:42 +0000
commit25ad3c22d79d06c16a5fc652b0a6e3ffd99ad2b6 (patch)
tree055829e80850bdec48fcbce915ff9e4de8280021 /kbx
parentkeyboxd: Fix UDPATE keyblob SQL statement (diff)
downloadgnupg-25ad3c22d79d06c16a5fc652b0a6e3ffd99ad2b6.tar.gz
gnupg-25ad3c22d79d06c16a5fc652b0a6e3ffd99ad2b6.zip
keyboxd: Implement multiple search descriptions.
* kbx/kbx-client-util.c (kbx_client_data_simple): New. * kbx/backend-sqlite.c (struct be_sqlite_local_s): Add field descidx. (be_sqlite_search): Use that. * g10/call-keyboxd.c (keydb_search): Implement multi mode. -- With that change the keyboxd is at par with the keybox code. Signed-off-by: Werner Koch <[email protected]>
Diffstat (limited to 'kbx')
-rw-r--r--kbx/backend-sqlite.c13
-rw-r--r--kbx/kbx-client-util.c10
-rw-r--r--kbx/kbx-client-util.h1
3 files changed, 22 insertions, 2 deletions
diff --git a/kbx/backend-sqlite.c b/kbx/backend-sqlite.c
index 6ba1886d6..0b5155a8f 100644
--- a/kbx/backend-sqlite.c
+++ b/kbx/backend-sqlite.c
@@ -78,6 +78,9 @@ struct be_sqlite_local_s
unsigned int filter_opgp : 1;
unsigned int filter_x509 : 1;
+ /* The current description index. */
+ unsigned int descidx;
+
/* The select statement has been executed with success. */
int select_done;
@@ -690,7 +693,7 @@ run_select_statement (ctrl_t ctrl, be_sqlite_local_t ctx,
unsigned char kidbuf[8];
- descidx = 0; /* Fixme: take from context. */
+ descidx = ctx->descidx;
if (descidx >= ndesc)
{
err = gpg_error (GPG_ERR_EOF);
@@ -985,6 +988,7 @@ be_sqlite_search (ctrl_t ctrl,
/* Reset */
ctx->select_done = 0;
ctx->select_eof = 0;
+ ctx->descidx = 0;
err = 0;
goto leave;
}
@@ -996,6 +1000,7 @@ be_sqlite_search (ctrl_t ctrl,
goto leave;
}
+ again:
if (!ctx->select_done)
{
/* Initial search - run the select. */
@@ -1131,7 +1136,11 @@ be_sqlite_search (ctrl_t ctrl,
}
else if (gpg_err_code (err) == GPG_ERR_SQL_DONE)
{
- /* FIXME: Move on to the next description index. */
+ if (++ctx->descidx < ndesc)
+ {
+ ctx->select_done = 0;
+ goto again;
+ }
err = gpg_error (GPG_ERR_EOF);
ctx->select_eof = 1;
}
diff --git a/kbx/kbx-client-util.c b/kbx/kbx-client-util.c
index e301ae025..f7477661f 100644
--- a/kbx/kbx-client-util.c
+++ b/kbx/kbx-client-util.c
@@ -339,6 +339,16 @@ kbx_client_data_release (kbx_client_data_t kcd)
}
+/* Send a simple Assuan command to the server. */
+gpg_error_t
+kbx_client_data_simple (kbx_client_data_t kcd, const char *command)
+{
+ /* log_debug ("%s: sending command '%s'\n", __func__, command); */
+ return assuan_transact (kcd->ctx, command,
+ NULL, NULL, NULL, NULL, NULL, NULL);
+}
+
+
/* Send the COMMAND down to the keyboxd associated with KCD.
* STATUS_CB and STATUS_CB_VALUE are the usual status callback as used
* by assuan_transact. After this function has returned success
diff --git a/kbx/kbx-client-util.h b/kbx/kbx-client-util.h
index 1cc68b5a0..07cf78ec7 100644
--- a/kbx/kbx-client-util.h
+++ b/kbx/kbx-client-util.h
@@ -28,6 +28,7 @@ typedef struct kbx_client_data_s *kbx_client_data_t;
gpg_error_t kbx_client_data_new (kbx_client_data_t *r_kcd,
assuan_context_t ctx, int dlines);
void kbx_client_data_release (kbx_client_data_t kcd);
+gpg_error_t kbx_client_data_simple (kbx_client_data_t kcd, const char *command);
gpg_error_t kbx_client_data_cmd (kbx_client_data_t kcd, const char *command,
gpg_error_t (*status_cb)(void *opaque,
const char *line),