From 6e6ffe831d523bc126a81c8d7f96f6ef92b118c1 Mon Sep 17 00:00:00 2001 From: roland Date: Mon, 15 Jul 1991 21:33:30 +0000 Subject: [PATCH] Initial revision --- grp/testgrp.c | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 grp/testgrp.c diff --git a/grp/testgrp.c b/grp/testgrp.c new file mode 100644 index 0000000000..56d240b067 --- /dev/null +++ b/grp/testgrp.c @@ -0,0 +1,41 @@ +#include +#include +#include +#include +#include +#include + +void main (void) +{ + uid_t me; + struct passwd *my_passwd; + struct group *my_group; + char **members; + + me = getuid (); + my_passwd = getpwuid (me); + + printf ("My login name is %s.\n", my_passwd->pw_name); + printf ("My uid is %d.\n", (int)(my_passwd->pw_uid)); + printf ("My home directory is %s.\n", my_passwd->pw_dir); + printf ("My default shell is %s.\n", my_passwd->pw_shell); + + my_group = getgrgid (my_passwd->pw_gid); + if (!my_group) { + printf ("Couldn't find out about group %d.\n", (int)(my_passwd->pw_gid)); + exit (EXIT_FAILURE); + } + + printf ("My default group is %s (%d).\n", + my_group->gr_name, (int)(my_passwd->pw_gid)); + printf ("The members of this group are:\n"); + members = my_group->gr_mem; + while (members) { + printf (" %s\n", *(members)); + members++; + } + exit (EXIT_SUCCESS); +} + + + -- 2.11.0