Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/nss/uids.c
blob: dbe17d0bc0d50eaf399040536b549ddfdfcdd685 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#define _GNU_SOURCE
#include <pwd.h>
#include <stdio.h>
#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;
}