X-Git-Url: https://the.earth.li/gitweb/?a=blobdiff_plain;f=keydb_fs.c;h=f8d55dc8233dd80a2b92e6878abee3719dc67cd0;hb=dfab9e96ee1fa4a10acf9c1cf644d7a4366a5af6;hp=78e240cdae6c2f86b8dd7a830849d629269b21e7;hpb=0c120d1895d25b59abe338862189be1b87447569;p=onak.git diff --git a/keydb_fs.c b/keydb_fs.c index 78e240c..f8d55dc 100644 --- a/keydb_fs.c +++ b/keydb_fs.c @@ -13,8 +13,7 @@ * more details. * * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., 51 - * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * this program. If not, see . */ #include @@ -380,8 +379,13 @@ static int fs_store_key(struct onak_dbctx *dbctx, } get_skshash(publickey, &hash); - hashid = (hash.hash[0] << 24) + (hash.hash[1] << 16) + - (hash.hash[2] << 8) + hash.hash[3]; + hashid = hash.hash[0]; + hashid <<= 8; + hashid |= hash.hash[1]; + hashid <<= 8; + hashid |= hash.hash[2]; + hashid <<= 8; + hashid |= hash.hash[3]; prove_path_to(hashid, "skshash", dbctx->config->location); skshashpath(wbuffer, sizeof(wbuffer), &hash, dbctx->config->location); @@ -395,10 +399,11 @@ static int fs_store_key(struct onak_dbctx *dbctx, /** * delete_key - Given a keyid delete the key from storage. - * @keyid: The keyid to delete. + * @fp: The fingerprint of the key to delete. * @intrans: If we're already in a transaction. */ -static int fs_delete_key(struct onak_dbctx *dbctx, uint64_t keyid, bool intrans) +static int fs_delete_key(struct onak_dbctx *dbctx, + struct openpgp_fingerprint *fp, bool intrans) { static char buffer[PATH_MAX]; int ret; @@ -408,9 +413,11 @@ static int fs_delete_key(struct onak_dbctx *dbctx, uint64_t keyid, bool intrans) struct openpgp_fingerprint *subkeyids = NULL; uint64_t subkeyid; int i = 0; + uint64_t keyid; - if ((keyid >> 32) == 0) - keyid = fs_getfullkeyid(dbctx, keyid); + keyid = fingerprint2keyid(fp); + if (keyid == 0) + return 1; if (!intrans) fs_starttrans(dbctx); @@ -433,6 +440,8 @@ static int fs_delete_key(struct onak_dbctx *dbctx, uint64_t keyid, bool intrans) wl = wl->next; } + llfree(wordlist, free); + wordlist = NULL; subkeyids = keysubkeys(pk); i = 0; @@ -461,6 +470,8 @@ static int fs_delete_key(struct onak_dbctx *dbctx, uint64_t keyid, bool intrans) keypath(buffer, sizeof(buffer), keyid, dbctx->config->location); unlink(buffer); + free_publickey(pk); + if (!intrans) fs_endtrans(dbctx); return 1; @@ -634,6 +645,10 @@ static void fs_cleanupdb(struct onak_dbctx *dbctx) /* Mmmm nothing to do here? */ close(privctx->lockfile_fd); + + free(privctx); + dbctx->priv = NULL; + free(dbctx); } /** @@ -704,7 +719,6 @@ struct onak_dbctx *keydb_fs_init(struct onak_db_config *dbcfg, bool readonly) dbctx->getkeysigs = generic_getkeysigs; dbctx->cached_getkeysigs = generic_cached_getkeysigs; dbctx->keyid2uid = generic_keyid2uid; - dbctx->getfullkeyid = fs_getfullkeyid; dbctx->iterate_keys = fs_iterate_keys; return dbctx;