X-Git-Url: http://git.iain.cx/?p=profile.git;a=blobdiff_plain;f=src%2Fnetgroups.c;fp=src%2Fnetgroups.c;h=0a3dd77414f779350286c6f7c1b4ebcdcf571792;hp=0000000000000000000000000000000000000000;hb=80a28ca55ac0e9a9743b561ff3a0ac9ccc62d4ce;hpb=c204dd8c0a7d9d0c767e01f98f623af5f103c4d9 diff --git a/src/netgroups.c b/src/netgroups.c new file mode 100644 index 0000000..0a3dd77 --- /dev/null +++ b/src/netgroups.c @@ -0,0 +1,27 @@ +#include +#include +#include + +int main(int argc, char **argv) { + char *group, *host, *hostp, *userp, *domainp; + + if (argc == 1) { + fprintf(stderr, "Usage: netgroups []\n"); + exit(1); + } + + /* What group do we want? */ + group = argv[1]; + if (*group == '@') group++; + + /* Do we want to match a host? */ + host = argv[2]; + + if (host) exit(! innetgr(group, host, 0, 0)); + + setnetgrent(group); + while (getnetgrent(&hostp, &userp, &domainp)) printf("%s\n", hostp); + endnetgrent(); + + exit(0); +}