summaryrefslogtreecommitdiffstats
path: root/winsup/cygwin/uinfo.cc
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2014-02-10 18:28:51 +0000
committerCorinna Vinschen <corinna@vinschen.de>2014-02-10 18:28:51 +0000
commit0ac645c1c32e2462c87378df16e0308d4f7af0b7 (patch)
tree523ccaa18e26d1a764dfd63b4276c6a2db0d93d9 /winsup/cygwin/uinfo.cc
parent127cfd4f5abfa7913a8f5704f9ba8978f9b4baae (diff)
downloadcygnal-0ac645c1c32e2462c87378df16e0308d4f7af0b7.tar.gz
cygnal-0ac645c1c32e2462c87378df16e0308d4f7af0b7.tar.bz2
cygnal-0ac645c1c32e2462c87378df16e0308d4f7af0b7.zip
* uinfo.cc (pwdgrp::fetch_account_from_windows): Add code to allow
setting the primary group from the SAM comment field.
Diffstat (limited to 'winsup/cygwin/uinfo.cc')
-rw-r--r--winsup/cygwin/uinfo.cc23
1 files changed, 22 insertions, 1 deletions
diff --git a/winsup/cygwin/uinfo.cc b/winsup/cygwin/uinfo.cc
index 6ef2719e0..e209cc66c 100644
--- a/winsup/cygwin/uinfo.cc
+++ b/winsup/cygwin/uinfo.cc
@@ -1443,6 +1443,7 @@ pwdgrp::fetch_account_from_windows (fetch_user_arg_t &arg, bool group)
debug_printf ("NetUserGetInfo(%W,%W) %u", domain, name, nas);
else
{
+ PWCHAR pgrp = NULL;
struct {
PCWSTR str;
size_t len;
@@ -1450,7 +1451,8 @@ pwdgrp::fetch_account_from_windows (fetch_user_arg_t &arg, bool group)
} search[] = {
{ L"name=\"", 6, &user },
{ L"home=\"", 6, &home },
- { L"shell=\"", 7, &shell }
+ { L"shell=\"", 7, &shell },
+ { L"group=\"", 7, &pgrp }
};
PWCHAR s, e;
@@ -1494,6 +1496,25 @@ pwdgrp::fetch_account_from_windows (fetch_user_arg_t &arg, bool group)
}
}
NetApiBufferFree (ui);
+ if (pgrp)
+ {
+ /* For setting the primary group, we have to test all
+ three possible Cygwin name variations:
+
+ MACHINE+group, +group, group
+ */
+ char gname[2 * (DNLEN + UNLEN + 1)];
+ char *sep;
+ struct group *gr;
+
+ sep += sys_wcstombs (sep = gname, 2 * DNLEN + 1, domain);
+ *sep = cygheap->pg.nss_separator ()[0];
+ sys_wcstombs (sep + 1, 2 * UNLEN + 1, pgrp);
+ if ((gr = internal_getgrnam (gname))
+ || (gr = internal_getgrnam (sep))
+ || (gr = internal_getgrnam (sep + 1)))
+ gid = gr->gr_gid;
+ }
}
}
else /* SidTypeGroup */