aboutsummaryrefslogtreecommitdiff
path: root/nss/getent.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@gmail.com>2011-06-15 20:54:31 -0400
committerUlrich Drepper <drepper@gmail.com>2011-06-15 21:06:19 -0400
commit82e9a1f7df488c62a214ee63847b2c884dcba565 (patch)
tree271719d21cef70e74fc8c0f1e34f13f8790c689c /nss/getent.c
parentc41af17eed77f07983dab6f702a6347fcad9a619 (diff)
downloadglibc-82e9a1f7df488c62a214ee63847b2c884dcba565.tar
glibc-82e9a1f7df488c62a214ee63847b2c884dcba565.tar.gz
glibc-82e9a1f7df488c62a214ee63847b2c884dcba565.tar.bz2
glibc-82e9a1f7df488c62a214ee63847b2c884dcba565.zip
Add initgroups lookup support to getent
Diffstat (limited to 'nss/getent.c')
-rw-r--r--nss/getent.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/nss/getent.c b/nss/getent.c
index a33bcb4ac1..9d43e2f656 100644
--- a/nss/getent.c
+++ b/nss/getent.c
@@ -501,6 +501,38 @@ netgroup_keys (int number, char *key[])
return result;
}
+/* This is for initgroups */
+static int
+initgroups_keys (int number, char *key[])
+{
+ int ngrps = 100;
+ size_t grpslen = ngrps * sizeof (gid_t);
+ gid_t *grps = alloca (grpslen);
+
+ for (int i = 0; i < number; ++i)
+ {
+ int no = ngrps;
+ int n;
+ while ((n = getgrouplist (key[i], -1, grps, &no)) == -1
+ && no > ngrps)
+ {
+ grps = extend_alloca (grps, grpslen, no * sizeof (gid_t));
+ ngrps = no;
+ }
+
+ if (n == -1)
+ return 1;
+
+ printf ("%-21s", key[i]);
+ for (int j = 0; j < n; ++j)
+ if (grps[j] != -1)
+ printf (" %ld", (long int) grps[j]);
+ putchar_unlocked ('\n');
+ }
+
+ return 0;
+}
+
/* This is for networks */
static void
print_networks (struct netent *net)
@@ -829,6 +861,7 @@ D(ethers)
D(group)
D(gshadow)
D(hosts)
+D(initgroups)
D(netgroup)
D(networks)
D(passwd)