From: Michael Tremer Date: Wed, 17 Aug 2022 10:07:57 +0000 (+0000) Subject: jail: Use common function to write files X-Git-Tag: 0.9.28~477 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1d4b54ef8c661c60ad0ae8e2dec5704bb94a6654;p=pakfire.git jail: Use common function to write files Signed-off-by: Michael Tremer --- diff --git a/src/libpakfire/jail.c b/src/libpakfire/jail.c index c4b19833f..06b664be3 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) {