summaryrefslogtreecommitdiffstats
path: root/passwd.c
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2020-03-02 12:24:31 -0500
committerTavian Barnes <tavianator@tavianator.com>2020-03-02 12:24:31 -0500
commit378607cc3e9d2d90c0158d40fcecd6834351dd80 (patch)
treef491a62ac7e97fb8ae29c68bc8d24274d81ee615 /passwd.c
parent10a408c15a77dfad65eda026f230f7e571d8d617 (diff)
downloadbfs-378607cc3e9d2d90c0158d40fcecd6834351dd80.tar.xz
passwd: Make earlier entries override later ones
Diffstat (limited to 'passwd.c')
-rw-r--r--passwd.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/passwd.c b/passwd.c
index ffb7b8c..2640c70 100644
--- a/passwd.c
+++ b/passwd.c
@@ -79,7 +79,9 @@ struct bfs_users *bfs_parse_users(void) {
struct passwd *entry = users->entries + i;
struct trie_leaf *leaf = trie_insert_str(&users->by_name, entry->pw_name);
if (leaf) {
- leaf->value = entry;
+ if (!leaf->value) {
+ leaf->value = entry;
+ }
} else {
error = errno;
goto fail_free;
@@ -87,7 +89,9 @@ struct bfs_users *bfs_parse_users(void) {
leaf = trie_insert_mem(&users->by_uid, &entry->pw_uid, sizeof(entry->pw_uid));
if (leaf) {
- leaf->value = entry;
+ if (!leaf->value) {
+ leaf->value = entry;
+ }
} else {
error = errno;
goto fail_free;
@@ -209,7 +213,9 @@ struct bfs_groups *bfs_parse_groups(void) {
struct group *entry = groups->entries + i;
struct trie_leaf *leaf = trie_insert_str(&groups->by_name, entry->gr_name);
if (leaf) {
- leaf->value = entry;
+ if (!leaf->value) {
+ leaf->value = entry;
+ }
} else {
error = errno;
goto fail_free;
@@ -217,7 +223,9 @@ struct bfs_groups *bfs_parse_groups(void) {
leaf = trie_insert_mem(&groups->by_gid, &entry->gr_gid, sizeof(entry->gr_gid));
if (leaf) {
- leaf->value = entry;
+ if (!leaf->value) {
+ leaf->value = entry;
+ }
} else {
error = errno;
goto fail_free;