Merge "Always return /vendor/bin/sh as shell for OEM ids in getpwnam() etc."
diff --git a/libc/bionic/grp_pwd.cpp b/libc/bionic/grp_pwd.cpp
index 136a098..dadda49 100644
--- a/libc/bionic/grp_pwd.cpp
+++ b/libc/bionic/grp_pwd.cpp
@@ -435,7 +435,7 @@
snprintf(state->name_buffer_, sizeof(state->name_buffer_), "oem_%u", uid);
snprintf(state->dir_buffer_, sizeof(state->dir_buffer_), "/");
- snprintf(state->sh_buffer_, sizeof(state->sh_buffer_), "/system/bin/sh");
+ snprintf(state->sh_buffer_, sizeof(state->sh_buffer_), "/vendor/bin/sh");
passwd* pw = &state->passwd_;
pw->pw_name = state->name_buffer_;
diff --git a/tests/grp_pwd_test.cpp b/tests/grp_pwd_test.cpp
index 68897ed..24a8648 100644
--- a/tests/grp_pwd_test.cpp
+++ b/tests/grp_pwd_test.cpp
@@ -42,8 +42,9 @@
using android::base::StartsWith;
enum uid_type_t {
+ TYPE_APP,
TYPE_SYSTEM,
- TYPE_APP
+ TYPE_VENDOR,
};
#if defined(__BIONIC__)
@@ -61,12 +62,17 @@
EXPECT_EQ(nullptr, pwd->pw_gecos);
#endif
- if (uid_type == TYPE_SYSTEM) {
- EXPECT_STREQ("/", pwd->pw_dir);
- } else {
+ if (uid_type == TYPE_APP) {
EXPECT_STREQ("/data", pwd->pw_dir);
+ } else {
+ EXPECT_STREQ("/", pwd->pw_dir);
}
- EXPECT_STREQ("/system/bin/sh", pwd->pw_shell);
+
+ if (uid_type == TYPE_VENDOR) {
+ EXPECT_STREQ("/vendor/bin/sh", pwd->pw_shell);
+ } else {
+ EXPECT_STREQ("/system/bin/sh", pwd->pw_shell);
+ }
}
static void check_getpwuid(const char* username, uid_t uid, uid_type_t uid_type,
@@ -155,19 +161,19 @@
}
TEST(pwd, getpwnam_oem_id_5000) {
- check_get_passwd("oem_5000", 5000, TYPE_SYSTEM, false);
+ check_get_passwd("oem_5000", 5000, TYPE_VENDOR, false);
}
TEST(pwd, getpwnam_oem_id_5999) {
- check_get_passwd("oem_5999", 5999, TYPE_SYSTEM, false);
+ check_get_passwd("oem_5999", 5999, TYPE_VENDOR, false);
}
TEST(pwd, getpwnam_oem_id_2900) {
- check_get_passwd("oem_2900", 2900, TYPE_SYSTEM, false);
+ check_get_passwd("oem_2900", 2900, TYPE_VENDOR, false);
}
TEST(pwd, getpwnam_oem_id_2999) {
- check_get_passwd("oem_2999", 2999, TYPE_SYSTEM, false);
+ check_get_passwd("oem_2999", 2999, TYPE_VENDOR, false);
}
TEST(pwd, getpwnam_app_id_nobody) {