X-Git-Url: https://the.earth.li/gitweb/?a=blobdiff_plain;f=keydb_db4.c;h=df07769ee224030291e831f034d1e3e4696e7d55;hb=a8c0920cce727a12697154a85896f2a3ba47eb75;hp=d2db2c5a39923f6bd7a9c4fe32f415919beb7f02;hpb=5cb163e87c7f0717aa94ca281a56e572c2a6c8f3;p=onak.git diff --git a/keydb_db4.c b/keydb_db4.c index d2db2c5..df07769 100644 --- a/keydb_db4.c +++ b/keydb_db4.c @@ -289,70 +289,6 @@ static int db4_upgradedb(struct onak_dbctx *dbctx) return ret; } -/** - * getfullkeyid - Maps a 32bit key id to a 64bit one. - * @keyid: The 32bit keyid. - * - * This function maps a 32bit key id to the full 64bit one. It returns the - * first full keyid that has this short keyid. If the key isn't found a - * keyid of 0 is returned. - * - * FIXME: This should either return the fingerprint or ideally go away - * entirely. - */ -static uint64_t db4_getfullkeyid(struct onak_dbctx *dbctx, uint64_t keyid) -{ - struct onak_db4_dbctx *privctx = (struct onak_db4_dbctx *) dbctx->priv; - DBT key, data; - DBC *cursor = NULL; - uint32_t shortkeyid = 0; - int ret = 0; - int i; - - if (keyid < 0x100000000LL) { - ret = privctx->id32db->cursor(privctx->id32db, - privctx->txn, - &cursor, - 0); /* flags */ - - if (ret != 0) { - return 0; - } - - shortkeyid = keyid & 0xFFFFFFFF; - - memset(&key, 0, sizeof(key)); - memset(&data, 0, sizeof(data)); - key.data = &shortkeyid; - key.size = sizeof(shortkeyid); - data.flags = DB_DBT_MALLOC; - - ret = cursor->c_get(cursor, - &key, - &data, - DB_SET); - - if (ret == 0) { - keyid = 0; - /* Only works for v4, not v3 or v5 */ - for (i = 12; i < 20; i++) { - keyid <<= 8; - keyid |= ((uint8_t *) data.data)[i]; - } - - if (data.data != NULL) { - free(data.data); - data.data = NULL; - } - } - - cursor->c_close(cursor); - cursor = NULL; - } - - return keyid; -} - /** * fetch_key_fp - Given a fingerprint fetch the key from storage. */ @@ -536,12 +472,6 @@ static int db4_fetch_key_id(struct onak_dbctx *dbctx, uint64_t keyid, return (numkeys); } - -int worddb_cmp(const void *d1, const void *d2) -{ - return memcmp(d1, d2, 12); -} - /** * fetch_key_text - Trys to find the keys that contain the supplied text. * @search: The text to search for. @@ -725,7 +655,6 @@ static int db4_delete_key(struct onak_dbctx *dbctx, int i; char **uids = NULL; char *primary = NULL; - unsigned char worddb_data[12]; struct ll *wordlist = NULL; struct ll *curword = NULL; bool deadlock = false; @@ -765,13 +694,6 @@ static int db4_delete_key(struct onak_dbctx *dbctx, for (curword = wordlist; curword != NULL && !deadlock; curword = curword->next) { - memset(&key, 0, sizeof(key)); - memset(&data, 0, sizeof(data)); - key.data = curword->object; - key.size = strlen(key.data); - data.data = worddb_data; - data.size = sizeof(worddb_data); - /* * New style uses the fingerprint as the data * Old (unsupported) style was the 64 bit keyid @@ -893,7 +815,7 @@ static int db4_delete_key(struct onak_dbctx *dbctx, memset(&key, 0, sizeof(key)); key.data = subkeyids[i].fp; key.size = subkeyids[i].length; - privctx->subkeydb->del(privctx->subkeydb, + ret = privctx->subkeydb->del(privctx->subkeydb, privctx->txn, &key, 0); if (ret != 0 && ret != DB_NOTFOUND) { logthing(LOGTHING_ERROR, @@ -1832,7 +1754,6 @@ struct onak_dbctx *keydb_db4_init(struct onak_db_config *dbcfg, bool readonly) dbctx->getkeysigs = generic_getkeysigs; dbctx->cached_getkeysigs = generic_cached_getkeysigs; dbctx->keyid2uid = generic_keyid2uid; - dbctx->getfullkeyid = db4_getfullkeyid; dbctx->iterate_keys = db4_iterate_keys; return dbctx;