1*4c0d7cdfSBrooks Davis /* $NetBSD: pwcache.h,v 1.5 2003/11/10 08:51:51 wiz Exp $ */ 2*4c0d7cdfSBrooks Davis /* $FreeBSD$ */ 3*4c0d7cdfSBrooks Davis 4*4c0d7cdfSBrooks Davis /*- 5*4c0d7cdfSBrooks Davis * Copyright (c) 1992 Keith Muller. 6*4c0d7cdfSBrooks Davis * Copyright (c) 1992, 1993 7*4c0d7cdfSBrooks Davis * The Regents of the University of California. All rights reserved. 8*4c0d7cdfSBrooks Davis * 9*4c0d7cdfSBrooks Davis * This code is derived from software contributed to Berkeley by 10*4c0d7cdfSBrooks Davis * Keith Muller of the University of California, San Diego. 11*4c0d7cdfSBrooks Davis * 12*4c0d7cdfSBrooks Davis * Redistribution and use in source and binary forms, with or without 13*4c0d7cdfSBrooks Davis * modification, are permitted provided that the following conditions 14*4c0d7cdfSBrooks Davis * are met: 15*4c0d7cdfSBrooks Davis * 1. Redistributions of source code must retain the above copyright 16*4c0d7cdfSBrooks Davis * notice, this list of conditions and the following disclaimer. 17*4c0d7cdfSBrooks Davis * 2. Redistributions in binary form must reproduce the above copyright 18*4c0d7cdfSBrooks Davis * notice, this list of conditions and the following disclaimer in the 19*4c0d7cdfSBrooks Davis * documentation and/or other materials provided with the distribution. 20*4c0d7cdfSBrooks Davis * 3. Neither the name of the University nor the names of its contributors 21*4c0d7cdfSBrooks Davis * may be used to endorse or promote products derived from this software 22*4c0d7cdfSBrooks Davis * without specific prior written permission. 23*4c0d7cdfSBrooks Davis * 24*4c0d7cdfSBrooks Davis * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 25*4c0d7cdfSBrooks Davis * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 26*4c0d7cdfSBrooks Davis * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 27*4c0d7cdfSBrooks Davis * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 28*4c0d7cdfSBrooks Davis * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 29*4c0d7cdfSBrooks Davis * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 30*4c0d7cdfSBrooks Davis * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31*4c0d7cdfSBrooks Davis * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 32*4c0d7cdfSBrooks Davis * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 33*4c0d7cdfSBrooks Davis * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 34*4c0d7cdfSBrooks Davis * SUCH DAMAGE. 35*4c0d7cdfSBrooks Davis * 36*4c0d7cdfSBrooks Davis * @(#)cache.h 8.1 (Berkeley) 5/31/93 37*4c0d7cdfSBrooks Davis */ 38*4c0d7cdfSBrooks Davis 39*4c0d7cdfSBrooks Davis /* 40*4c0d7cdfSBrooks Davis * Constants and data structures used to implement group and password file 41*4c0d7cdfSBrooks Davis * caches. Traditional passwd/group cache routines perform quite poorly with 42*4c0d7cdfSBrooks Davis * archives. The chances of hitting a valid lookup with an archive is quite a 43*4c0d7cdfSBrooks Davis * bit worse than with files already resident on the file system. These misses 44*4c0d7cdfSBrooks Davis * create a MAJOR performance cost. To address this problem, these routines 45*4c0d7cdfSBrooks Davis * cache both hits and misses. 46*4c0d7cdfSBrooks Davis * 47*4c0d7cdfSBrooks Davis * NOTE: name lengths must be as large as those stored in ANY PROTOCOL and 48*4c0d7cdfSBrooks Davis * as stored in the passwd and group files. CACHE SIZES MUST BE PRIME 49*4c0d7cdfSBrooks Davis */ 50*4c0d7cdfSBrooks Davis #define UNMLEN 32 /* >= user name found in any protocol */ 51*4c0d7cdfSBrooks Davis #define GNMLEN 32 /* >= group name found in any protocol */ 52*4c0d7cdfSBrooks Davis #define UID_SZ 317 /* size of uid to user_name cache */ 53*4c0d7cdfSBrooks Davis #define UNM_SZ 317 /* size of user_name to uid cache */ 54*4c0d7cdfSBrooks Davis #define GID_SZ 251 /* size of gid to group_name cache */ 55*4c0d7cdfSBrooks Davis #define GNM_SZ 251 /* size of group_name to gid cache */ 56*4c0d7cdfSBrooks Davis #define VALID 1 /* entry and name are valid */ 57*4c0d7cdfSBrooks Davis #define INVALID 2 /* entry valid, name NOT valid */ 58*4c0d7cdfSBrooks Davis 59*4c0d7cdfSBrooks Davis /* 60*4c0d7cdfSBrooks Davis * Node structures used in the user, group, uid, and gid caches. 61*4c0d7cdfSBrooks Davis */ 62*4c0d7cdfSBrooks Davis 63*4c0d7cdfSBrooks Davis typedef struct uidc { 64*4c0d7cdfSBrooks Davis int valid; /* is this a valid or a miss entry */ 65*4c0d7cdfSBrooks Davis char name[UNMLEN]; /* uid name */ 66*4c0d7cdfSBrooks Davis uid_t uid; /* cached uid */ 67*4c0d7cdfSBrooks Davis } UIDC; 68*4c0d7cdfSBrooks Davis 69*4c0d7cdfSBrooks Davis typedef struct gidc { 70*4c0d7cdfSBrooks Davis int valid; /* is this a valid or a miss entry */ 71*4c0d7cdfSBrooks Davis char name[GNMLEN]; /* gid name */ 72*4c0d7cdfSBrooks Davis gid_t gid; /* cached gid */ 73*4c0d7cdfSBrooks Davis } GIDC; 74