]> the.earth.li Git - onak.git/blobdiff - keydb_fs.c
Properly free database context when cleaning up fs backend
[onak.git] / keydb_fs.c
index 0bf922f1475a419781226b33dc22e154e4234c63..01874ee4188da6e1d483a8fffb7bc7115e47ba70 100644 (file)
@@ -394,10 +394,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;
@@ -407,9 +408,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);
@@ -633,6 +636,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);
 }
 
 /**
@@ -703,7 +710,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;