From a722b886545086c0625285d8615f9782b11bacf5 Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Wed, 5 Feb 2025 10:52:56 +0000 Subject: [PATCH] repos: Fix exporting keys Before, the key was randomly written into the file descriptor. Signed-off-by: Michael Tremer --- src/pakfire/repo.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) 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; } } -- 2.39.5