This is the mail archive of the
cygwin-patches@cygwin.com
mailing list for the Cygwin project.
Re: Small security patches
Corinna,
Until the initialization issue is settled, here is a patch covering
only the internationalization of security.cc
It should go in the next cygwin, and I always prefer when there
is a sufficiently long bake time.
Pierre
2002/12/13 Pierre Humblet <pierre.humblet@ieee.org>
* security.cc (get_user_local_groups): Use LookupAccountSid to find the
local equivalent of BUILTIN.
Index: security.cc
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/security.cc,v
retrieving revision 1.128
diff -u -p -r1.128 security.cc
--- security.cc 10 Dec 2002 12:43:49 -0000 1.128
+++ security.cc 13 Dec 2002 02:35:32 -0000
@@ -389,16 +389,19 @@ get_user_local_groups (cygsidlist &grp_l
return FALSE;
}
- char bgroup[sizeof ("BUILTIN\\") + GNLEN] = "BUILTIN\\";
+ char bgroup[INTERNET_MAX_HOST_NAME_LENGTH + GNLEN + 2];
char lgroup[INTERNET_MAX_HOST_NAME_LENGTH + GNLEN + 2];
- const DWORD blen = sizeof ("BUILTIN\\") - 1;
- DWORD llen = INTERNET_MAX_HOST_NAME_LENGTH + 1;
- if (!GetComputerNameA (lgroup, &llen))
+ DWORD blen, llen;
+ SID_NAME_USE use;
+
+ blen = llen = INTERNET_MAX_HOST_NAME_LENGTH + 1;
+ if (!LookupAccountSid (NULL, well_known_admins_sid, lgroup, &llen, bgroup, &blen, &use)
+ || !GetComputerNameA (lgroup, &(llen = INTERNET_MAX_HOST_NAME_LENGTH + 1)))
{
__seterrno ();
return FALSE;
}
- lgroup[llen++] = '\\';
+ bgroup[blen++] = lgroup[llen++] = '\\';
for (DWORD i = 0; i < cnt; ++i)
if (is_group_member (buf[i].lgrpi0_name, pusersid, grp_list))
@@ -407,8 +410,8 @@ get_user_local_groups (cygsidlist &grp_l
DWORD glen = sizeof (gsid);
char domain[INTERNET_MAX_HOST_NAME_LENGTH + 1];
DWORD dlen = sizeof (domain);
- SID_NAME_USE use = SidTypeInvalid;
+ use = SidTypeInvalid;
sys_wcstombs (bgroup + blen, buf[i].lgrpi0_name, GNLEN + 1);
if (!LookupAccountName (NULL, bgroup, gsid, &glen, domain, &dlen, &use))
{