1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License, Version 1.0 only 6 * (the "License"). You may not use this file except in compliance 7 * with the License. 8 * 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10 * or http://www.opensolaris.org/os/licensing. 11 * See the License for the specific language governing permissions 12 * and limitations under the License. 13 * 14 * When distributing Covered Code, include this CDDL HEADER in each 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 * If applicable, add the following below this CDDL HEADER, with the 17 * fields enclosed by brackets "[]" replaced with your own identifying 18 * information: Portions Copyright [yyyy] [name of copyright owner] 19 * 20 * CDDL HEADER END 21 */ 22 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ 23 /* All Rights Reserved */ 24 25 26 #ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.7 */ 27 /* 28 * namtouid converts login names to uids 29 * maintains ulist for speed only 30 */ 31 #include <stdio.h> 32 #include <sys/types.h> 33 #include "acctdef.h" 34 #include <pwd.h> 35 static usize; 36 static struct ulist { 37 char uname[NSZ]; 38 uid_t uuid; 39 } ul[A_USIZE]; 40 char ntmp[NSZ+1]; 41 42 char *strncpy(); 43 44 uid_t 45 namtouid(name) 46 char name[NSZ]; 47 { 48 register struct ulist *up; 49 register uid_t tuid; 50 struct passwd *getpwnam(), *pp; 51 52 for (up = ul; up < &ul[usize]; up++) 53 if (strncmp(name, up->uname, NSZ) == 0) 54 return(up->uuid); 55 strncpy(ntmp, name, NSZ); 56 (void) setpwent(); 57 if ((pp = getpwnam(ntmp)) == NULL) 58 tuid = -1; 59 else { 60 tuid = pp->pw_uid; 61 if (usize < A_USIZE) { 62 CPYN(up->uname, name); 63 up->uuid = tuid; 64 usize++; 65 } 66 } 67 return(tuid); 68 } 69