From 6f17403298cf33747a45fb5ecbe78bf7632531f9 Mon Sep 17 00:00:00 2001 From: Arthur de Jong Date: Wed, 11 Oct 2006 13:34:15 +0000 Subject: import release 251 of nss-ldap git-svn-id: http://arthurdejong.org/svn/nss-pam-ldapd/nss_ldap-251@1 ef36b2f9-881f-0410-afb5-c4e39611909c --- tests/testgr.c | 71 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 tests/testgr.c (limited to 'tests/testgr.c') diff --git a/tests/testgr.c b/tests/testgr.c new file mode 100644 index 0000000..4907238 --- /dev/null +++ b/tests/testgr.c @@ -0,0 +1,71 @@ +#include +#include +#include + +void +main (int argc, char **argv) +{ +#if 0 + struct group + { /* see getgrent(3) */ + char *gr_name; + char *gr_passwd; + gid_t gr_gid; + char **gr_mem; + }; +#endif + + scan_group (); + exit (0); +} + +void +dump (struct group *g) +{ + char mem[2048]; + char **p; + + int doit = (g->gr_mem && *(g->gr_mem)); + p = g->gr_mem; + strcpy (mem, ""); + while (doit) + { + if (p != g->gr_mem) + strcat (mem, ","); + strcat (mem, *p); + if (*(++p) == NULL) + break; + } + printf ("%s:%s:%d:%s\n", g->gr_name, g->gr_passwd, g->gr_gid, mem); + +} + +scan_group () +{ + struct group *g; + + signal(SIGPIPE, SIG_IGN); + + setgrent (); + + while ((g = getgrent ()) != NULL) + { + dump (g); + } + + endgrent (); + + sleep(10); + + printf ("==> getgrnam(qmail)\n"); + g = getgrnam ("qmail"); + if (g != NULL) + dump (g); +#if 0 + printf ("==> getgrnam(testgroup)\n"); + g = getgrnam ("testgroup"); + if (g != NULL) + dump (g); +#endif + +} -- cgit v1.2.3