Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/nss/uids.c
diff options
context:
space:
mode:
Diffstat (limited to 'nss/uids.c')
-rw-r--r--nss/uids.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/nss/uids.c b/nss/uids.c
new file mode 100644
index 0000000..dbe17d0
--- /dev/null
+++ b/nss/uids.c
@@ -0,0 +1,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;
+}
+