1 #ifndef lint 2 static char sccsid[] = "@(#)getpwinfo.c 5.2 (Berkeley) 01/22/85"; 3 #endif 4 5 #include "uucp.h" 6 #include <pwd.h> 7 8 /******* 9 * guinfo(uid, name, path) get passwd file info for uid 10 * int uid; 11 * char *path, *name; 12 * 13 * return codes: 0 | FAIL 14 * 15 * modified 3/16/81 to use the "real" login name -- mcnc!dennis 16 * (Dennis Rockwell) 17 */ 18 19 guinfo(uid, name, path) 20 int uid; 21 register char *path, *name; 22 { 23 register struct passwd *pwd; 24 struct passwd *getpwuid(), *getpwnam(); 25 char *getlogin(), *l; 26 27 if ((l = getlogin()) != NULL) { 28 pwd = getpwnam(l); 29 if (pwd->pw_uid == uid || *l == 'U') 30 goto setup; 31 } 32 if ((pwd = getpwuid(uid)) == NULL) { 33 /* can not find uid in passwd file */ 34 *path = '\0'; 35 return FAIL; 36 } 37 38 setup: 39 strcpy(path, pwd->pw_dir); 40 strcpy(name, pwd->pw_name); 41 return SUCCESS; 42 } 43 44 45 /* 46 * get passwd file info for name 47 * 48 * return codes: SUCCESS | FAIL 49 */ 50 51 gninfo(name, uid, path) 52 char *path, *name; 53 int *uid; 54 { 55 register struct passwd *pwd; 56 struct passwd *getpwnam(); 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 } 68