Lines Matching refs:pwd
61 static void check_passwd(const passwd* pwd, const char* username, uid_t uid, uid_type_t uid_type, in check_passwd() argument
63 ASSERT_TRUE(pwd != nullptr); in check_passwd()
65 EXPECT_STREQ(username, pwd->pw_name); in check_passwd()
67 EXPECT_EQ(uid, pwd->pw_uid); in check_passwd()
68 EXPECT_EQ(uid, pwd->pw_gid); in check_passwd()
69 EXPECT_EQ(nullptr, pwd->pw_passwd); in check_passwd()
71 EXPECT_EQ(nullptr, pwd->pw_gecos); in check_passwd()
75 EXPECT_STREQ("/data", pwd->pw_dir); in check_passwd()
77 EXPECT_STREQ("/", pwd->pw_dir); in check_passwd()
83 EXPECT_STREQ("/bin/sh", pwd->pw_shell); in check_passwd()
90 passwd* pwd = getpwuid(uid); in check_getpwuid() local
93 check_passwd(pwd, username, uid, uid_type, check_username); in check_getpwuid()
99 passwd* pwd = getpwnam(username); in check_getpwnam() local
102 check_passwd(pwd, username, uid, uid_type, check_username); in check_getpwnam()
112 passwd* pwd = nullptr; in check_getpwuid_r() local
113 result = getpwuid_r(uid, &pwd_storage, buf, sizeof(buf), &pwd); in check_getpwuid_r()
117 check_passwd(pwd, username, uid, uid_type, check_username); in check_getpwuid_r()
127 passwd* pwd = nullptr; in check_getpwnam_r() local
128 result = getpwnam_r(username, &pwd_storage, buf, sizeof(buf), &pwd); in check_getpwnam_r()
132 check_passwd(pwd, username, uid, uid_type, check_username); in check_getpwnam_r()
193 TEST(pwd, getpwnam_platform_ids) { in TEST() argument
206 TEST(pwd, getpwnam_oem_ids) { in TEST() argument
215 TEST(pwd, getpwnam_non_exist) { in TEST() argument
233 TEST(pwd, getpwnam_u0_app_ids) { in TEST() argument
243 TEST(pwd, getpwnam_app_id_u1_ids) { in TEST() argument
256 TEST(pwd, getpwnam_app_id_u31_ids) { in TEST() argument
269 TEST(pwd, getpwnam_app_id_not_allowed_platform) { in TEST() argument
277 TEST(pwd, getpwuid_app_id_u1_non_exist) { in TEST() argument
290 TEST(pwd, getpwuid_app_id_u31_non_exist) { in TEST() argument
303 TEST(pwd, getpwnam_r_alignment) { in TEST() argument
307 passwd* pwd; in TEST() local
308 int result = getpwnam_r("root", &pwd_storage, buf + 1, sizeof(buf) - 1, &pwd); in TEST()
310 check_passwd(pwd, "root", 0, TYPE_SYSTEM, true); in TEST()
316 TEST(pwd, getpwuid_r_alignment) { in TEST() argument
320 passwd* pwd; in TEST() local
321 int result = getpwuid_r(0, &pwd_storage, buf + 1, sizeof(buf) - 1, &pwd); in TEST()
323 check_passwd(pwd, "root", 0, TYPE_SYSTEM, true); in TEST()
329 TEST(pwd, getpwnam_r_reentrancy) { in TEST() argument
333 passwd* pwd[3]; in TEST() local
334 int result = getpwnam_r("root", &pwd_storage[0], buf[0], sizeof(buf[0]), &pwd[0]); in TEST()
336 check_passwd(pwd[0], "root", 0, TYPE_SYSTEM, true); in TEST()
337 pwd[1] = getpwnam("system"); in TEST()
338 ASSERT_NE(nullptr, pwd[1]); in TEST()
339 check_passwd(pwd[1], "system", 1000, TYPE_SYSTEM, true); in TEST()
340 result = getpwnam_r("radio", &pwd_storage[1], buf[1], sizeof(buf[1]), &pwd[2]); in TEST()
342 check_passwd(pwd[2], "radio", 1001, TYPE_SYSTEM, true); in TEST()
343 check_passwd(pwd[0], "root", 0, TYPE_SYSTEM, true); in TEST()
344 check_passwd(pwd[1], "system", 1000, TYPE_SYSTEM, true); in TEST()
350 TEST(pwd, getpwuid_r_reentrancy) { in TEST() argument
354 passwd* pwd[3]; in TEST() local
355 int result = getpwuid_r(0, &pwd_storage[0], buf[0], sizeof(buf[0]), &pwd[0]); in TEST()
357 check_passwd(pwd[0], "root", 0, TYPE_SYSTEM, true); in TEST()
358 pwd[1] = getpwuid(1000); in TEST()
359 ASSERT_NE(nullptr, pwd[1]); in TEST()
360 check_passwd(pwd[1], "system", 1000, TYPE_SYSTEM, true); in TEST()
361 result = getpwuid_r(1001, &pwd_storage[1], buf[1], sizeof(buf[1]), &pwd[2]); in TEST()
363 check_passwd(pwd[2], "radio", 1001, TYPE_SYSTEM, true); in TEST()
364 check_passwd(pwd[0], "root", 0, TYPE_SYSTEM, true); in TEST()
365 check_passwd(pwd[1], "system", 1000, TYPE_SYSTEM, true); in TEST()
371 TEST(pwd, getpwnam_r_large_enough_suggested_buffer_size) { in TEST() argument
377 passwd* pwd; in TEST() local
378 ASSERT_EQ(0, getpwnam_r("root", &pwd_storage, buf, size, &pwd)); in TEST()
379 check_passwd(pwd, "root", 0, TYPE_SYSTEM, true); in TEST()
478 TEST(pwd, getpwent_iterate) { in TEST() argument
480 passwd* pwd; in TEST() local
484 while ((pwd = getpwent()) != nullptr) { in TEST()
485 ASSERT_TRUE(nullptr != pwd->pw_name); in TEST()
487 EXPECT_EQ(pwd->pw_gid, pwd->pw_uid) << "pwd->pw_uid: " << pwd->pw_uid; in TEST()
488 EXPECT_EQ(nullptr, pwd->pw_passwd) << "pwd->pw_uid: " << pwd->pw_uid; in TEST()
490 EXPECT_TRUE(nullptr == pwd->pw_gecos) << "pwd->pw_uid: " << pwd->pw_uid; in TEST()
492 EXPECT_TRUE(nullptr != pwd->pw_shell); in TEST()
493 if (pwd->pw_uid < AID_APP_START || pwd->pw_uid == AID_OVERFLOWUID) { in TEST()
494 EXPECT_STREQ("/", pwd->pw_dir) << "pwd->pw_uid: " << pwd->pw_uid; in TEST()
496 EXPECT_STREQ("/data", pwd->pw_dir) << "pwd->pw_uid: " << pwd->pw_uid; in TEST()
499 EXPECT_EQ(0U, uids.count(pwd->pw_uid)) << "pwd->pw_uid: " << pwd->pw_uid; in TEST()
500 uids.emplace(pwd->pw_uid); in TEST()
893 TEST(pwd, vendor_prefix_users) { in TEST() argument
905 TEST(pwd, vendor_prefix_groups) { in TEST() argument