1 2 3 4 5 6 7 8 9 10 11 12 13 14
#include <grp.h> #include <string.h> #include <stdlib.h> struct group *getgrnam(const char* name) { struct group *tmp; setgrent(); for (;;) { tmp=getgrent(); if (!tmp) return 0; if (!strcmp(tmp->gr_name,name)) return tmp; } }