* uinfo.cc (cygheap_user::env_domain): Use LookupAccountSidW and

convert user and domain to multibyte strings to make sure to use
	correct codeset.
This commit is contained in:
Corinna Vinschen 2011-03-29 10:46:04 +00:00
parent 5f660ecf24
commit 91d3057085
2 changed files with 15 additions and 9 deletions

View File

@ -1,3 +1,9 @@
2011-03-29 Corinna Vinschen <corinna@vinschen.de>
* uinfo.cc (cygheap_user::env_domain): Use LookupAccountSidW and
convert user and domain to multibyte strings to make sure to use
correct codeset.
2011-03-29 Corinna Vinschen <corinna@vinschen.de>
* autoload.cc (UuidCreate): Remove.

View File

@ -1,7 +1,7 @@
/* uinfo.cc: user info (uid, gid, etc...)
Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
2006, 2007, 2008 Red Hat, Inc.
2006, 2007, 2008, 2009, 2010, 2011 Red Hat, Inc.
This file is part of Cygwin.
@ -382,21 +382,21 @@ cygheap_user::env_domain (const char *name, size_t namelen)
if (pwinname && test_uid (pdomain, name, namelen))
return pdomain;
char username[UNLEN + 1];
DWORD ulen = sizeof (username);
char userdomain[DNLEN + 1];
DWORD dlen = sizeof (userdomain);
DWORD ulen = UNLEN + 1;
WCHAR username[ulen];
DWORD dlen = DNLEN + 1;
WCHAR userdomain[dlen];
SID_NAME_USE use;
cfree_and_set (pwinname, almost_null);
cfree_and_set (pdomain, almost_null);
if (!LookupAccountSid (NULL, sid (), username, &ulen,
userdomain, &dlen, &use))
if (!LookupAccountSidW (NULL, sid (), username, &ulen,
userdomain, &dlen, &use))
__seterrno ();
else
{
pwinname = cstrdup (username);
pdomain = cstrdup (userdomain);
sys_wcstombs_alloc (&pwinname, HEAP_STR, username);
sys_wcstombs_alloc (&pdomain, HEAP_STR, userdomain);
}
return pdomain;
}