This commit was manufactured by cvs2svn to create branch 'SAMBA_3_0'.(This used to...
[samba.git] / testsuite / nsswitch / getpwnam.c
1 /*
2  * Lookup a user by name
3  */
4  
5 #include <stdio.h>
6 #include <pwd.h>
7 #include <sys/types.h>
8
9 int 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 }