From 2a9b4b7aa07c166beca1c37d2ba7faa22feca33f Mon Sep 17 00:00:00 2001 From: Corinna Vinschen Date: Tue, 28 Sep 2010 14:49:31 +0000 Subject: [PATCH] Revert accidental previous login. --- winsup/cygwin/ChangeLog | 4 +++ winsup/cygwin/Makefile.in | 2 +- winsup/cygwin/autoload.cc | 71 --------------------------------------- winsup/cygwin/mount.cc | 3 +- winsup/cygwin/passwd.cc | 5 ++- winsup/cygwin/shared.cc | 2 +- winsup/cygwin/uinfo.cc | 41 ++++++---------------- 7 files changed, 19 insertions(+), 109 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 480220115..d260e2d69 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,7 @@ +2010-09-28 Corinna Vinschen + + Revert accidental previous login. + 2010-09-28 Corinna Vinschen * Makefile.in (DLL_IMPORTS): Remove libadvapi32.a. diff --git a/winsup/cygwin/Makefile.in b/winsup/cygwin/Makefile.in index 558b8f161..10743eab8 100644 --- a/winsup/cygwin/Makefile.in +++ b/winsup/cygwin/Makefile.in @@ -130,7 +130,7 @@ EXTRA_OFILES:= MALLOC_OFILES:=@MALLOC_OFILES@ -DLL_IMPORTS:=$(w32api_lib)/libkernel32.a $(w32api_lib)/libntdll.a +DLL_IMPORTS:=$(w32api_lib)/libadvapi32.a $(w32api_lib)/libkernel32.a $(w32api_lib)/libntdll.a MT_SAFE_OBJECTS:= # Please maintain this list in sorted order, with maximum files per 86 col line diff --git a/winsup/cygwin/autoload.cc b/winsup/cygwin/autoload.cc index c03e4cdf8..c034db51f 100644 --- a/winsup/cygwin/autoload.cc +++ b/winsup/cygwin/autoload.cc @@ -305,77 +305,6 @@ wsock_init () LoadDLLprime (ws2_32, _wsock_init) -LoadDLLfunc (AccessCheck, 32, advapi32) -LoadDLLfunc (AddAccessAllowedAce, 16, advapi32) -LoadDLLfunc (AddAccessDeniedAce, 16, advapi32) -LoadDLLfunc (AddAce, 20, advapi32) -LoadDLLfunc (AllocateLocallyUniqueId, 4, advapi32) -LoadDLLfunc (CopySid, 12, advapi32) -LoadDLLfunc (CreateProcessAsUserW, 44, advapi32) -LoadDLLfunc (CryptAcquireContextA, 20, advapi32) -LoadDLLfunc (CryptGenRandom, 12, advapi32) -LoadDLLfunc (CryptReleaseContext, 8, advapi32) -LoadDLLfunc (DeregisterEventSource, 4, advapi32) -LoadDLLfunc (DuplicateTokenEx, 24, advapi32) -LoadDLLfunc (EqualPrefixSid, 8, advapi32) -LoadDLLfunc (EqualSid, 8, advapi32) -LoadDLLfunc (FindFirstFreeAce, 8, advapi32) -LoadDLLfunc (GetAce, 12, advapi32) -LoadDLLfunc (GetKernelObjectSecurity, 20, advapi32) -LoadDLLfunc (GetLengthSid, 4, advapi32) -LoadDLLfunc (GetSecurityDescriptorDacl, 16, advapi32) -LoadDLLfunc (GetSecurityDescriptorGroup, 12, advapi32) -LoadDLLfunc (GetSecurityDescriptorOwner, 12, advapi32) -LoadDLLfunc (GetSecurityInfo, 32, advapi32) -LoadDLLfunc (GetSidIdentifierAuthority, 4, advapi32) -LoadDLLfunc (GetSidSubAuthority, 8, advapi32) -LoadDLLfunc (GetSidSubAuthorityCount, 4, advapi32) -LoadDLLfunc (GetTokenInformation, 20, advapi32) -LoadDLLfunc (GetUserNameW, 8, advapi32) -LoadDLLfunc (ImpersonateLoggedOnUser, 4, advapi32) -LoadDLLfunc (ImpersonateNamedPipeClient, 4, advapi32) -LoadDLLfunc (InitializeAcl, 12, advapi32) -LoadDLLfunc (InitializeSecurityDescriptor, 8, advapi32) -LoadDLLfunc (InitializeSid, 12, advapi32) -LoadDLLfunc (LogonUserW, 24, advapi32) -LoadDLLfunc (LookupAccountNameW, 28, advapi32) -LoadDLLfunc (LookupAccountSidA, 28, advapi32) -LoadDLLfunc (LookupAccountSidW, 28, advapi32) -LoadDLLfunc (LsaClose, 4, advapi32) -LoadDLLfunc (LsaEnumerateAccountRights, 16, advapi32) -LoadDLLfunc (LsaFreeMemory, 4, advapi32) -LoadDLLfunc (LsaNtStatusToWinError, 4, advapi32) -LoadDLLfunc (LsaOpenPolicy, 16, advapi32) -LoadDLLfunc (LsaRetrievePrivateData, 12, advapi32) -LoadDLLfunc (LsaStorePrivateData, 12, advapi32) -LoadDLLfunc (MakeSelfRelativeSD, 12, advapi32) -LoadDLLfunc (OpenProcessToken, 12, advapi32) -LoadDLLfunc (OpenThreadToken, 16, advapi32) -LoadDLLfunc (PrivilegeCheck, 12, advapi32) -LoadDLLfunc (RegCloseKey, 4, advapi32) -LoadDLLfunc (RegCreateKeyExA, 36, advapi32) -LoadDLLfunc (RegCreateKeyExW, 36, advapi32) -LoadDLLfunc (RegDeleteKeyA, 8, advapi32) -LoadDLLfunc (RegDeleteValueA, 8, advapi32) -LoadDLLfunc (RegEnumKeyExW, 32, advapi32) -LoadDLLfunc (RegEnumValueW, 32, advapi32) -LoadDLLfunc (RegGetKeySecurity, 16, advapi32) -LoadDLLfunc (RegLoadKeyW, 12, advapi32) -LoadDLLfunc (RegOpenKeyExA, 20, advapi32) -LoadDLLfunc (RegOpenKeyExW, 20, advapi32) -LoadDLLfunc (RegQueryInfoKeyA, 48, advapi32) -LoadDLLfunc (RegQueryValueExA, 24, advapi32) -LoadDLLfunc (RegQueryValueExW, 24, advapi32) -LoadDLLfunc (RegSetValueExA, 24, advapi32) -LoadDLLfunc (RegSetValueExW, 24, advapi32) -LoadDLLfunc (RegisterEventSourceA, 8, advapi32) -LoadDLLfunc (ReportEventA, 36, advapi32) -LoadDLLfunc (RevertToSelf, 0, advapi32) -LoadDLLfunc (SetSecurityDescriptorDacl, 16, advapi32) -LoadDLLfunc (SetSecurityDescriptorGroup, 12, advapi32) -LoadDLLfunc (SetSecurityDescriptorOwner, 12, advapi32) -LoadDLLfunc (SetTokenInformation, 16, advapi32) - LoadDLLfuncEx2 (DnsQuery_A, 24, dnsapi, 1, 127) // ERROR_PROC_NOT_FOUND LoadDLLfuncEx (DnsRecordListFree, 8, dnsapi, 1) diff --git a/winsup/cygwin/mount.cc b/winsup/cygwin/mount.cc index 95494c53f..b862b5b17 100644 --- a/winsup/cygwin/mount.cc +++ b/winsup/cygwin/mount.cc @@ -467,8 +467,7 @@ mount_info::init () pathend = wcpcpy (pathend, L"\\etc\\fstab"); from_fstab (false, path, pathend); - if (cygheap->user.name () && *cygheap->user.name ()) - from_fstab (true, path, pathend); + from_fstab (true, path, pathend); if (!got_usr_bin || !got_usr_lib) { diff --git a/winsup/cygwin/passwd.cc b/winsup/cygwin/passwd.cc index 23756241a..8c51c22a0 100644 --- a/winsup/cygwin/passwd.cc +++ b/winsup/cygwin/passwd.cc @@ -66,8 +66,7 @@ pwdgrp::read_passwd () if (!user_shared->cb || myself->uid == ILLEGAL_UID) searchentry = !internal_getpwsid (tu); if (searchentry - && (!cygheap->user.name () - || !(pw = internal_getpwnam (cygheap->user.name ())) + && (!(pw = internal_getpwnam (cygheap->user.name ())) || !user_shared->cb || (myself->uid != ILLEGAL_UID && myself->uid != (__uid32_t) pw->pw_uid @@ -76,7 +75,7 @@ pwdgrp::read_passwd () static char linebuf[1024]; // must be static and // should not be NO_COPY snprintf (linebuf, sizeof (linebuf), "%s:*:%lu:%lu:,%s:%s:/bin/sh", - cygheap->user.name () ?: "", + cygheap->user.name (), (!user_shared->cb || myself->uid == ILLEGAL_UID) ? UNKNOWN_UID : myself->uid, !user_shared->cb ? UNKNOWN_GID : myself->gid, diff --git a/winsup/cygwin/shared.cc b/winsup/cygwin/shared.cc index 5118b432b..10d03b088 100644 --- a/winsup/cygwin/shared.cc +++ b/winsup/cygwin/shared.cc @@ -312,6 +312,7 @@ user_info::initialize () spinlock sversion (version, CURR_USER_MAGIC); if (!sversion) { + cb = sizeof (*user_shared); cygpsid sid (cygheap->user.sid ()); struct passwd *pw = internal_getpwsid (sid); /* Correct the user name with what's defined in /etc/passwd before @@ -319,7 +320,6 @@ user_info::initialize () if (pw) cygheap->user.set_name (pw->pw_name); mountinfo.init (); /* Initialize the mount table. */ - cb = sizeof (*user_shared); } else if (sversion != CURR_USER_MAGIC) sversion.multiple_cygwin_problem ("user shared memory version", version, diff --git a/winsup/cygwin/uinfo.cc b/winsup/cygwin/uinfo.cc index 8ea3e1ab0..60db38e76 100644 --- a/winsup/cygwin/uinfo.cc +++ b/winsup/cygwin/uinfo.cc @@ -38,16 +38,14 @@ void cygheap_user::init () { WCHAR user_name[UNLEN + 1]; - DWORD user_name_len; + DWORD user_name_len = UNLEN + 1; - user_name_len = GetEnvironmentVariableW (L"USERNAME", user_name, UNLEN + 1); - if (user_name_len) - { - user_name[UNLEN] = L'\0'; - char mb_user_name[user_name_len = sys_wcstombs (NULL, 0, user_name)]; - sys_wcstombs (mb_user_name, user_name_len, user_name); - set_name (mb_user_name); - } + if (!GetUserNameW (user_name, &user_name_len)) + wcpcpy (user_name, L"unknown"); + + char mb_user_name[user_name_len = sys_wcstombs (NULL, 0, user_name)]; + sys_wcstombs (mb_user_name, user_name_len, user_name); + set_name (mb_user_name); DWORD siz; PSECURITY_DESCRIPTOR psd; @@ -98,29 +96,10 @@ internal_getlogin (cygheap_user &user) { struct passwd *pw = NULL; - /* Handle a border case. If neither $USERNAME, nor /etc/passwd exists, - we tryto fetch the username from the system now. */ - if (!user.name () || !*user.name ()) - { - WCHAR user_name[UNLEN + 1]; - DWORD user_name_len = UNLEN + 1; + cygpsid psid = user.sid (); + pw = internal_getpwsid (psid); - if (GetUserNameW (user_name, &user_name_len)) - { - char mb_user_name[user_name_len = sys_wcstombs (NULL, 0, user_name)]; - sys_wcstombs (mb_user_name, user_name_len, user_name); - user.set_name (mb_user_name); - } - else - user.set_name ("unknown"); - } - else - { - cygpsid psid = user.sid (); - pw = internal_getpwsid (psid); - } - - if (!pw && !(pw = internal_getpwnam (user.name (), true)) + if (!pw && !(pw = internal_getpwnam (user.name ())) && !(pw = internal_getpwuid (DEFAULT_UID))) debug_printf ("user not found in augmented /etc/passwd"); else