source: branches/samba-3.3.x/testsuite/nsswitch/getpwnam.c@ 715

Last change on this file since 715 was 206, checked in by Herwig Bauernfeind, 16 years ago

Import Samba 3.3 branch at 3.0.0 level (psmedley's port)

File size: 790 bytes
Line 
1/*
2 * Lookup a user by name
3 */
4
5#include <stdio.h>
6#include <pwd.h>
7#include <sys/types.h>
8
9int main(int argc, char **argv)
10{
11 struct passwd *pw;
12
13 /* Check args */
14
15 if (argc != 2) {
16 printf("ERROR: no arg specified\n");
17 exit(1);
18 }
19
20 /* Do getpwnam() */
21
22 if ((pw = getpwnam(argv[1])) == NULL) {
23 printf("FAIL: user %s does not exist\n", argv[1]);
24 exit(1);
25 }
26
27 printf("PASS: user %s exists\n", argv[1]);
28 printf("pw_name = %s\n", pw->pw_name);
29 printf("pw_passwd = %s\n", pw->pw_passwd);
30 printf("pw_uid = %d\n", pw->pw_uid);
31 printf("pw_gid = %d\n", pw->pw_gid);
32 printf("pw_gecos = %s\n", pw->pw_gecos);
33 printf("pw_dir = %s\n", pw->pw_dir);
34 printf("pw_shell = %s\n", pw->pw_shell);
35
36 exit(0);
37}
Note: See TracBrowser for help on using the repository browser.