Commit | Line | Data |
---|---|---|
9552e6b8 | 1 | /* |
a12ff486 KB |
2 | * Copyright (c) 1980, 1993 |
3 | * The Regents of the University of California. All rights reserved. | |
0c5f72fb | 4 | * |
f15db449 | 5 | * %sccs.include.redist.c% |
9552e6b8 DF |
6 | */ |
7 | ||
acfc7e9b | 8 | #ifndef lint |
a12ff486 | 9 | static char sccsid[] = "@(#)getname.c 8.1 (Berkeley) %G%"; |
acfc7e9b | 10 | #endif /* not lint */ |
9552e6b8 | 11 | |
a0d23834 | 12 | #include "rcv.h" |
4e161d3b | 13 | #include <pwd.h> |
a0d23834 | 14 | #include "extern.h" |
b0f79ad7 | 15 | |
a0d23834 | 16 | /* Getname / getuserid for those with hashed passwd data base). */ |
b0f79ad7 | 17 | |
b0f79ad7 KS |
18 | /* |
19 | * Search the passwd file for a uid. Return name through ref parameter | |
20 | * if found, indicating success with 0 return. Return -1 on error. | |
b0f79ad7 | 21 | */ |
f674e088 EW |
22 | char * |
23 | getname(uid) | |
a0d23834 | 24 | int uid; |
b0f79ad7 | 25 | { |
4e161d3b | 26 | struct passwd *pw; |
b0f79ad7 | 27 | |
4e161d3b | 28 | if ((pw = getpwuid(uid)) == NULL) |
f674e088 EW |
29 | return NOSTR; |
30 | return pw->pw_name; | |
b0f79ad7 KS |
31 | } |
32 | ||
33 | /* | |
34 | * Convert the passed name to a user id and return it. Return -1 | |
828615a1 | 35 | * on error. |
b0f79ad7 | 36 | */ |
a0d23834 | 37 | int |
b0f79ad7 KS |
38 | getuserid(name) |
39 | char name[]; | |
40 | { | |
4e161d3b | 41 | struct passwd *pw; |
b0f79ad7 | 42 | |
4e161d3b | 43 | if ((pw = getpwnam(name)) == NULL) |
828615a1 | 44 | return -1; |
4e161d3b | 45 | return pw->pw_uid; |
b0f79ad7 | 46 | } |