diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2014-02-10 18:28:51 +0000 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2014-02-10 18:28:51 +0000 |
commit | 0ac645c1c32e2462c87378df16e0308d4f7af0b7 (patch) | |
tree | 523ccaa18e26d1a764dfd63b4276c6a2db0d93d9 | |
parent | 127cfd4f5abfa7913a8f5704f9ba8978f9b4baae (diff) | |
download | newlib-0ac645c1c32e2462c87378df16e0308d4f7af0b7.zip newlib-0ac645c1c32e2462c87378df16e0308d4f7af0b7.tar.gz newlib-0ac645c1c32e2462c87378df16e0308d4f7af0b7.tar.bz2 |
* uinfo.cc (pwdgrp::fetch_account_from_windows): Add code to allow
setting the primary group from the SAM comment field.
-rw-r--r-- | winsup/cygwin/ChangeLog | 5 | ||||
-rw-r--r-- | winsup/cygwin/uinfo.cc | 23 |
2 files changed, 27 insertions, 1 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index b585aa7..6ad0ed2 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,5 +1,10 @@ 2014-02-10 Corinna Vinschen <corinna@vinschen.de> + * uinfo.cc (pwdgrp::fetch_account_from_windows): Add code to allow + setting the primary group from the SAM comment field. + +2014-02-10 Corinna Vinschen <corinna@vinschen.de> + * dcrt0.cc (child_info_spawn::handle_spawn): Call fixup_lockf_after_exec with additional argument to specify if the process has been execed or spawned. diff --git a/winsup/cygwin/uinfo.cc b/winsup/cygwin/uinfo.cc index 6ef2719..e209cc6 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 */ |