]> the.earth.li Git - onak.git/blobdiff - keydb_fs.c
Change delete_key to use a full fingerprint
[onak.git] / keydb_fs.c
index 78e240cdae6c2f86b8dd7a830849d629269b21e7..926960f04cbe9a2f7aec564f094e2d26201d05d2 100644 (file)
@@ -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 <https://www.gnu.org/licenses/>.
  */
 
 #include <sys/types.h>
@@ -395,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;
@@ -408,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);