]> git.ipfire.org Git - pakfire.git/commitdiff
repos: Fix exporting keys
authorMichael Tremer <michael.tremer@ipfire.org>
Wed, 5 Feb 2025 10:52:56 +0000 (10:52 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Wed, 5 Feb 2025 10:52:56 +0000 (10:52 +0000)
Before, the key was randomly written into the file descriptor.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/pakfire/repo.c

index e8a8284ddd587e40c2be9c789a4de71642418da6..6b0b6770b704956722e336697b52550fc7f7b3a3 100644 (file)
@@ -1801,20 +1801,16 @@ int pakfire_repo_write_config(struct pakfire_repo* repo, FILE* f) {
        // Key
        key = pakfire_repo_get_key(repo);
        if (key) {
-               r = pakfire_key_export(key, f, PAKFIRE_KEY_EXPORT_MODE_PUBLIC);
-               if (r) {
-                       ERROR(repo->ctx, "Could not export the key: %m\n");
+               r = pakfire_key_export_string(key, &buffer, &length);
+               if (r < 0) {
+                       ERROR(repo->ctx, "Could not export the key: %s\n", strerror(-r));
                        goto ERROR;
                }
 
-#warning Are we actually exporting the key here?
-
-               if (buffer) {
-                       r = pakfire_config_set_format(config, section, "key", "%.*s", (int)length, buffer);
-                       if (r) {
-                               ERROR(repo->ctx, "Could not set key: %m\n");
-                               goto ERROR;
-                       }
+               r = pakfire_config_set_format(config, section, "key", "%.*s", (int)length, buffer);
+               if (r < 0) {
+                       ERROR(repo->ctx, "Could not set key: %s\n", strerror(-r));
+                       goto ERROR;
                }
        }