1 #ifndef lint 2 static char sccsid[] = "@(#)getpwinfo.c 5.1 (Berkeley) 07/02/83"; 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) 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(0); 42 } 43 44 45 /*** 46 * gninfo(name, uid, path) get passwd file info for name 47 * char *path, *name; 48 * int *uid; 49 * 50 * return codes: 0 | FAIL 51 */ 52 53 gninfo(name, uid, path) 54 char *path, *name; 55 int *uid; 56 { 57 register struct passwd *pwd; 58 struct passwd *getpwnam(); 59 60 if ((pwd = getpwnam(name)) == NULL) { 61 /* can not find name in passwd file */ 62 *path = '\0'; 63 return(FAIL); 64 } 65 66 strcpy(path, pwd->pw_dir); 67 *uid = pwd->pw_uid; 68 return(0); 69 } 70 71 72