Lines Matching refs:pwd

59 static void check_passwd(const passwd* pwd, const char* username, uid_t uid, uid_type_t uid_type,  in check_passwd()  argument
61 ASSERT_TRUE(pwd != nullptr); in check_passwd()
63 EXPECT_STREQ(username, pwd->pw_name); in check_passwd()
65 EXPECT_EQ(uid, pwd->pw_uid); in check_passwd()
66 EXPECT_EQ(uid, pwd->pw_gid); in check_passwd()
67 EXPECT_EQ(nullptr, pwd->pw_passwd); in check_passwd()
69 EXPECT_EQ(nullptr, pwd->pw_gecos); in check_passwd()
73 EXPECT_STREQ("/data", pwd->pw_dir); in check_passwd()
75 EXPECT_STREQ("/", pwd->pw_dir); in check_passwd()
81 EXPECT_STREQ("/bin/sh", pwd->pw_shell); in check_passwd()
88 passwd* pwd = getpwuid(uid); in check_getpwuid() local
91 check_passwd(pwd, username, uid, uid_type, check_username); in check_getpwuid()
97 passwd* pwd = getpwnam(username); in check_getpwnam() local
100 check_passwd(pwd, username, uid, uid_type, check_username); in check_getpwnam()
110 passwd* pwd = nullptr; in check_getpwuid_r() local
111 result = getpwuid_r(uid, &pwd_storage, buf, sizeof(buf), &pwd); in check_getpwuid_r()
115 check_passwd(pwd, username, uid, uid_type, check_username); in check_getpwuid_r()
125 passwd* pwd = nullptr; in check_getpwnam_r() local
126 result = getpwnam_r(username, &pwd_storage, buf, sizeof(buf), &pwd); in check_getpwnam_r()
130 check_passwd(pwd, username, uid, uid_type, check_username); in check_getpwnam_r()
191 TEST(pwd, getpwnam_platform_ids) { in TEST() argument
204 TEST(pwd, getpwnam_oem_ids) { in TEST() argument
213 TEST(pwd, getpwnam_non_exist) { in TEST() argument
231 TEST(pwd, getpwnam_u0_app_ids) { in TEST() argument
241 TEST(pwd, getpwnam_app_id_u1_ids) { in TEST() argument
254 TEST(pwd, getpwnam_app_id_u31_ids) { in TEST() argument
267 TEST(pwd, getpwnam_app_id_not_allowed_platform) { in TEST() argument
275 TEST(pwd, getpwuid_app_id_u1_non_exist) { in TEST() argument
288 TEST(pwd, getpwuid_app_id_u31_non_exist) { in TEST() argument
301 TEST(pwd, getpwnam_r_alignment) { in TEST() argument
305 passwd* pwd; in TEST() local
306 int result = getpwnam_r("root", &pwd_storage, buf + 1, sizeof(buf) - 1, &pwd); in TEST()
308 check_passwd(pwd, "root", 0, TYPE_SYSTEM, true); in TEST()
314 TEST(pwd, getpwuid_r_alignment) { in TEST() argument
318 passwd* pwd; in TEST() local
319 int result = getpwuid_r(0, &pwd_storage, buf + 1, sizeof(buf) - 1, &pwd); in TEST()
321 check_passwd(pwd, "root", 0, TYPE_SYSTEM, true); in TEST()
327 TEST(pwd, getpwnam_r_reentrancy) { in TEST() argument
331 passwd* pwd[3]; in TEST() local
332 int result = getpwnam_r("root", &pwd_storage[0], buf[0], sizeof(buf[0]), &pwd[0]); in TEST()
334 check_passwd(pwd[0], "root", 0, TYPE_SYSTEM, true); in TEST()
335 pwd[1] = getpwnam("system"); in TEST()
336 ASSERT_NE(nullptr, pwd[1]); in TEST()
337 check_passwd(pwd[1], "system", 1000, TYPE_SYSTEM, true); in TEST()
338 result = getpwnam_r("radio", &pwd_storage[1], buf[1], sizeof(buf[1]), &pwd[2]); in TEST()
340 check_passwd(pwd[2], "radio", 1001, TYPE_SYSTEM, true); in TEST()
341 check_passwd(pwd[0], "root", 0, TYPE_SYSTEM, true); in TEST()
342 check_passwd(pwd[1], "system", 1000, TYPE_SYSTEM, true); in TEST()
348 TEST(pwd, getpwuid_r_reentrancy) { in TEST() argument
352 passwd* pwd[3]; in TEST() local
353 int result = getpwuid_r(0, &pwd_storage[0], buf[0], sizeof(buf[0]), &pwd[0]); in TEST()
355 check_passwd(pwd[0], "root", 0, TYPE_SYSTEM, true); in TEST()
356 pwd[1] = getpwuid(1000); in TEST()
357 ASSERT_NE(nullptr, pwd[1]); in TEST()
358 check_passwd(pwd[1], "system", 1000, TYPE_SYSTEM, true); in TEST()
359 result = getpwuid_r(1001, &pwd_storage[1], buf[1], sizeof(buf[1]), &pwd[2]); in TEST()
361 check_passwd(pwd[2], "radio", 1001, TYPE_SYSTEM, true); in TEST()
362 check_passwd(pwd[0], "root", 0, TYPE_SYSTEM, true); in TEST()
363 check_passwd(pwd[1], "system", 1000, TYPE_SYSTEM, true); in TEST()
369 TEST(pwd, getpwnam_r_large_enough_suggested_buffer_size) { in TEST() argument
375 passwd* pwd; in TEST() local
376 ASSERT_EQ(0, getpwnam_r("root", &pwd_storage, buf, size, &pwd)); in TEST()
377 check_passwd(pwd, "root", 0, TYPE_SYSTEM, true); in TEST()
448 TEST(pwd, getpwent_iterate) { in TEST() argument
450 passwd* pwd; in TEST() local
454 while ((pwd = getpwent()) != nullptr) { in TEST()
455 ASSERT_TRUE(nullptr != pwd->pw_name); in TEST()
457 EXPECT_EQ(pwd->pw_gid, pwd->pw_uid) << "pwd->pw_uid: " << pwd->pw_uid; in TEST()
458 EXPECT_EQ(nullptr, pwd->pw_passwd) << "pwd->pw_uid: " << pwd->pw_uid; in TEST()
460 EXPECT_TRUE(nullptr == pwd->pw_gecos) << "pwd->pw_uid: " << pwd->pw_uid; in TEST()
462 EXPECT_TRUE(nullptr != pwd->pw_shell); in TEST()
463 if (pwd->pw_uid < AID_APP_START || pwd->pw_uid == AID_OVERFLOWUID) { in TEST()
464 EXPECT_STREQ("/", pwd->pw_dir) << "pwd->pw_uid: " << pwd->pw_uid; in TEST()
466 EXPECT_STREQ("/data", pwd->pw_dir) << "pwd->pw_uid: " << pwd->pw_uid; in TEST()
469 EXPECT_EQ(0U, uids.count(pwd->pw_uid)) << "pwd->pw_uid: " << pwd->pw_uid; in TEST()
470 uids.emplace(pwd->pw_uid); in TEST()
840 TEST(pwd, vendor_prefix_users) { in TEST() argument
852 TEST(pwd, vendor_prefix_groups) { in TEST() argument