diff --git a/src/parser.c b/src/parser.c index c922951..9b38753 100644 --- a/src/parser.c +++ b/src/parser.c @@ -1079,7 +1079,8 @@ int simple_archiver_handle_map_user_or_group( } if (first_is_numeric && last_is_numeric) { - if (simple_archiver_hash_map_get(IDToID, first_id, sizeof(uint32_t))) { + if (simple_archiver_hash_map_get(IDToID, first_id, sizeof(uint32_t)) + || simple_archiver_hash_map_get(IDToName, first_id, sizeof(uint32_t))) { fprintf(stderr, "ERROR: Mapping with key \"%" PRIu32 "\" already exists!\n", *first_id); @@ -1103,7 +1104,8 @@ int simple_archiver_handle_map_user_or_group( last_id = NULL; first_id = NULL; } else if (first_is_numeric) { - if (simple_archiver_hash_map_get(IDToName, first_id, sizeof(uint32_t))) { + if (simple_archiver_hash_map_get(IDToName, first_id, sizeof(uint32_t)) + || simple_archiver_hash_map_get(IDToID, first_id, sizeof(uint32_t))) { fprintf(stderr, "ERROR: Mapping with key \"%" PRIu32 "\" already exists!\n", *first_id); @@ -1129,7 +1131,10 @@ int simple_archiver_handle_map_user_or_group( } else if (last_is_numeric) { if (simple_archiver_hash_map_get(NameToID, first_buf, - strlen(first_buf) + 1)) { + strlen(first_buf) + 1) + || simple_archiver_hash_map_get(NameToName, + first_buf, + strlen(first_buf) + 1)) { fprintf(stderr, "ERROR: Mapping with key \"%s\" already exists!\n", first_buf); @@ -1155,7 +1160,10 @@ int simple_archiver_handle_map_user_or_group( } else { if (simple_archiver_hash_map_get(NameToName, first_buf, - strlen(first_buf) + 1)) { + strlen(first_buf) + 1) + || simple_archiver_hash_map_get(NameToID, + first_buf, + strlen(first_buf) + 1)) { fprintf(stderr, "ERROR: Mapping with key \"%s\" already exists!\n", first_buf); diff --git a/src/test.c b/src/test.c index 6c5c643..cde8699 100644 --- a/src/test.c +++ b/src/test.c @@ -169,6 +169,13 @@ int main(void) { parsed.mappings.UidToUid, parsed.mappings.UnameToUname) != 0); fprintf(stderr, "Expecting ERROR output on next line:\n"); + CHECK_TRUE(simple_archiver_handle_map_user_or_group( + "1000:other", + parsed.mappings.UidToUname, + parsed.mappings.UnameToUid, + parsed.mappings.UidToUid, + parsed.mappings.UnameToUname) != 0); + fprintf(stderr, "Expecting ERROR output on next line:\n"); CHECK_TRUE(simple_archiver_handle_map_user_or_group( "1002:user00", parsed.mappings.UidToUname, @@ -176,6 +183,13 @@ int main(void) { parsed.mappings.UidToUid, parsed.mappings.UnameToUname) != 0); fprintf(stderr, "Expecting ERROR output on next line:\n"); + CHECK_TRUE(simple_archiver_handle_map_user_or_group( + "1002:100", + parsed.mappings.UidToUname, + parsed.mappings.UnameToUid, + parsed.mappings.UidToUid, + parsed.mappings.UnameToUname) != 0); + fprintf(stderr, "Expecting ERROR output on next line:\n"); CHECK_TRUE(simple_archiver_handle_map_user_or_group( "user1:1033", parsed.mappings.UidToUname, @@ -183,12 +197,26 @@ int main(void) { parsed.mappings.UidToUid, parsed.mappings.UnameToUname) != 0); fprintf(stderr, "Expecting ERROR output on next line:\n"); + CHECK_TRUE(simple_archiver_handle_map_user_or_group( + "user1:user10", + parsed.mappings.UidToUname, + parsed.mappings.UnameToUid, + parsed.mappings.UidToUid, + parsed.mappings.UnameToUname) != 0); + fprintf(stderr, "Expecting ERROR output on next line:\n"); CHECK_TRUE(simple_archiver_handle_map_user_or_group( "user2:us3r3", parsed.mappings.UidToUname, parsed.mappings.UnameToUid, parsed.mappings.UidToUid, parsed.mappings.UnameToUname) != 0); + fprintf(stderr, "Expecting ERROR output on next line:\n"); + CHECK_TRUE(simple_archiver_handle_map_user_or_group( + "user2:3", + parsed.mappings.UidToUname, + parsed.mappings.UnameToUid, + parsed.mappings.UidToUid, + parsed.mappings.UnameToUname) != 0); uint32_t id_check = 1000; uint32_t *id_get;