X-Git-Url: https://the.earth.li/gitweb/?p=onak.git;a=blobdiff_plain;f=keydb%2Fkeydb_db4.c;h=d9c45a9815799397d49231a7c659efb2b9f9989b;hp=1f306e267f60e9851c0dd65b0874517ba7afcb39;hb=a2979c20e1ab2d52e3a961ac7dad45fee9d6345a;hpb=00e37c36f214bf9d2e9794d3089e64522a6275a2 diff --git a/keydb/keydb_db4.c b/keydb/keydb_db4.c index 1f306e2..d9c45a9 100644 --- a/keydb/keydb_db4.c +++ b/keydb/keydb_db4.c @@ -295,10 +295,11 @@ static int db4_upgradedb(struct onak_dbctx *dbctx) /** * fetch_key_fp - Given a fingerprint fetch the key from storage. */ -static int db4_fetch_key_fp(struct onak_dbctx *dbctx, +static int db4_fetch_key_int(struct onak_dbctx *dbctx, struct openpgp_fingerprint *fingerprint, struct openpgp_publickey **publickey, - bool intrans) + bool intrans, + bool dosubkey) { struct onak_db4_dbctx *privctx = (struct onak_db4_dbctx *) dbctx->priv; struct openpgp_packet_list *packets = NULL; @@ -328,7 +329,7 @@ static int db4_fetch_key_fp(struct onak_dbctx *dbctx, &data, 0); /* flags*/ - if (ret == DB_NOTFOUND) { + if (ret == DB_NOTFOUND && dosubkey) { /* If we didn't find the key ID see if it's a subkey ID */ memset(&key, 0, sizeof(key)); memset(&data, 0, sizeof(data)); @@ -386,6 +387,22 @@ static int db4_fetch_key_fp(struct onak_dbctx *dbctx, return (numkeys); } +static int db4_fetch_key(struct onak_dbctx *dbctx, + struct openpgp_fingerprint *fingerprint, + struct openpgp_publickey **publickey, + bool intrans) +{ + return db4_fetch_key_int(dbctx, fingerprint, publickey, intrans, false); +} + +static int db4_fetch_key_fp(struct onak_dbctx *dbctx, + struct openpgp_fingerprint *fingerprint, + struct openpgp_publickey **publickey, + bool intrans) +{ + return db4_fetch_key_int(dbctx, fingerprint, publickey, intrans, true); +} + /** * fetch_key_id - Given a keyid fetch the key from storage. * @keyid: The keyid to fetch. @@ -1744,8 +1761,9 @@ struct onak_dbctx *keydb_db4_init(struct onak_db_config *dbcfg, bool readonly) dbctx->cleanupdb = db4_cleanupdb; dbctx->starttrans = db4_starttrans; dbctx->endtrans = db4_endtrans; - dbctx->fetch_key_id = db4_fetch_key_id; + dbctx->fetch_key = db4_fetch_key; dbctx->fetch_key_fp = db4_fetch_key_fp; + dbctx->fetch_key_id = db4_fetch_key_id; dbctx->fetch_key_text = db4_fetch_key_text; dbctx->fetch_key_skshash = db4_fetch_key_skshash; dbctx->store_key = db4_store_key;