#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <grp.h>
int main() {
struct group* grp;
gid_t gid;
char** users;
int x = 1;
gid = getgid();
printf("Group ID: %d\n", gid);
if((grp = getgrgid(gid)) == NULL )
return 1;
printf("Group: %s\n", grp->gr_name );
printf("Users in your group\n");
printf("-------------------\n");
for( users = grp->gr_mem; *users != NULL; users++,++x )
printf( "%d. %s\n", x, *users );
printf("-------------------\n");
if(strcmp(grp->gr_passwd,"x") == 0)
printf("Password is protected by shadow file.\n");
else
printf("Password: %s\n", grp->gr_passwd);
return 0;
}