From 1d4b54ef8c661c60ad0ae8e2dec5704bb94a6654 Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Wed, 17 Aug 2022 10:07:57 +0000 Subject: [PATCH] jail: Use common function to write files Signed-off-by: Michael Tremer --- src/libpakfire/jail.c | 35 ++--------------------------------- 1 file changed, 2 insertions(+), 33 deletions(-) diff --git a/src/libpakfire/jail.c b/src/libpakfire/jail.c index c4b19833..06b664be 100644 --- a/src/libpakfire/jail.c +++ b/src/libpakfire/jail.c @@ -982,39 +982,8 @@ static int pakfire_jail_mount(struct pakfire_jail* jail) { static int pakfire_jail_write_uidgid_mapping(struct pakfire_jail* jail, const char* path, const struct pakfire_subid* subid) { - int r = 1; - - // Open file for writing - FILE* f = fopen(path, "w"); - if (!f) { - ERROR(jail->pakfire, "Could not open %s for writing: %m\n", path); - goto ERROR; - } - - // Write configuration - int bytes_written = fprintf(f, "%d %u %lu\n", 0, subid->id, subid->length); - if (bytes_written <= 0) { - ERROR(jail->pakfire, "Could not write UID/GID mapping: %m\n"); - goto ERROR; - } - - // Close the file - r = fclose(f); - f = NULL; - if (r) { - ERROR(jail->pakfire, "Could not write UID/GID mapping: %m\n"); - - goto ERROR; - } - - // Success - r = 0; - -ERROR: - if (f) - fclose(f); - - return r; + return pakfire_file_write(jail->pakfire, path, 0, 0, 0, + "%d %u %lu\n", 0, subid->id, subid->length); } static int pakfire_jail_setup_uid_mapping(struct pakfire_jail* jail, pid_t pid) { -- 2.47.3