am 4d695bf5: Merge "Align struct passwd definition with other variations of libc"

* commit '4d695bf5606f2cf4029a7ff4e6dd61073407d3b0':
  Align struct passwd definition with other variations of libc
This commit is contained in:
Calin Juravle 2014-05-12 09:58:20 +00:00 committed by Android Git Automerger
commit 60e1132460
3 changed files with 17 additions and 8 deletions

View File

@ -89,9 +89,11 @@ static int do_getpw_r(int by_name, const char* name, uid_t uid,
// Copy the strings. // Copy the strings.
snprintf(buf, byte_count, "%s%c%s%c%s", src->pw_name, 0, src->pw_dir, 0, src->pw_shell); snprintf(buf, byte_count, "%s%c%s%c%s", src->pw_name, 0, src->pw_dir, 0, src->pw_shell);
// pw_passwd is non-POSIX and unused (always NULL) in bionic. // pw_passwd and pw_gecos are non-POSIX and unused (always NULL) in bionic.
// pw_gecos is non-POSIX and missing in bionic.
dst->pw_passwd = NULL; dst->pw_passwd = NULL;
#ifdef __LP64__
dst->pw_gecos = NULL;
#endif
// Copy the integral fields. // Copy the integral fields.
dst->pw_gid = src->pw_gid; dst->pw_gid = src->pw_gid;

View File

@ -104,6 +104,9 @@ struct passwd
char* pw_passwd; char* pw_passwd;
uid_t pw_uid; uid_t pw_uid;
gid_t pw_gid; gid_t pw_gid;
#ifdef __LP64__
char* pw_gecos;
#endif
char* pw_dir; char* pw_dir;
char* pw_shell; char* pw_shell;
}; };

View File

@ -41,6 +41,10 @@ static void check_getpwnam(const char* username, uid_t uid, uid_type_t uid_type)
EXPECT_STREQ(username, pwd->pw_name); EXPECT_STREQ(username, pwd->pw_name);
EXPECT_EQ(uid, pwd->pw_uid); EXPECT_EQ(uid, pwd->pw_uid);
EXPECT_EQ(uid, pwd->pw_gid); EXPECT_EQ(uid, pwd->pw_gid);
ASSERT_EQ(NULL, pwd->pw_passwd);
#ifdef __LP64__
ASSERT_EQ(NULL, pwd->pw_gecos);
#endif
if (uid_type == TYPE_SYSTEM) { if (uid_type == TYPE_SYSTEM) {
EXPECT_STREQ("/", pwd->pw_dir); EXPECT_STREQ("/", pwd->pw_dir);