From 8ec5da1ff6c169f34f9d85d98129814fb40dd4f8 Mon Sep 17 00:00:00 2001 From: Corinna Vinschen Date: Mon, 23 Feb 2009 18:27:48 +0000 Subject: * sec_auth.cc (get_user_local_groups): Simplify LookupAccountName code. --- winsup/cygwin/ChangeLog | 4 ++++ winsup/cygwin/sec_auth.cc | 33 ++++++++++++++++++++------------- 2 files changed, 24 insertions(+), 13 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 586412d..377337a 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,7 @@ +2009-02-23 Corinna Vinschen + + * sec_auth.cc (get_user_local_groups): Simplify LookupAccountName code. + 2009-02-20 Corinna Vinschen * autoload.cc (NetLocalGroupEnum): Remove. diff --git a/winsup/cygwin/sec_auth.cc b/winsup/cygwin/sec_auth.cc index f39b663..23bda8a 100644 --- a/winsup/cygwin/sec_auth.cc +++ b/winsup/cygwin/sec_auth.cc @@ -297,27 +297,34 @@ get_user_local_groups (PWCHAR logonserver, PWCHAR domain, DWORD glen = MAX_SID_LEN; WCHAR dom[MAX_DOMAIN_NAME_LEN + 1]; DWORD domlen = sizeof (dom); - bool builtin = false; use = SidTypeInvalid; wcscpy (dg_ptr, buf[i].lgrpi0_name); - if (!LookupAccountNameW (NULL, domlocal_grp, gsid, &glen, - dom, &domlen, &use)) + if (LookupAccountNameW (NULL, domlocal_grp, gsid, &glen, + dom, &domlen, &use)) { - if (GetLastError () != ERROR_NONE_MAPPED) - debug_printf ("LookupAccountName(%W), %E", domlocal_grp); + if (!legal_sid_type (use)) + debug_printf ("Rejecting local %W. use: %d", dg_ptr, use); + else + grp_list += gsid; + } + else if (GetLastError () == ERROR_NONE_MAPPED) + { + /* Check if it's a builtin group. */ wcscpy (bg_ptr, dg_ptr); - if (!LookupAccountNameW (NULL, builtin_grp, gsid, &glen, - dom, &domlen, &use)) + if (LookupAccountNameW (NULL, builtin_grp, gsid, &glen, + dom, &domlen, &use)) + { + if (!legal_sid_type (use)) + debug_printf ("Rejecting local %W. use: %d", dg_ptr, use); + else + grp_list *= gsid; + } + else debug_printf ("LookupAccountName(%W), %E", builtin_grp); - builtin = true; } - if (!legal_sid_type (use)) - debug_printf ("Rejecting local %W. use: %d", dg_ptr, use); - else if (builtin) - grp_list *= gsid; else - grp_list += gsid; + debug_printf ("LookupAccountName(%W), %E", domlocal_grp); } NetApiBufferFree (buf); return true; -- cgit v1.1