]> git.ipfire.org Git - pakfire.git/commitdiff
repo: Store the fingerprint of the imported key
authorMichael Tremer <michael.tremer@ipfire.org>
Wed, 12 Oct 2022 10:09:39 +0000 (10:09 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Wed, 12 Oct 2022 10:09:39 +0000 (10:09 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/libpakfire/include/pakfire/key.h
src/libpakfire/repo.c

index 4962a22c7bab3d1fd6f8e5c35bc642fe1b7589fd..139bc63ca0b22c48e5cb2190d10c55bbe036f9c2 100644 (file)
@@ -67,6 +67,8 @@ char* pakfire_key_dump(struct pakfire_key* key);
 
 #include <gpgme.h>
 
+#define PAKFIRE_KEY_FPR_MAXLEN 41
+
 int pakfire_key_create(struct pakfire_key** key, struct pakfire* pakfire, gpgme_key_t gpgkey);
 
 int pakfire_key_sign(struct pakfire_key* key, const char* buffer, const size_t buffer_length,
index 9f4f9221108dafd25fc32c5d1b6f6faaf6a4ec24..38ab62401e3d2c5b0f1eda7e8b7ed46f5f1fe9c9 100644 (file)
@@ -63,7 +63,7 @@ struct pakfire_repo_appdata {
        char metadata[PATH_MAX];
 
        // Key fingerprint
-       char* key;
+       char key[PAKFIRE_KEY_FPR_MAXLEN];
 
        // Mirrorlist
        char* mirrorlist_url;
@@ -153,6 +153,18 @@ static int pakfire_repo_import_key(struct pakfire_repo* repo, FILE* f) {
 
                if (dump)
                        DEBUG(repo->pakfire, "Imported key:\n%s\n", dump);
+
+               // Fetch the key's fingerprint
+               const char* fingerprint = pakfire_key_get_fingerprint(*key);
+               if (!fingerprint) {
+                       r = 1;
+                       goto ERROR;
+               }
+
+               // Store the fingerprint
+               r = pakfire_string_set(repo->appdata->key, fingerprint);
+               if (r)
+                       goto ERROR;
        }
 
 ERROR: