Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/winsup
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2010-09-28 18:40:18 +0400
committerCorinna Vinschen <corinna@vinschen.de>2010-09-28 18:40:18 +0400
commit2f1f8815c037ee0387c30fba98689e544ab75c9a (patch)
tree58a54bb45cbd833ed7169a8669005e7468dbb1ec /winsup
parent91e0b943a07e768bbdcd7d8da2b991eee41fc0c4 (diff)
* Makefile.in (DLL_IMPORTS): Remove libadvapi32.a.
* autoload.cc: Add all advapi32 entry points. * mount.cc (mount_info::init): Read user fstab only if we have a username. * passwd.cc (pwdgrp::read_passwd): Only use username if we have one. * shared.cc (user_info::initialize): Set cb last so as not to override planned behaviour in pwdgrp::read_passwd. * uinfo.cc (cygheap_user::init): Fetch Windows username from environment variable $USERNAME. Don't set name in cygheap if variable is empty. (internal_getlogin): If we still have no username, try GetUserNameW.
Diffstat (limited to 'winsup')
-rw-r--r--winsup/cygwin/ChangeLog13
-rw-r--r--winsup/cygwin/Makefile.in2
-rw-r--r--winsup/cygwin/autoload.cc71
-rw-r--r--winsup/cygwin/mount.cc3
-rw-r--r--winsup/cygwin/passwd.cc5
-rw-r--r--winsup/cygwin/shared.cc2
-rw-r--r--winsup/cygwin/uinfo.cc41
7 files changed, 122 insertions, 15 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index 620e512bc..480220115 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,5 +1,18 @@
2010-09-28 Corinna Vinschen <corinna@vinschen.de>
+ * Makefile.in (DLL_IMPORTS): Remove libadvapi32.a.
+ * autoload.cc: Add all advapi32 entry points.
+ * mount.cc (mount_info::init): Read user fstab only if we have a
+ username.
+ * passwd.cc (pwdgrp::read_passwd): Only use username if we have one.
+ * shared.cc (user_info::initialize): Set cb last so as not to override
+ planned behaviour in pwdgrp::read_passwd.
+ * uinfo.cc (cygheap_user::init): Fetch Windows username from environment
+ variable $USERNAME. Don't set name in cygheap if variable is empty.
+ (internal_getlogin): If we still have no username, try GetUserNameW.
+
+2010-09-28 Corinna Vinschen <corinna@vinschen.de>
+
* fhandler_tty.cc (fhandler_pty_master::setup): Always create master
thread.
diff --git a/winsup/cygwin/Makefile.in b/winsup/cygwin/Makefile.in
index 10743eab8..558b8f161 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)/libadvapi32.a $(w32api_lib)/libkernel32.a $(w32api_lib)/libntdll.a
+DLL_IMPORTS:=$(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 c034db51f..c03e4cdf8 100644
--- a/winsup/cygwin/autoload.cc
+++ b/winsup/cygwin/autoload.cc
@@ -305,6 +305,77 @@ 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 b862b5b17..95494c53f 100644
--- a/winsup/cygwin/mount.cc
+++ b/winsup/cygwin/mount.cc
@@ -467,7 +467,8 @@ mount_info::init ()
pathend = wcpcpy (pathend, L"\\etc\\fstab");
from_fstab (false, path, pathend);
- from_fstab (true, path, pathend);
+ if (cygheap->user.name () && *cygheap->user.name ())
+ 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 8c51c22a0..23756241a 100644
--- a/winsup/cygwin/passwd.cc
+++ b/winsup/cygwin/passwd.cc
@@ -66,7 +66,8 @@ pwdgrp::read_passwd ()
if (!user_shared->cb || myself->uid == ILLEGAL_UID)
searchentry = !internal_getpwsid (tu);
if (searchentry
- && (!(pw = internal_getpwnam (cygheap->user.name ()))
+ && (!cygheap->user.name ()
+ || !(pw = internal_getpwnam (cygheap->user.name ()))
|| !user_shared->cb
|| (myself->uid != ILLEGAL_UID
&& myself->uid != (__uid32_t) pw->pw_uid
@@ -75,7 +76,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 10d03b088..5118b432b 100644
--- a/winsup/cygwin/shared.cc
+++ b/winsup/cygwin/shared.cc
@@ -312,7 +312,6 @@ 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
@@ -320,6 +319,7 @@ 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 60db38e76..8ea3e1ab0 100644
--- a/winsup/cygwin/uinfo.cc
+++ b/winsup/cygwin/uinfo.cc
@@ -38,14 +38,16 @@ void
cygheap_user::init ()
{
WCHAR user_name[UNLEN + 1];
- DWORD user_name_len = UNLEN + 1;
+ DWORD user_name_len;
- 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);
+ 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);
+ }
DWORD siz;
PSECURITY_DESCRIPTOR psd;
@@ -96,10 +98,29 @@ internal_getlogin (cygheap_user &user)
{
struct passwd *pw = NULL;
- cygpsid psid = user.sid ();
- pw = internal_getpwsid (psid);
+ /* 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;
+
+ 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 ()))
+ if (!pw && !(pw = internal_getpwnam (user.name (), true))
&& !(pw = internal_getpwuid (DEFAULT_UID)))
debug_printf ("user not found in augmented /etc/passwd");
else