(struct onak_dbctx *) privctx->backends->object;
struct openpgp_publickey *curkey;
- cleankeys(&publickey, config.clean_policies);
+ cleankeys(backend, &publickey, config.clean_policies);
/*
* If we walked the stack at all, store the key in the first
* backend if configured to do so. It's not an update as we
* reach the end or get a successful result.
*/
-static int stacked_fetch_key_id(struct onak_dbctx *dbctx, uint64_t keyid,
+static int stacked_fetch_key(struct onak_dbctx *dbctx,
+ struct openpgp_fingerprint *fingerprint,
struct openpgp_publickey **publickey, bool intrans)
{
struct onak_stacked_dbctx *privctx =
for (cur = privctx->backends; cur != NULL && res == 0;
cur = cur->next) {
backend = (struct onak_dbctx *) cur->object;
- res = backend->fetch_key_id(backend, keyid, publickey,
+ res = backend->fetch_key(backend, fingerprint, publickey,
intrans);
}
return res;
}
+static int stacked_fetch_key_id(struct onak_dbctx *dbctx, uint64_t keyid,
+ struct openpgp_publickey **publickey, bool intrans)
+{
+ struct onak_stacked_dbctx *privctx =
+ (struct onak_stacked_dbctx *) dbctx->priv;
+ struct onak_dbctx *backend;
+ struct ll *cur;
+ int res = 0;
+
+ for (cur = privctx->backends; cur != NULL && res == 0;
+ cur = cur->next) {
+ backend = (struct onak_dbctx *) cur->object;
+ res = backend->fetch_key_id(backend, keyid, publickey,
+ intrans);
+ }
+
+ if (privctx->store_on_fallback && cur != privctx->backends) {
+ store_on_fallback(privctx, *publickey, intrans);
+ }
+
+ return res;
+}
+
static int stacked_fetch_key_text(struct onak_dbctx *dbctx,
const char *search,
struct openpgp_publickey **publickey)
dbctx->cleanupdb = stacked_cleanupdb;
dbctx->starttrans = stacked_starttrans;
dbctx->endtrans = stacked_endtrans;
- dbctx->fetch_key_id = stacked_fetch_key_id;
+ dbctx->fetch_key = stacked_fetch_key;
dbctx->fetch_key_fp = stacked_fetch_key_fp;
+ dbctx->fetch_key_id = stacked_fetch_key_id;
dbctx->fetch_key_text = stacked_fetch_key_text;
dbctx->fetch_key_skshash = stacked_fetch_key_skshash;
dbctx->store_key = stacked_store_key;