Skip to content

Commit

Permalink
Fix issue #1003 (missing pw_gecos)
Browse files Browse the repository at this point in the history
Signed-off-by: Dmitry Moskalchuk <dm@crystax.net>
  • Loading branch information
dmsck committed Oct 6, 2015
1 parent 051cc6b commit f6048d4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
12 changes: 11 additions & 1 deletion libc/bionic/stubs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,12 @@ static int do_getpw_r(int by_name, const char* name, uid_t uid,

// pw_passwd and pw_gecos are non-POSIX and unused (always NULL) in bionic.
dst->pw_passwd = NULL;
#if defined(__CRYSTAX__)
dst->pw_gecos = src->pw_name;
#else
#if defined(__LP64__)
dst->pw_gecos = NULL;
#endif
#endif

// Copy the integral fields.
Expand Down Expand Up @@ -151,6 +155,9 @@ static passwd* android_iinfo_to_passwd(passwd_state_t* state,
pw->pw_gid = iinfo->aid;
pw->pw_dir = state->dir_buffer_;
pw->pw_shell = state->sh_buffer_;
#if defined(__CRYSTAX__)
pw->pw_gecos = pw->pw_name;
#endif
return pw;
}

Expand Down Expand Up @@ -319,7 +326,7 @@ static void print_app_name_from_gid(const gid_t gid, char* buffer, const int buf
// AID_USER+ -> u1_radio, u1_a1234, u2_i1234, etc.
// returns a passwd structure (sets errno to ENOENT on failure).
static passwd* app_id_to_passwd(uid_t uid, passwd_state_t* state) {
if (uid < AID_APP) {
if (uid < AID_APP || uid == (uid_t)-1) {
errno = ENOENT;
return NULL;
}
Expand All @@ -341,6 +348,9 @@ static passwd* app_id_to_passwd(uid_t uid, passwd_state_t* state) {
pw->pw_shell = state->sh_buffer_;
pw->pw_uid = uid;
pw->pw_gid = uid;
#if defined(__CRYSTAX__)
pw->pw_gecos = pw->pw_name;
#endif
return pw;
}

Expand Down
8 changes: 7 additions & 1 deletion libc/include/pwd.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ struct passwd
char* pw_passwd;
uid_t pw_uid;
gid_t pw_gid;
#ifdef __LP64__
#if defined(__LP64__) || defined(__CRYSTAX__)
char* pw_gecos;
#endif
char* pw_dir;
Expand All @@ -119,6 +119,12 @@ struct passwd* getpwuid(uid_t);
int getpwnam_r(const char*, struct passwd*, char*, size_t, struct passwd**);
int getpwuid_r(uid_t, struct passwd*, char*, size_t, struct passwd**);

#if defined(__CRYSTAX__)
struct passwd *getpwent(void);
void endpwent(void);
void setpwent(void);
#endif /* __CRYSTAX__ */

__END_DECLS

#endif

0 comments on commit f6048d4

Please sign in to comment.