#include #include #include #include #include #include #include #include #include #include #include #include #include int main(int argc, const char *argv[]) { struct passwd *pwd; const char *user; int pam_err, retry; register struct group *g; gid_t gid; pwd = getpwnam(argv[2]); setgrent(); if ( NULL == (g = getgrnam(argv[1]))) { endgrent(); } else { while (*(g->gr_mem) != NULL) { printf("gr_mem: %s - %s\n",argv[1], *(g->gr_mem)); if (0==strcmp(user,*(g->gr_mem))) { puts("OK"); break; } *(g->gr_mem)++; } endgrent(); } gid=getgid(); if ( gid == g->gr_gid ) puts("OK MAIN"); return (0); }