aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2001-11-03 21:19:50 +0000
committerCorinna Vinschen <corinna@vinschen.de>2001-11-03 21:19:50 +0000
commitf41d24a14d5672c152938abd44226108d236aca1 (patch)
tree008f92c6a4894acc0627ed07c8dd0abb0078eaf9
parented14f73cc2f859348e26639fd7a96264640ec614 (diff)
downloadnewlib-f41d24a14d5672c152938abd44226108d236aca1.zip
newlib-f41d24a14d5672c152938abd44226108d236aca1.tar.gz
newlib-f41d24a14d5672c152938abd44226108d236aca1.tar.bz2
* security.cc (get_supplementary_group_sidlist): New function.
(get_group_sidlist): Call get_supplementary_group_sidlist() to retrieve list of supplementary groups SIDs from /etc/group and add them to the user's group list.
-rw-r--r--winsup/cygwin/ChangeLog7
-rw-r--r--winsup/cygwin/security.cc31
2 files changed, 38 insertions, 0 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index bc752f6..593690a 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,3 +1,10 @@
+2001-11-03 Corinna Vinschen <corinna@vinschen.de>
+
+ * security.cc (get_supplementary_group_sidlist): New function.
+ (get_group_sidlist): Call get_supplementary_group_sidlist() to
+ retrieve list of supplementary groups SIDs from /etc/group and
+ add them to the user's group list.
+
2001-11-03 Christopher Faylor <cgf@redhat.com>
* fhandler.cc (fhandler_base::read): Return just read ahead characters
diff --git a/winsup/cygwin/security.cc b/winsup/cygwin/security.cc
index 971612e..934ceed 100644
--- a/winsup/cygwin/security.cc
+++ b/winsup/cygwin/security.cc
@@ -448,6 +448,30 @@ get_user_primary_group (WCHAR *wlogonserver, const char *user,
return retval;
}
+static int
+get_supplementary_group_sidlist (const char *username, cygsidlist &grp_list)
+{
+ struct group *gr;
+ int cnt = 0;
+
+ for (int gidx = 0; (gr = internal_getgrent (gidx)); ++gidx)
+ {
+ if (gr->gr_mem)
+ for (int gi = 0; gr->gr_mem[gi]; ++gi)
+ if (strcasematch (username, gr->gr_mem[gi]))
+ {
+ if (gr->gr_passwd && *gr->gr_passwd)
+ {
+ cygsid sid (gr->gr_passwd);
+ if ((PSID)sid && grp_list.add (sid))
+ ++cnt;
+ }
+ break;
+ }
+ }
+ return cnt;
+}
+
static BOOL
get_group_sidlist (const char *logonserver, cygsidlist &grp_list,
cygsid &usersid, cygsid &pgrpsid,
@@ -459,6 +483,7 @@ get_group_sidlist (const char *logonserver, cygsidlist &grp_list,
DWORD ulen = INTERNET_MAX_HOST_NAME_LENGTH + 1;
DWORD dlen = INTERNET_MAX_HOST_NAME_LENGTH + 1;
SID_NAME_USE use;
+ cygsidlist sup_list;
auth_pos = -1;
sys_mbstowcs (wserver, logonserver, INTERNET_MAX_HOST_NAME_LENGTH + 1);
@@ -514,6 +539,12 @@ get_group_sidlist (const char *logonserver, cygsidlist &grp_list,
return FALSE;
if (!grp_list.contains (pgrpsid))
grp_list += pgrpsid;
+ if (get_supplementary_group_sidlist (user, sup_list))
+ {
+ for (int i = 0; i < sup_list.count; ++i)
+ if (!grp_list.contains (sup_list.sids[i]))
+ grp_list += sup_list.sids[i];
+ }
return TRUE;
}