122454Sdist /* 2*62083Sbostic * Copyright (c) 1980, 1993 3*62083Sbostic * The Regents of the University of California. All rights reserved. 433499Sbostic * 542741Sbostic * %sccs.include.redist.c% 622454Sdist */ 722454Sdist 834905Sbostic #ifndef lint 9*62083Sbostic static char sccsid[] = "@(#)getname.c 8.1 (Berkeley) 06/06/93"; 1034905Sbostic #endif /* not lint */ 1122454Sdist 1254505Sbostic #include "rcv.h" 1316733Sralph #include <pwd.h> 1454505Sbostic #include "extern.h" 151233Skas 1654505Sbostic /* Getname / getuserid for those with hashed passwd data base). */ 171233Skas 181233Skas /* 191233Skas * Search the passwd file for a uid. Return name through ref parameter 201233Skas * if found, indicating success with 0 return. Return -1 on error. 211233Skas */ 2234968Sedward char * getname(uid)2334968Sedwardgetname(uid) 2454505Sbostic int uid; 251233Skas { 2616733Sralph struct passwd *pw; 271233Skas 2816733Sralph if ((pw = getpwuid(uid)) == NULL) 2934968Sedward return NOSTR; 3034968Sedward return pw->pw_name; 311233Skas } 321233Skas 331233Skas /* 341233Skas * Convert the passed name to a user id and return it. Return -1 3531142Sedward * on error. 361233Skas */ 3754505Sbostic int getuserid(name)381233Skasgetuserid(name) 391233Skas char name[]; 401233Skas { 4116733Sralph struct passwd *pw; 421233Skas 4316733Sralph if ((pw = getpwnam(name)) == NULL) 4431142Sedward return -1; 4516733Sralph return pw->pw_uid; 461233Skas } 47