aboutsummaryrefslogtreecommitdiff
path: root/winsup/cygwin/grp.cc
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2015-02-20 15:13:46 +0000
committerCorinna Vinschen <corinna@vinschen.de>2015-02-20 15:13:46 +0000
commitd6f62a117812f074bff9cbe11099b9f6406ab08a (patch)
tree9922732a892b7786c210c977d7a3bef100647ed9 /winsup/cygwin/grp.cc
parent89a3749928a964ca31067efc7c3694a4bbbf1289 (diff)
downloadnewlib-d6f62a117812f074bff9cbe11099b9f6406ab08a.zip
newlib-d6f62a117812f074bff9cbe11099b9f6406ab08a.tar.gz
newlib-d6f62a117812f074bff9cbe11099b9f6406ab08a.tar.bz2
* grp.cc (internal_getgroups): Take additional timeout_ns parameter.
Restrict fetching group account entries from user token groups by timeout_ns 100ns-intervals. Add preceding comment to explain why. * pwdgrp.h (internal_getgroups): Align prototype. * times.cc (GetTickCount_ns): New function. * uinfo.cc (internal_getlogin): Call internal_getgroups wih 300ms timeout. * winsup.h (GetTickCount_ns): Declare.
Diffstat (limited to 'winsup/cygwin/grp.cc')
-rw-r--r--winsup/cygwin/grp.cc14
1 files changed, 12 insertions, 2 deletions
diff --git a/winsup/cygwin/grp.cc b/winsup/cygwin/grp.cc
index f7ce61b..0702029 100644
--- a/winsup/cygwin/grp.cc
+++ b/winsup/cygwin/grp.cc
@@ -1,7 +1,7 @@
/* grp.cc
Copyright 1996, 1997, 1998, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
- 2008, 2009, 2011, 2012, 2013, 2014 Red Hat, Inc.
+ 2008, 2009, 2011, 2012, 2013, 2014, 2015 Red Hat, Inc.
Original stubs by Jason Molenda of Cygnus Support, crash@cygnus.com
First implementation by Gunther Ebert, gunther.ebert@ixos-leipzig.de
@@ -492,8 +492,12 @@ endgrent_filtered (void *gr)
((gr_ent *) gr)->endgrent ();
}
+/* timeout_ns (in 100ns units) is set to non-0 when called from
+ internal_getlogin. This restricts fetching of the user's groups at process
+ tree startup to a (hopefully) bearable time. */
int
-internal_getgroups (int gidsetsize, gid_t *grouplist, cyg_ldap *pldap)
+internal_getgroups (int gidsetsize, gid_t *grouplist, cyg_ldap *pldap,
+ const DWORD timeout_ns)
{
NTSTATUS status;
HANDLE tok;
@@ -527,6 +531,10 @@ internal_getgroups (int gidsetsize, gid_t *grouplist, cyg_ldap *pldap)
status = NtQueryInformationToken (tok, TokenGroups, groups, size, &size);
if (NT_SUCCESS (status))
{
+ ULONGLONG t0;
+
+ if (timeout_ns)
+ t0 = GetTickCount_ns ();
for (DWORD pg = 0; pg < groups->GroupCount; ++pg)
{
cygpsid sid = groups->Groups[pg].Sid;
@@ -543,6 +551,8 @@ internal_getgroups (int gidsetsize, gid_t *grouplist, cyg_ldap *pldap)
goto error;
}
}
+ if (timeout_ns && GetTickCount_ns () - t0 >= timeout_ns)
+ break;
}
}
}