From: Stephen Seo Date: Wed, 8 Jan 2025 06:58:38 +0000 (+0900) Subject: Impl UID/GID remap for file format v1 X-Git-Tag: 1.11^2~8 X-Git-Url: https://git.seodisparate.com/stephenseo/annotated.html?a=commitdiff_plain;h=34b34673895c7e75f3f364c1ccf2f3ec0d1a51d0;p=SimpleArchiver Impl UID/GID remap for file format v1 TODO: Remap on extract. --- diff --git a/src/archiver.c b/src/archiver.c index 4c03757..4616471 100644 --- a/src/archiver.c +++ b/src/archiver.c @@ -2816,12 +2816,42 @@ int simple_archiver_write_v1(FILE *out_f, SDArchiverState *state, // Forced UID/GID is already handled by "symlinks_and_files_from_files". u32 = file_info_struct->uid; + if ((state->parsed->flags & 0x400) == 0) { + uint32_t mapped_uid; + if (simple_archiver_get_uid_mapping(state->parsed->mappings, + state->parsed->users_infos, + u32, + &mapped_uid, + NULL) == 0) { + //fprintf(stderr, + // "NOTICE: Mapped UID %" PRIu32 " to %" PRIu32 " for %s\n", + // u32, + // mapped_uid, + // file_info_struct->filename); + u32 = mapped_uid; + } + } simple_archiver_helper_32_bit_be(&u32); if (fwrite(&u32, 4, 1, out_f) != 1) { return SDAS_FAILED_TO_WRITE; } u32 = file_info_struct->gid; + if ((state->parsed->flags & 0x800) == 0) { + uint32_t mapped_gid; + if (simple_archiver_get_gid_mapping(state->parsed->mappings, + state->parsed->users_infos, + u32, + &mapped_gid, + NULL) == 0) { + //fprintf(stderr, + // "NOTICE: Mapped GID %" PRIu32 " to %" PRIu32 " for %s\n", + // u32, + // mapped_gid, + // file_info_struct->filename); + u32 = mapped_gid; + } + } simple_archiver_helper_32_bit_be(&u32); if (fwrite(&u32, 4, 1, out_f) != 1) { return SDAS_FAILED_TO_WRITE;