diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 84c1b1531..c7d783b0d 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,9 @@ +2001-04-25 Kazuhiro Fujieda + + * uinfo.cc (internal_getlogin): Return pointer to struct passwd. + (uinfo_init): Accommodate the above change. + * syscalls.cc (seteuid): Ditto. + Tue Apr 25 11:08:00 2001 Corinna Vinschen * autoload.cc: Add LoadDLLfunc statements for SetTokenInformation@16. diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc index 142873b27..bf2400edd 100644 --- a/winsup/cygwin/syscalls.cc +++ b/winsup/cygwin/syscalls.cc @@ -1945,7 +1945,7 @@ setuid (uid_t uid) return ret; } -extern const char *internal_getlogin (cygheap_user &user); +extern struct passwd *internal_getlogin (cygheap_user &user); /* seteuid: standards? */ extern "C" int @@ -2015,7 +2015,7 @@ seteuid (uid_t uid) retrieving user's SID. */ user.token = cygheap->user.impersonated ? cygheap->user.token : INVALID_HANDLE_VALUE; - struct passwd *pw_cur = getpwnam (internal_getlogin (user)); + struct passwd *pw_cur = internal_getlogin (user); if (pw_cur != pw_new) { debug_printf ("Diffs!!! token: %d, cur: %d, new: %d, orig: %d", diff --git a/winsup/cygwin/uinfo.cc b/winsup/cygwin/uinfo.cc index eb3f6ff81..c7b97e374 100644 --- a/winsup/cygwin/uinfo.cc +++ b/winsup/cygwin/uinfo.cc @@ -26,11 +26,12 @@ details. */ #include "registry.h" #include "security.h" -const char * +struct passwd * internal_getlogin (cygheap_user &user) { char username[MAX_USER_NAME]; DWORD username_len = MAX_USER_NAME; + struct passwd *pw = NULL; if (!user.name ()) if (!GetUserName (username, &username_len)) @@ -153,7 +154,6 @@ internal_getlogin (cygheap_user &user) cygsid gsid (NULL); if (ret) { - struct passwd *pw; cygsid psid; if (!strcasematch (user.name (), "SYSTEM") @@ -194,7 +194,7 @@ internal_getlogin (cygheap_user &user) } } debug_printf ("Cygwins Username: %s", user.name ()); - return user.name (); + return pw ?: getpwnam(user.name ()); } void @@ -212,7 +212,7 @@ uinfo_init () /* If uid is USHRT_MAX, the process is started from a non cygwin process or the user context was changed in spawn.cc */ if (myself->uid == USHRT_MAX) - if ((p = getpwnam (internal_getlogin (cygheap->user))) != NULL) + if ((p = internal_getlogin (cygheap->user)) != NULL) { myself->uid = p->pw_uid; /* Set primary group only if ntsec is off or the process has been