1: #if !defined(lint) && defined(DOSCCS)
2: static char sccsid[] = "@(#)getpwinfo.c 5.3.1 (2.11BSD) 1997/10/2";
3: #endif
4:
5: #include "uucp.h"
6: #include <pwd.h>
7:
8: /*LINTLIBRARY*/
9:
10: /*
11: * get passwd file info for uid
12: *
13: * return codes: SUCCESS | FAIL
14: *
15: */
16:
17: guinfo(uid, name, path)
18: int uid;
19: register char *path, *name;
20: {
21: register struct passwd *pwd;
22: char *l;
23:
24: if ((l = getlogin()) == NULL) {
25: l = getenv("USER");
26: }
27: if (l != NULL) {
28: pwd = getpwnam(l);
29: if (pwd != NULL && pwd->pw_uid == uid)
30: goto setup;
31: }
32: if ((pwd = getpwuid(uid)) == NULL) {
33: /* can not find uid in passwd file */
34: *name = '\0';
35: *path = '\0';
36: return FAIL;
37: }
38:
39: setup:
40: strcpy(path, pwd->pw_dir);
41: strcpy(name, pwd->pw_name);
42: return SUCCESS;
43: }
44:
45:
46: /*
47: * get passwd file info for name
48: *
49: * return codes: SUCCESS | FAIL
50: */
51:
52: gninfo(name, uid, path)
53: char *path, *name;
54: int *uid;
55: {
56: register struct passwd *pwd;
57:
58: if ((pwd = getpwnam(name)) == NULL) {
59: /* can not find name in passwd file */
60: *path = '\0';
61: return FAIL;
62: }
63:
64: strcpy(path, pwd->pw_dir);
65: *uid = pwd->pw_uid;
66: return SUCCESS;
67: }
Defined functions
Defined variables
sccsid
defined in line
2;
never used