From: Michael Tremer Date: Wed, 5 Feb 2025 10:52:56 +0000 (+0000) Subject: repos: Fix exporting keys X-Git-Tag: 0.9.30~126 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a722b886545086c0625285d8615f9782b11bacf5;p=pakfire.git repos: Fix exporting keys Before, the key was randomly written into the file descriptor. Signed-off-by: Michael Tremer --- diff --git a/src/pakfire/repo.c b/src/pakfire/repo.c index e8a8284d..6b0b6770 100644 --- a/src/pakfire/repo.c +++ b/src/pakfire/repo.c @@ -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; } }