1 /* 2 * Copyright (c) 1980 Regents of the University of California. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms are permitted 6 * provided that the above copyright notice and this paragraph are 7 * duplicated in all such forms and that any documentation, 8 * advertising materials, and other materials related to such 9 * distribution and use acknowledge that the software was developed 10 * by the University of California, Berkeley. The name of the 11 * University may not be used to endorse or promote products derived 12 * from this software without specific prior written permission. 13 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR 14 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED 15 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. 16 */ 17 18 #ifndef lint 19 static char sccsid[] = "@(#)getname.c 5.6 (Berkeley) 07/07/88"; 20 #endif /* not lint */ 21 22 #include <pwd.h> 23 24 /* 25 * Getname / getuserid for those with 26 * hashed passwd data base). 27 * 28 */ 29 30 #include "rcv.h" 31 32 /* 33 * Search the passwd file for a uid. Return name through ref parameter 34 * if found, indicating success with 0 return. Return -1 on error. 35 */ 36 char * 37 getname(uid) 38 { 39 struct passwd *pw; 40 41 if ((pw = getpwuid(uid)) == NULL) 42 return NOSTR; 43 return pw->pw_name; 44 } 45 46 /* 47 * Convert the passed name to a user id and return it. Return -1 48 * on error. 49 */ 50 getuserid(name) 51 char name[]; 52 { 53 struct passwd *pw; 54 55 if ((pw = getpwnam(name)) == NULL) 56 return -1; 57 return pw->pw_uid; 58 } 59