Require vendor users and groups to start with vendor_
Require that users and groups found in /vendor/etc/{passwd,group}
start with vendor_. This is needed to compliance with Treble as
without this prefix, it is possible for a new system image to create a
user/group name that a vendor has already used, causing a collision.
Bug: 79528966
Test: new unit test
Change-Id: I07500641e165f41526a8101592d83fa174e7a711
diff --git a/libc/private/grp_pwd.h b/libc/private/grp_pwd.h
index e1aff4f..ab79586 100644
--- a/libc/private/grp_pwd.h
+++ b/libc/private/grp_pwd.h
@@ -31,18 +31,20 @@
#include <grp.h>
#include <pwd.h>
+static constexpr size_t kGrpPwdBufferSize = 32;
+
struct group_state_t {
group group_;
char* group_members_[2];
- char group_name_buffer_[32];
+ char group_name_buffer_[kGrpPwdBufferSize];
// Must be last so init_group_state can run a simple memset for the above
ssize_t getgrent_idx;
};
struct passwd_state_t {
passwd passwd_;
- char name_buffer_[32];
- char dir_buffer_[32];
- char sh_buffer_[32];
+ char name_buffer_[kGrpPwdBufferSize];
+ char dir_buffer_[kGrpPwdBufferSize];
+ char sh_buffer_[kGrpPwdBufferSize];
ssize_t getpwent_idx;
};