public inbox for cygwin-cvs@sourceware.org
help / color / mirror / Atom feed
* [newlib-cygwin] Cygwin: fetch local groups from local machine
@ 2019-02-22 9:21 Corinna Vinschen
0 siblings, 0 replies; only message in thread
From: Corinna Vinschen @ 2019-02-22 9:21 UTC (permalink / raw)
To: cygwin-cvs
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=14e22688535e3695a7f73a0c82f3535ce164ee67
commit 14e22688535e3695a7f73a0c82f3535ce164ee67
Author: Corinna Vinschen <corinna@vinschen.de>
Date: Fri Feb 22 00:13:57 2019 +0100
Cygwin: fetch local groups from local machine
...even for domain accounts, otherwise local group membership is ignored.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Diff:
---
winsup/cygwin/sec_auth.cc | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/winsup/cygwin/sec_auth.cc b/winsup/cygwin/sec_auth.cc
index beff327..4bbcb0e 100644
--- a/winsup/cygwin/sec_auth.cc
+++ b/winsup/cygwin/sec_auth.cc
@@ -400,11 +400,18 @@ get_user_local_groups (PWCHAR logonserver, PWCHAR domain,
DWORD cnt, tot;
NET_API_STATUS ret;
- ret = NetUserGetLocalGroups (logonserver, user, 0, LG_INCLUDE_INDIRECT,
+ /* We want to know the membership in local groups on the current machine.
+ Thus, don't ask the logonserver, ask the local machine. In contrast
+ to most other NetUser functions, NetUserGetLocalGroups accepts the
+ username in DOMAIN\user form. */
+ WCHAR username[MAX_DOMAIN_NAME_LEN + UNLEN + 2];
+ wcpcpy (wcpcpy (wcpcpy (username, domain), L"\\"), user);
+ ret = NetUserGetLocalGroups (NULL, username, 0, LG_INCLUDE_INDIRECT,
(LPBYTE *) &buf, MAX_PREFERRED_LENGTH,
&cnt, &tot);
if (ret)
{
+ debug_printf ("username: %W", username);
__seterrno_from_win_error (ret);
return false;
}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2019-02-22 9:21 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-22 9:21 [newlib-cygwin] Cygwin: fetch local groups from local machine Corinna Vinschen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).