#define _GNU_SOURCE #include #include #define BUFLEN 4096 int main() { struct passwd pw, *pwp; char buf[BUFLEN]; int i, cnt; cnt = 0; setpwent(); while (1) { i = getpwent_r(&pw, buf, BUFLEN, &pwp); if (i) { printf("status: %d\n", i); break; } printf("%d: %s (%d)\tHOME %s\tSHELL %s\n", cnt, pwp->pw_name, pwp->pw_uid, pwp->pw_dir, pwp->pw_shell); cnt++; } endpwent(); return 0; }