diff options
author | Tavian Barnes <tavianator@tavianator.com> | 2020-03-02 12:24:31 -0500 |
---|---|---|
committer | Tavian Barnes <tavianator@tavianator.com> | 2020-03-02 12:24:31 -0500 |
commit | 378607cc3e9d2d90c0158d40fcecd6834351dd80 (patch) | |
tree | f491a62ac7e97fb8ae29c68bc8d24274d81ee615 /passwd.c | |
parent | 10a408c15a77dfad65eda026f230f7e571d8d617 (diff) | |
download | bfs-378607cc3e9d2d90c0158d40fcecd6834351dd80.tar.xz |
passwd: Make earlier entries override later ones
Diffstat (limited to 'passwd.c')
-rw-r--r-- | passwd.c | 16 |
1 files changed, 12 insertions, 4 deletions
@@ -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; |