#include <string.h>
#include <unistd.h>
+#include "build-config.h"
#include "charfuncs.h"
#include "keyarray.h"
#include "keydb.h"
*
* This is just a no-op for keyring file access.
*/
-static bool keyring_starttrans(struct onak_dbctx *dbctx)
+static bool keyring_starttrans(__unused struct onak_dbctx *dbctx)
{
return true;
}
*
* This is just a no-op for keyring file access.
*/
-static void keyring_endtrans(struct onak_dbctx *dbctx)
+static void keyring_endtrans(__unused struct onak_dbctx *dbctx)
{
return;
}
/**
* keyring_fetch_key - fetch a key given its index
*/
-static int keyring_fetch_key(struct onak_keyring_dbctx *privctx,
+static int keyring_fetch_key_idx(struct onak_keyring_dbctx *privctx,
unsigned int index,
struct openpgp_publickey **publickey)
{
return 1;
}
-static int keyring_fetch_key_fp(struct onak_dbctx *dbctx,
+/*
+ * We only index the primary fingerprint of the key, so will only return one
+ * key at most from this function.
+ */
+static int keyring_fetch_key(struct onak_dbctx *dbctx,
struct openpgp_fingerprint *fingerprint,
struct openpgp_publickey **publickey,
- bool intrans)
+ __unused bool intrans)
{
struct onak_keyring_dbctx *privctx =
(struct onak_keyring_dbctx *) dbctx->priv;
}
if (i < privctx->count) {
- return keyring_fetch_key(privctx, i, publickey);
+ return keyring_fetch_key_idx(privctx, i, publickey);
}
return 0;
static int keyring_fetch_key_id(struct onak_dbctx *dbctx,
uint64_t keyid,
struct openpgp_publickey **publickey,
- bool intrans)
+ __unused bool intrans)
{
struct onak_keyring_dbctx *privctx =
(struct onak_keyring_dbctx *) dbctx->priv;
count = 0;
for (i = 0; i < privctx->count; i++) {
if (fingerprint2keyid(&privctx->keys[i].fp) == keyid) {
- if (keyring_fetch_key(privctx, i, publickey))
+ if (keyring_fetch_key_idx(privctx, i, publickey))
count++;
}
}
*
* We don't support storing keys into a keyring file.
*/
-static int keyring_store_key(struct onak_dbctx *dbctx,
- struct openpgp_publickey *publickey, bool intrans,
- bool update)
+static int keyring_store_key(__unused struct onak_dbctx *dbctx,
+ __unused struct openpgp_publickey *publickey,
+ __unused bool intrans,
+ __unused bool update)
{
return 0;
}
*
* We don't support removing keys from a keyring file.
*/
-static int keyring_delete_key(struct onak_dbctx *dbctx,
- struct openpgp_fingerprint *fp, bool intrans)
+static int keyring_delete_key(__unused struct onak_dbctx *dbctx,
+ __unused struct openpgp_fingerprint *fp, __unused bool intrans)
{
return 1;
}
*
* TODO: Write for flat file access. Some sort of grep?
*/
-static int keyring_fetch_key_text(struct onak_dbctx *dbctx,
- const char *search,
- struct openpgp_publickey **publickey)
+static int keyring_fetch_key_text(__unused struct onak_dbctx *dbctx,
+ __unused const char *search,
+ __unused struct openpgp_publickey **publickey)
{
return 0;
}
count = 0;
for (i = 0; i < privctx->count; i++) {
- if (keyring_fetch_key(privctx, i, &key)) {
+ if (keyring_fetch_key_idx(privctx, i, &key)) {
iterfunc(ctx, key);
free_publickey(key);
key = NULL;
return count;
}
-static int keyring_update_keys(struct onak_dbctx *dbctx,
- struct openpgp_publickey **keys,
- struct keyarray *blacklist,
- bool updateonly,
- bool sendsync)
+static int keyring_update_keys(__unused struct onak_dbctx *dbctx,
+ __unused struct openpgp_publickey **keys,
+ __unused struct keyarray *blacklist,
+ __unused bool updateonly,
+ __unused bool sendsync)
{
return 0;
}
* We need to fetch the key to calculate the
* fingerprint.
*/
- keyring_fetch_key(privctx, privctx->count - 1,
+ keyring_fetch_key_idx(privctx,
+ privctx->count - 1,
&key);
get_fingerprint(key->publickey,
&privctx->keys[privctx->count - 1].fp);
if (dbctx != NULL) {
free(dbctx);
}
-};
+}
/**
* initdb - Initialize the key database.
* This is just a no-op for flat file access.
*/
struct onak_dbctx *keydb_keyring_init(struct onak_db_config *dbcfg,
- bool readonly)
+ __unused bool readonly)
{
struct onak_keyring_dbctx *privctx;
struct onak_dbctx *dbctx;
dbctx->cleanupdb = keyring_cleanupdb;
dbctx->starttrans = keyring_starttrans;
dbctx->endtrans = keyring_endtrans;
+ dbctx->fetch_key = keyring_fetch_key;
+ /* We don't index by subkey fingerprint, so fallback to fetch_key */
+ dbctx->fetch_key_fp = keyring_fetch_key;
dbctx->fetch_key_id = keyring_fetch_key_id;
- dbctx->fetch_key_fp = keyring_fetch_key_fp;
dbctx->fetch_key_text = keyring_fetch_key_text;
dbctx->store_key = keyring_store_key;
dbctx->update_keys = keyring_update_keys;