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) {