diff options
author | Tim Potter <tpot@samba.org> | 2000-05-12 06:55:09 +0000 |
---|---|---|
committer | Tim Potter <tpot@samba.org> | 2000-05-12 06:55:09 +0000 |
commit | 75ebfc6f7a7692d772b729b2d83038a9054b4f90 (patch) | |
tree | 031b445348b62fdf40489fb2526c46506ee2c3ba /testsuite/nsswitch/getgrgid.c | |
parent | 053322d0ca6b68be638c2d5f4caa9909a19c1646 (diff) | |
download | samba-75ebfc6f7a7692d772b729b2d83038a9054b4f90.tar.gz samba-75ebfc6f7a7692d772b729b2d83038a9054b4f90.tar.xz samba-75ebfc6f7a7692d772b729b2d83038a9054b4f90.zip |
Merge from TNG.
(This used to be commit af5ded9f17addb4bc89ecb762b9b99d2f99463ab)
Diffstat (limited to 'testsuite/nsswitch/getgrgid.c')
-rw-r--r-- | testsuite/nsswitch/getgrgid.c | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/testsuite/nsswitch/getgrgid.c b/testsuite/nsswitch/getgrgid.c new file mode 100644 index 0000000000..947dd0ac4c --- /dev/null +++ b/testsuite/nsswitch/getgrgid.c @@ -0,0 +1,57 @@ +/* + * Lookup a group by gid. + */ + +#include <stdio.h> +#include <grp.h> +#include <sys/types.h> + +int main(int argc, char **argv) +{ + struct group *gr; + gid_t gid; + + /* Check args */ + + if (argc != 2) { + printf("ERROR: no arg specified\n"); + exit(1); + } + + if ((gid = atoi(argv[1])) == 0) { + printf("ERROR: invalid gid specified\n"); + exit(1); + } + + /* Do getgrgid() */ + + if ((gr = getgrgid(gid)) == NULL) { + printf("FAIL: gid %d does not exist\n", gid); + exit(1); + } + + /* Print group info */ + + printf("PASS: gid %d exists\n", gid); + printf("gr_name = %s\n", gr->gr_name); + printf("gr_passwd = %s\n", gr->gr_passwd); + printf("gr_gid = %d\n", gr->gr_gid); + + /* Group membership */ + + if (gr->gr_mem != NULL) { + int i = 0; + + printf("gr_mem = "); + while(gr->gr_mem[i] != NULL) { + printf("%s", gr->gr_mem[i]); + i++; + if (gr->gr_mem != NULL) { + printf(","); + } + } + printf("\n"); + } + + exit(0); +} |