1*7c478bd9Sstevel@tonic-gate /* 2*7c478bd9Sstevel@tonic-gate * CDDL HEADER START 3*7c478bd9Sstevel@tonic-gate * 4*7c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*7c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*7c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*7c478bd9Sstevel@tonic-gate * with the License. 8*7c478bd9Sstevel@tonic-gate * 9*7c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*7c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*7c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 12*7c478bd9Sstevel@tonic-gate * and limitations under the License. 13*7c478bd9Sstevel@tonic-gate * 14*7c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*7c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*7c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*7c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*7c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*7c478bd9Sstevel@tonic-gate * 20*7c478bd9Sstevel@tonic-gate * CDDL HEADER END 21*7c478bd9Sstevel@tonic-gate */ 22*7c478bd9Sstevel@tonic-gate /* 23*7c478bd9Sstevel@tonic-gate * Copyright 2004 Sun Microsystems, Inc. All rights reserved. 24*7c478bd9Sstevel@tonic-gate * Use is subject to license terms. 25*7c478bd9Sstevel@tonic-gate * 26*7c478bd9Sstevel@tonic-gate * Database-speficic definitions for the getXXXbyYYY routines 27*7c478bd9Sstevel@tonic-gate * (e.g getpwuid_r(), ether_ntohost()) that use the name-service switch. 28*7c478bd9Sstevel@tonic-gate * Database-independent definitions are in <nss_common.h> 29*7c478bd9Sstevel@tonic-gate * 30*7c478bd9Sstevel@tonic-gate * Ideally, this is the only switch header file one would add things 31*7c478bd9Sstevel@tonic-gate * to in order to support a new database. 32*7c478bd9Sstevel@tonic-gate * 33*7c478bd9Sstevel@tonic-gate * NOTE: The interfaces documented in this file may change in a minor 34*7c478bd9Sstevel@tonic-gate * release. It is intended that in the future a stronger committment 35*7c478bd9Sstevel@tonic-gate * will be made to these interface definitions which will guarantee 36*7c478bd9Sstevel@tonic-gate * them across minor releases. 37*7c478bd9Sstevel@tonic-gate */ 38*7c478bd9Sstevel@tonic-gate 39*7c478bd9Sstevel@tonic-gate #ifndef _NSS_DBDEFS_H 40*7c478bd9Sstevel@tonic-gate #define _NSS_DBDEFS_H 41*7c478bd9Sstevel@tonic-gate 42*7c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 43*7c478bd9Sstevel@tonic-gate 44*7c478bd9Sstevel@tonic-gate #include <errno.h> 45*7c478bd9Sstevel@tonic-gate #include <netdb.h> /* MAXALIASES, MAXADDRS */ 46*7c478bd9Sstevel@tonic-gate #include <limits.h> /* LOGNAME_MAX */ 47*7c478bd9Sstevel@tonic-gate #include <nss_common.h> 48*7c478bd9Sstevel@tonic-gate 49*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 50*7c478bd9Sstevel@tonic-gate extern "C" { 51*7c478bd9Sstevel@tonic-gate #endif 52*7c478bd9Sstevel@tonic-gate 53*7c478bd9Sstevel@tonic-gate #ifndef NSS_INCLUDE_UNSAFE 54*7c478bd9Sstevel@tonic-gate #define NSS_INCLUDE_UNSAFE 1 /* Build old, MT-unsafe interfaces, */ 55*7c478bd9Sstevel@tonic-gate #endif /* NSS_INCLUDE_UNSAFE */ /* e.g. getpwnam (c.f. getpwnam_r) */ 56*7c478bd9Sstevel@tonic-gate 57*7c478bd9Sstevel@tonic-gate /* 58*7c478bd9Sstevel@tonic-gate * Names of the well-known databases. 59*7c478bd9Sstevel@tonic-gate */ 60*7c478bd9Sstevel@tonic-gate 61*7c478bd9Sstevel@tonic-gate #define NSS_DBNAM_ALIASES "aliases" /* E-mail aliases, that is */ 62*7c478bd9Sstevel@tonic-gate #define NSS_DBNAM_AUTOMOUNT "automount" 63*7c478bd9Sstevel@tonic-gate #define NSS_DBNAM_BOOTPARAMS "bootparams" 64*7c478bd9Sstevel@tonic-gate #define NSS_DBNAM_ETHERS "ethers" 65*7c478bd9Sstevel@tonic-gate #define NSS_DBNAM_GROUP "group" 66*7c478bd9Sstevel@tonic-gate #define NSS_DBNAM_HOSTS "hosts" 67*7c478bd9Sstevel@tonic-gate #define NSS_DBNAM_IPNODES "ipnodes" 68*7c478bd9Sstevel@tonic-gate #define NSS_DBNAM_NETGROUP "netgroup" 69*7c478bd9Sstevel@tonic-gate #define NSS_DBNAM_NETMASKS "netmasks" 70*7c478bd9Sstevel@tonic-gate #define NSS_DBNAM_NETWORKS "networks" 71*7c478bd9Sstevel@tonic-gate #define NSS_DBNAM_PASSWD "passwd" 72*7c478bd9Sstevel@tonic-gate #define NSS_DBNAM_PRINTERS "printers" 73*7c478bd9Sstevel@tonic-gate #define NSS_DBNAM_PROJECT "project" 74*7c478bd9Sstevel@tonic-gate #define NSS_DBNAM_PROTOCOLS "protocols" 75*7c478bd9Sstevel@tonic-gate #define NSS_DBNAM_PUBLICKEY "publickey" 76*7c478bd9Sstevel@tonic-gate #define NSS_DBNAM_RPC "rpc" 77*7c478bd9Sstevel@tonic-gate #define NSS_DBNAM_SERVICES "services" 78*7c478bd9Sstevel@tonic-gate #define NSS_DBNAM_AUDITUSER "audit_user" 79*7c478bd9Sstevel@tonic-gate #define NSS_DBNAM_AUTHATTR "auth_attr" 80*7c478bd9Sstevel@tonic-gate #define NSS_DBNAM_EXECATTR "exec_attr" 81*7c478bd9Sstevel@tonic-gate #define NSS_DBNAM_PROFATTR "prof_attr" 82*7c478bd9Sstevel@tonic-gate #define NSS_DBNAM_USERATTR "user_attr" 83*7c478bd9Sstevel@tonic-gate 84*7c478bd9Sstevel@tonic-gate /* getspnam() et al use the "passwd" config entry but the "shadow" backend */ 85*7c478bd9Sstevel@tonic-gate #define NSS_DBNAM_SHADOW "shadow" 86*7c478bd9Sstevel@tonic-gate 87*7c478bd9Sstevel@tonic-gate /* The "compat" backend gets config entries for these pseudo-databases */ 88*7c478bd9Sstevel@tonic-gate #define NSS_DBNAM_PASSWD_COMPAT "passwd_compat" 89*7c478bd9Sstevel@tonic-gate #define NSS_DBNAM_GROUP_COMPAT "group_compat" 90*7c478bd9Sstevel@tonic-gate 91*7c478bd9Sstevel@tonic-gate /* 92*7c478bd9Sstevel@tonic-gate * Default switch configuration, compiled into the front-ends. 93*7c478bd9Sstevel@tonic-gate * 94*7c478bd9Sstevel@tonic-gate * Absent good reasons to the contrary, this should be compatible with the 95*7c478bd9Sstevel@tonic-gate * default /etc/nsswitch.conf file. 96*7c478bd9Sstevel@tonic-gate */ 97*7c478bd9Sstevel@tonic-gate #define NSS_FILES_ONLY "files" 98*7c478bd9Sstevel@tonic-gate #define NSS_FILES_NS "files nis" 99*7c478bd9Sstevel@tonic-gate #define NSS_NS_FALLBACK "nis [NOTFOUND=return] files" 100*7c478bd9Sstevel@tonic-gate #define NSS_NS_ONLY "nis" 101*7c478bd9Sstevel@tonic-gate 102*7c478bd9Sstevel@tonic-gate #define NSS_DEFCONF_ALIASES NSS_FILES_NS 103*7c478bd9Sstevel@tonic-gate #define NSS_DEFCONF_AUTOMOUNT NSS_FILES_NS 104*7c478bd9Sstevel@tonic-gate #define NSS_DEFCONF_BOOTPARAMS NSS_NS_FALLBACK 105*7c478bd9Sstevel@tonic-gate #define NSS_DEFCONF_ETHERS NSS_NS_FALLBACK 106*7c478bd9Sstevel@tonic-gate #define NSS_DEFCONF_GROUP NSS_FILES_NS 107*7c478bd9Sstevel@tonic-gate #define NSS_DEFCONF_HOSTS NSS_NS_FALLBACK 108*7c478bd9Sstevel@tonic-gate #define NSS_DEFCONF_IPNODES NSS_NS_FALLBACK 109*7c478bd9Sstevel@tonic-gate #define NSS_DEFCONF_NETGROUP NSS_NS_ONLY 110*7c478bd9Sstevel@tonic-gate #define NSS_DEFCONF_NETMASKS NSS_NS_FALLBACK 111*7c478bd9Sstevel@tonic-gate #define NSS_DEFCONF_NETWORKS NSS_NS_FALLBACK 112*7c478bd9Sstevel@tonic-gate #define NSS_DEFCONF_PASSWD NSS_FILES_NS 113*7c478bd9Sstevel@tonic-gate #define NSS_DEFCONF_PRINTERS "user files nis nisplus" 114*7c478bd9Sstevel@tonic-gate #define NSS_DEFCONF_PROJECT NSS_FILES_NS 115*7c478bd9Sstevel@tonic-gate #define NSS_DEFCONF_PROTOCOLS NSS_NS_FALLBACK 116*7c478bd9Sstevel@tonic-gate #define NSS_DEFCONF_PUBLICKEY NSS_FILES_NS 117*7c478bd9Sstevel@tonic-gate #define NSS_DEFCONF_RPC NSS_NS_FALLBACK 118*7c478bd9Sstevel@tonic-gate #define NSS_DEFCONF_SERVICES NSS_FILES_NS /* speeds up byname() */ 119*7c478bd9Sstevel@tonic-gate 120*7c478bd9Sstevel@tonic-gate #define NSS_DEFCONF_GROUP_COMPAT NSS_NS_ONLY 121*7c478bd9Sstevel@tonic-gate #define NSS_DEFCONF_PASSWD_COMPAT NSS_NS_ONLY 122*7c478bd9Sstevel@tonic-gate 123*7c478bd9Sstevel@tonic-gate #define NSS_DEFCONF_ATTRDB NSS_FILES_NS 124*7c478bd9Sstevel@tonic-gate 125*7c478bd9Sstevel@tonic-gate #define NSS_DEFCONF_AUDITUSER NSS_DEFCONF_PASSWD 126*7c478bd9Sstevel@tonic-gate #define NSS_DEFCONF_USERATTR NSS_DEFCONF_PASSWD 127*7c478bd9Sstevel@tonic-gate #define NSS_DEFCONF_AUTHATTR NSS_DEFCONF_ATTRDB 128*7c478bd9Sstevel@tonic-gate #define NSS_DEFCONF_PROFATTR NSS_DEFCONF_ATTRDB 129*7c478bd9Sstevel@tonic-gate #define NSS_DEFCONF_EXECATTR NSS_DEFCONF_PROFATTR 130*7c478bd9Sstevel@tonic-gate 131*7c478bd9Sstevel@tonic-gate /* 132*7c478bd9Sstevel@tonic-gate * Line-lengths that the "files" and "compat" backends will try to support. 133*7c478bd9Sstevel@tonic-gate * It may be reasonable (even advisable) to use smaller values than these. 134*7c478bd9Sstevel@tonic-gate */ 135*7c478bd9Sstevel@tonic-gate 136*7c478bd9Sstevel@tonic-gate #define NSS_BUFSIZ 1024 137*7c478bd9Sstevel@tonic-gate 138*7c478bd9Sstevel@tonic-gate #define NSS_LINELEN_GROUP ((NSS_BUFSIZ) * 4) 139*7c478bd9Sstevel@tonic-gate #define NSS_LINELEN_HOSTS ((NSS_BUFSIZ) * 8) 140*7c478bd9Sstevel@tonic-gate #define NSS_LINELEN_IPNODES ((NSS_BUFSIZ) * 8) 141*7c478bd9Sstevel@tonic-gate #define NSS_LINELEN_NETMASKS NSS_BUFSIZ 142*7c478bd9Sstevel@tonic-gate #define NSS_LINELEN_NETWORKS NSS_BUFSIZ 143*7c478bd9Sstevel@tonic-gate #define NSS_LINELEN_PASSWD NSS_BUFSIZ 144*7c478bd9Sstevel@tonic-gate #define NSS_LINELEN_PRINTERS NSS_BUFSIZ 145*7c478bd9Sstevel@tonic-gate #define NSS_LINELEN_PROJECT ((NSS_BUFSIZ) * 4) 146*7c478bd9Sstevel@tonic-gate #define NSS_LINELEN_PROTOCOLS NSS_BUFSIZ 147*7c478bd9Sstevel@tonic-gate #define NSS_LINELEN_PUBLICKEY NSS_BUFSIZ 148*7c478bd9Sstevel@tonic-gate #define NSS_LINELEN_RPC NSS_BUFSIZ 149*7c478bd9Sstevel@tonic-gate #define NSS_LINELEN_SERVICES NSS_BUFSIZ 150*7c478bd9Sstevel@tonic-gate #define NSS_LINELEN_SHADOW NSS_BUFSIZ 151*7c478bd9Sstevel@tonic-gate #define NSS_LINELEN_ETHERS NSS_BUFSIZ 152*7c478bd9Sstevel@tonic-gate #define NSS_LINELEN_BOOTPARAMS NSS_BUFSIZ 153*7c478bd9Sstevel@tonic-gate 154*7c478bd9Sstevel@tonic-gate #define NSS_LINELEN_ATTRDB NSS_BUFSIZ 155*7c478bd9Sstevel@tonic-gate 156*7c478bd9Sstevel@tonic-gate #define NSS_LINELEN_AUDITUSER NSS_LINELEN_ATTRDB 157*7c478bd9Sstevel@tonic-gate #define NSS_LINELEN_AUTHATTR NSS_LINELEN_ATTRDB 158*7c478bd9Sstevel@tonic-gate #define NSS_LINELEN_EXECATTR NSS_LINELEN_ATTRDB 159*7c478bd9Sstevel@tonic-gate #define NSS_LINELEN_PROFATTR NSS_LINELEN_ATTRDB 160*7c478bd9Sstevel@tonic-gate #define NSS_LINELEN_USERATTR NSS_LINELEN_ATTRDB 161*7c478bd9Sstevel@tonic-gate 162*7c478bd9Sstevel@tonic-gate #define NSS_MMAPLEN_EXECATTR NSS_LINELEN_EXECATTR * 8 163*7c478bd9Sstevel@tonic-gate 164*7c478bd9Sstevel@tonic-gate /* 165*7c478bd9Sstevel@tonic-gate * Reasonable defaults for 'buflen' values passed to _r functions. The BSD 166*7c478bd9Sstevel@tonic-gate * and SunOS 4.x implementations of the getXXXbyYYY() functions used hard- 167*7c478bd9Sstevel@tonic-gate * coded array sizes; the values here are meant to handle anything that 168*7c478bd9Sstevel@tonic-gate * those implementations handled. 169*7c478bd9Sstevel@tonic-gate * === These might more reasonably go in <pwd.h>, <netdb.h> et al 170*7c478bd9Sstevel@tonic-gate */ 171*7c478bd9Sstevel@tonic-gate 172*7c478bd9Sstevel@tonic-gate #define NSS_BUFLEN_GROUP (NSS_LINELEN_GROUP + 800 * sizeof (char *)) 173*7c478bd9Sstevel@tonic-gate #define NSS_BUFLEN_HOSTS \ 174*7c478bd9Sstevel@tonic-gate (NSS_LINELEN_HOSTS + (MAXALIASES + MAXADDRS + 2) * sizeof (char *)) 175*7c478bd9Sstevel@tonic-gate #define NSS_BUFLEN_IPNODES \ 176*7c478bd9Sstevel@tonic-gate (NSS_LINELEN_IPNODES + (MAXALIASES + MAXADDRS + 2) * sizeof (char *)) 177*7c478bd9Sstevel@tonic-gate #define NSS_BUFLEN_NETGROUP (MAXHOSTNAMELEN * 2 + LOGNAME_MAX + 3) 178*7c478bd9Sstevel@tonic-gate #define NSS_BUFLEN_NETWORKS NSS_LINELEN_NETWORKS /* === ? + 35 * 4 */ 179*7c478bd9Sstevel@tonic-gate #define NSS_BUFLEN_PASSWD NSS_LINELEN_PASSWD 180*7c478bd9Sstevel@tonic-gate #define NSS_BUFLEN_PROJECT (NSS_LINELEN_PROJECT + 800 * sizeof (char *)) 181*7c478bd9Sstevel@tonic-gate #define NSS_BUFLEN_PROTOCOLS NSS_LINELEN_PROTOCOLS /* === ? + 35 * 4 */ 182*7c478bd9Sstevel@tonic-gate #define NSS_BUFLEN_PUBLICKEY NSS_LINELEN_PUBLICKEY 183*7c478bd9Sstevel@tonic-gate #define NSS_BUFLEN_RPC NSS_LINELEN_RPC /* === ? + 35 * 4 */ 184*7c478bd9Sstevel@tonic-gate #define NSS_BUFLEN_SERVICES NSS_LINELEN_SERVICES /* === ? + 35 * 4 */ 185*7c478bd9Sstevel@tonic-gate #define NSS_BUFLEN_SHADOW NSS_LINELEN_SHADOW 186*7c478bd9Sstevel@tonic-gate #define NSS_BUFLEN_ETHERS NSS_LINELEN_ETHERS 187*7c478bd9Sstevel@tonic-gate #define NSS_BUFLEN_BOOTPARAMS NSS_LINELEN_BOOTPARAMS 188*7c478bd9Sstevel@tonic-gate 189*7c478bd9Sstevel@tonic-gate #define NSS_BUFLEN_ATTRDB NSS_LINELEN_ATTRDB 190*7c478bd9Sstevel@tonic-gate 191*7c478bd9Sstevel@tonic-gate #define NSS_BUFLEN_AUDITUSER NSS_BUFLEN_ATTRDB 192*7c478bd9Sstevel@tonic-gate #define NSS_BUFLEN_AUTHATTR NSS_BUFLEN_ATTRDB 193*7c478bd9Sstevel@tonic-gate #define NSS_BUFLEN_EXECATTR NSS_BUFLEN_ATTRDB 194*7c478bd9Sstevel@tonic-gate #define NSS_BUFLEN_PROFATTR NSS_BUFLEN_ATTRDB 195*7c478bd9Sstevel@tonic-gate #define NSS_BUFLEN_USERATTR NSS_BUFLEN_ATTRDB 196*7c478bd9Sstevel@tonic-gate 197*7c478bd9Sstevel@tonic-gate 198*7c478bd9Sstevel@tonic-gate /* 199*7c478bd9Sstevel@tonic-gate * Arguments and results, passed between the frontends and backends for 200*7c478bd9Sstevel@tonic-gate * the well-known databases. The getXbyY_r() and getXent_r() routines 201*7c478bd9Sstevel@tonic-gate * use a common format that is further described below; other routines 202*7c478bd9Sstevel@tonic-gate * use their own formats. 203*7c478bd9Sstevel@tonic-gate */ 204*7c478bd9Sstevel@tonic-gate 205*7c478bd9Sstevel@tonic-gate /* 206*7c478bd9Sstevel@tonic-gate * The initgroups() function [see initgroups(3c)] needs to find all the 207*7c478bd9Sstevel@tonic-gate * groups to which a given user belongs. To do this it calls 208*7c478bd9Sstevel@tonic-gate * _getgroupsbymember(), which is part of the frontend for the "group" 209*7c478bd9Sstevel@tonic-gate * database. 210*7c478bd9Sstevel@tonic-gate * We want the same effect as if we used getgrent_r() to enumerate the 211*7c478bd9Sstevel@tonic-gate * entire groups database (possibly from multiple sources), but getgrent_r() 212*7c478bd9Sstevel@tonic-gate * is too inefficient. Most backends can do better if they know they're 213*7c478bd9Sstevel@tonic-gate * meant to scan all groups; hence there's a separate backend operation, 214*7c478bd9Sstevel@tonic-gate * NSS_DBOP_GROUP_BYMEMBER, which uses the nss_groupsbymem struct. 215*7c478bd9Sstevel@tonic-gate * Note that the normal return-value from such a backend, even when it 216*7c478bd9Sstevel@tonic-gate * successfully finds matching group entries, is NSS_NOTFOUND, because 217*7c478bd9Sstevel@tonic-gate * this tells the switch engine to keep searching in any more sources. 218*7c478bd9Sstevel@tonic-gate * In fact, the backends only return NSS_SUCCESS if they find enough 219*7c478bd9Sstevel@tonic-gate * matching entries that the gid_array is completely filled, in which 220*7c478bd9Sstevel@tonic-gate * case the switch engine should stop searching. 221*7c478bd9Sstevel@tonic-gate * If the force_slow_way field is set, the backend should eschew any cached 222*7c478bd9Sstevel@tonic-gate * information (e.g. the YP netid.byname map or the NIS+ cred.org_dir table) 223*7c478bd9Sstevel@tonic-gate * and should instead grind its way through the group map/table/whatever. 224*7c478bd9Sstevel@tonic-gate */ 225*7c478bd9Sstevel@tonic-gate 226*7c478bd9Sstevel@tonic-gate struct nss_groupsbymem { /* For _getgroupsbymember() */ 227*7c478bd9Sstevel@tonic-gate /* in: */ 228*7c478bd9Sstevel@tonic-gate const char *username; 229*7c478bd9Sstevel@tonic-gate gid_t *gid_array; 230*7c478bd9Sstevel@tonic-gate int maxgids; 231*7c478bd9Sstevel@tonic-gate int force_slow_way; 232*7c478bd9Sstevel@tonic-gate /* 233*7c478bd9Sstevel@tonic-gate * The process_cstr() routine does the real work for any backend 234*7c478bd9Sstevel@tonic-gate * that can supply a group entry as a string in /etc/group format 235*7c478bd9Sstevel@tonic-gate */ 236*7c478bd9Sstevel@tonic-gate #if defined(__STDC__) 237*7c478bd9Sstevel@tonic-gate int (*str2ent) (const char *instr, 238*7c478bd9Sstevel@tonic-gate int instr_len, 239*7c478bd9Sstevel@tonic-gate void *ent, char *buffer, int buflen); 240*7c478bd9Sstevel@tonic-gate nss_status_t (*process_cstr) (const char *instr, 241*7c478bd9Sstevel@tonic-gate int instr_len, 242*7c478bd9Sstevel@tonic-gate struct nss_groupsbymem *); 243*7c478bd9Sstevel@tonic-gate #else 244*7c478bd9Sstevel@tonic-gate int (*str2ent)(); 245*7c478bd9Sstevel@tonic-gate nss_status_t (*process_cstr)(); 246*7c478bd9Sstevel@tonic-gate #endif 247*7c478bd9Sstevel@tonic-gate 248*7c478bd9Sstevel@tonic-gate /* in_out: */ 249*7c478bd9Sstevel@tonic-gate int numgids; 250*7c478bd9Sstevel@tonic-gate }; 251*7c478bd9Sstevel@tonic-gate 252*7c478bd9Sstevel@tonic-gate /* 253*7c478bd9Sstevel@tonic-gate * The netgroup routines are handled as follows: 254*7c478bd9Sstevel@tonic-gate * 255*7c478bd9Sstevel@tonic-gate * Policy decision: 256*7c478bd9Sstevel@tonic-gate * If netgroup A refers to netgroup B, both must occur in the same 257*7c478bd9Sstevel@tonic-gate * source (other choices give very confusing semantics). This 258*7c478bd9Sstevel@tonic-gate * assumption is deeply embedded in the frontend and backends. 259*7c478bd9Sstevel@tonic-gate * 260*7c478bd9Sstevel@tonic-gate * - setnetgrent(), despite its name, is really a getXXXbyYYY operation: 261*7c478bd9Sstevel@tonic-gate * it takes a name and finds a netgroup with that name (see the 262*7c478bd9Sstevel@tonic-gate * nss_setnetgrent_args struct below). The "result" that it returns 263*7c478bd9Sstevel@tonic-gate * to the frontend is an nss_backend_t for a pseudo-backend that allows 264*7c478bd9Sstevel@tonic-gate * one to enumerate the members of that netgroup. 265*7c478bd9Sstevel@tonic-gate * 266*7c478bd9Sstevel@tonic-gate * - getnetgrent() calls the 'getXXXent' function in the pseudo-backend; 267*7c478bd9Sstevel@tonic-gate * it doesn't go through the switch engine at all. It uses the 268*7c478bd9Sstevel@tonic-gate * nss_getnetgrent_args struct below. 269*7c478bd9Sstevel@tonic-gate * 270*7c478bd9Sstevel@tonic-gate * - innetgr() is implemented on top of __multi_innetgr(), which replaces 271*7c478bd9Sstevel@tonic-gate * each (char *) argument of innetgr() with a counted vector of (char *). 272*7c478bd9Sstevel@tonic-gate * The semantics are the same as an OR of the results of innetgr() 273*7c478bd9Sstevel@tonic-gate * operations on each possible 4-tuple picked from the arguments, but 274*7c478bd9Sstevel@tonic-gate * it's possible to implement some cases more efficiently. This is 275*7c478bd9Sstevel@tonic-gate * important for mountd, which used to read YP netgroup.byhost directly 276*7c478bd9Sstevel@tonic-gate * in order to determine efficiently whether a given host belonged to any 277*7c478bd9Sstevel@tonic-gate * one of a long list of netgroups. Wildcarded arguments are indicated 278*7c478bd9Sstevel@tonic-gate * by a count of zero. 279*7c478bd9Sstevel@tonic-gate * 280*7c478bd9Sstevel@tonic-gate * - __multi_innetgr() uses the nss_innetgr_args struct. A backend whose 281*7c478bd9Sstevel@tonic-gate * source contains at least one of the groups listed in the 'groups' 282*7c478bd9Sstevel@tonic-gate * vector will return NSS_SUCCESS and will set the 'status' field to 283*7c478bd9Sstevel@tonic-gate * indicate whether any 4-tuple was satisfied. A backend will only 284*7c478bd9Sstevel@tonic-gate * return NSS_NOTFOUND if the source contained none of the groups 285*7c478bd9Sstevel@tonic-gate * listed in the 'groups' vector. 286*7c478bd9Sstevel@tonic-gate */ 287*7c478bd9Sstevel@tonic-gate 288*7c478bd9Sstevel@tonic-gate enum nss_netgr_argn { /* We need (machine, user, domain) triples */ 289*7c478bd9Sstevel@tonic-gate NSS_NETGR_MACHINE, 290*7c478bd9Sstevel@tonic-gate NSS_NETGR_USER, 291*7c478bd9Sstevel@tonic-gate NSS_NETGR_DOMAIN, 292*7c478bd9Sstevel@tonic-gate NSS_NETGR_N 293*7c478bd9Sstevel@tonic-gate }; 294*7c478bd9Sstevel@tonic-gate 295*7c478bd9Sstevel@tonic-gate enum nss_netgr_status { /* Status from setnetgrent, multi_innetgr */ 296*7c478bd9Sstevel@tonic-gate NSS_NETGR_FOUND, 297*7c478bd9Sstevel@tonic-gate NSS_NETGR_NO, 298*7c478bd9Sstevel@tonic-gate NSS_NETGR_NOMEM 299*7c478bd9Sstevel@tonic-gate }; 300*7c478bd9Sstevel@tonic-gate 301*7c478bd9Sstevel@tonic-gate struct nss_setnetgrent_args { 302*7c478bd9Sstevel@tonic-gate /* in: */ 303*7c478bd9Sstevel@tonic-gate const char *netgroup; 304*7c478bd9Sstevel@tonic-gate /* out: */ 305*7c478bd9Sstevel@tonic-gate nss_backend_t *iterator; /* <==== Explain */ 306*7c478bd9Sstevel@tonic-gate }; 307*7c478bd9Sstevel@tonic-gate 308*7c478bd9Sstevel@tonic-gate struct nss_getnetgrent_args { 309*7c478bd9Sstevel@tonic-gate /* in: */ 310*7c478bd9Sstevel@tonic-gate char *buffer; 311*7c478bd9Sstevel@tonic-gate int buflen; 312*7c478bd9Sstevel@tonic-gate /* out: */ 313*7c478bd9Sstevel@tonic-gate enum nss_netgr_status status; 314*7c478bd9Sstevel@tonic-gate char *retp[NSS_NETGR_N]; 315*7c478bd9Sstevel@tonic-gate }; 316*7c478bd9Sstevel@tonic-gate 317*7c478bd9Sstevel@tonic-gate typedef unsigned nss_innetgr_argc; /* 0 means wildcard */ 318*7c478bd9Sstevel@tonic-gate typedef char ** nss_innetgr_argv; /* === Do we really need these? */ 319*7c478bd9Sstevel@tonic-gate 320*7c478bd9Sstevel@tonic-gate struct nss_innetgr_1arg { 321*7c478bd9Sstevel@tonic-gate nss_innetgr_argc argc; 322*7c478bd9Sstevel@tonic-gate nss_innetgr_argv argv; 323*7c478bd9Sstevel@tonic-gate }; 324*7c478bd9Sstevel@tonic-gate 325*7c478bd9Sstevel@tonic-gate struct nss_innetgr_args { 326*7c478bd9Sstevel@tonic-gate /* in: */ 327*7c478bd9Sstevel@tonic-gate struct nss_innetgr_1arg arg[NSS_NETGR_N]; 328*7c478bd9Sstevel@tonic-gate struct nss_innetgr_1arg groups; 329*7c478bd9Sstevel@tonic-gate /* out: */ 330*7c478bd9Sstevel@tonic-gate enum nss_netgr_status status; 331*7c478bd9Sstevel@tonic-gate }; 332*7c478bd9Sstevel@tonic-gate 333*7c478bd9Sstevel@tonic-gate 334*7c478bd9Sstevel@tonic-gate /* 335*7c478bd9Sstevel@tonic-gate * nss_XbyY_buf_t -- structure containing the generic arguments passwd to 336*7c478bd9Sstevel@tonic-gate * getXXXbyYYY_r() and getXXXent_r() routines. The (void *) value points to 337*7c478bd9Sstevel@tonic-gate * a struct of the appropriate type, e.g. struct passwd or struct hostent. 338*7c478bd9Sstevel@tonic-gate * 339*7c478bd9Sstevel@tonic-gate * The functions that allocate and free these structures do no locking at 340*7c478bd9Sstevel@tonic-gate * all, since the routines that use them are inherently MT-unsafe anyway. 341*7c478bd9Sstevel@tonic-gate */ 342*7c478bd9Sstevel@tonic-gate 343*7c478bd9Sstevel@tonic-gate typedef struct { 344*7c478bd9Sstevel@tonic-gate void *result; /* "result" parameter to getXbyY_r() */ 345*7c478bd9Sstevel@tonic-gate char *buffer; /* "buffer" " " */ 346*7c478bd9Sstevel@tonic-gate int buflen; /* "buflen" " " */ 347*7c478bd9Sstevel@tonic-gate } nss_XbyY_buf_t; 348*7c478bd9Sstevel@tonic-gate 349*7c478bd9Sstevel@tonic-gate #if defined(__STDC__) 350*7c478bd9Sstevel@tonic-gate extern nss_XbyY_buf_t *_nss_XbyY_buf_alloc(int struct_size, int buffer_size); 351*7c478bd9Sstevel@tonic-gate extern void _nss_XbyY_buf_free(nss_XbyY_buf_t *); 352*7c478bd9Sstevel@tonic-gate #else 353*7c478bd9Sstevel@tonic-gate extern nss_XbyY_buf_t *_nss_XbyY_buf_alloc(); 354*7c478bd9Sstevel@tonic-gate extern void _nss_XbyY_buf_free(); 355*7c478bd9Sstevel@tonic-gate #endif 356*7c478bd9Sstevel@tonic-gate 357*7c478bd9Sstevel@tonic-gate #define NSS_XbyY_ALLOC(bufpp, str_size, buf_size) (\ 358*7c478bd9Sstevel@tonic-gate (*bufpp) == 0 \ 359*7c478bd9Sstevel@tonic-gate ? (*bufpp) = _nss_XbyY_buf_alloc(str_size, buf_size) \ 360*7c478bd9Sstevel@tonic-gate : (*bufpp)) \ 361*7c478bd9Sstevel@tonic-gate 362*7c478bd9Sstevel@tonic-gate #define NSS_XbyY_FREE(bufpp) (_nss_XbyY_buf_free(*bufpp), (*bufpp) = 0) 363*7c478bd9Sstevel@tonic-gate 364*7c478bd9Sstevel@tonic-gate /* 365*7c478bd9Sstevel@tonic-gate * The nss_XbyY_args_t struct contains all the information passed between 366*7c478bd9Sstevel@tonic-gate * frontends and backends for the getXbyY_r() and getXent() routines, 367*7c478bd9Sstevel@tonic-gate * including an nss_XbyY_buf_t and the lookup key (unused for getXXXent_r). 368*7c478bd9Sstevel@tonic-gate * 369*7c478bd9Sstevel@tonic-gate * The (*str2ent)() member converts a single XXXent from ASCII text to the 370*7c478bd9Sstevel@tonic-gate * appropriate struct, storing any pointer data (strings, in_addrs, arrays 371*7c478bd9Sstevel@tonic-gate * of these) in the buffer. The ASCII text is a counted string (*not* a 372*7c478bd9Sstevel@tonic-gate * zero-terminated string) whose length is specified by the instr_len 373*7c478bd9Sstevel@tonic-gate * parameter. The text is found at the address specified by instr and 374*7c478bd9Sstevel@tonic-gate * the string is treated as readonly. buffer and instr must be non- 375*7c478bd9Sstevel@tonic-gate * intersecting memory areas. 376*7c478bd9Sstevel@tonic-gate * 377*7c478bd9Sstevel@tonic-gate * With the exception of passwd, shadow and group, the text form for these 378*7c478bd9Sstevel@tonic-gate * databases allows trailing comments and arbitrary whitespace. The 379*7c478bd9Sstevel@tonic-gate * corresponding str2ent routine assumes that comments, leading whitespace 380*7c478bd9Sstevel@tonic-gate * and trailing whitespace have been stripped (and thus assumes that entries 381*7c478bd9Sstevel@tonic-gate * consisting only of these have been discarded). 382*7c478bd9Sstevel@tonic-gate * 383*7c478bd9Sstevel@tonic-gate * The text entries for "rpc" and for the databases described in <netdb.h> 384*7c478bd9Sstevel@tonic-gate * follow a common format (a canonical name with a possibly empty list 385*7c478bd9Sstevel@tonic-gate * of aliases, and some other value), albeit with minor variations. 386*7c478bd9Sstevel@tonic-gate * The function _nss_netdb_aliases() does most of the generic work involved 387*7c478bd9Sstevel@tonic-gate * in parsing and marshalling these into the buffer. 388*7c478bd9Sstevel@tonic-gate */ 389*7c478bd9Sstevel@tonic-gate 390*7c478bd9Sstevel@tonic-gate union nss_XbyY_key { /* No tag; backend should know what to expect */ 391*7c478bd9Sstevel@tonic-gate uid_t uid; 392*7c478bd9Sstevel@tonic-gate gid_t gid; 393*7c478bd9Sstevel@tonic-gate projid_t projid; 394*7c478bd9Sstevel@tonic-gate const char *name; 395*7c478bd9Sstevel@tonic-gate int number; 396*7c478bd9Sstevel@tonic-gate struct { 397*7c478bd9Sstevel@tonic-gate int net; 398*7c478bd9Sstevel@tonic-gate int type; 399*7c478bd9Sstevel@tonic-gate } netaddr; 400*7c478bd9Sstevel@tonic-gate struct { 401*7c478bd9Sstevel@tonic-gate const char *addr; 402*7c478bd9Sstevel@tonic-gate int len; 403*7c478bd9Sstevel@tonic-gate int type; 404*7c478bd9Sstevel@tonic-gate } hostaddr; 405*7c478bd9Sstevel@tonic-gate struct { 406*7c478bd9Sstevel@tonic-gate union { 407*7c478bd9Sstevel@tonic-gate const char *name; 408*7c478bd9Sstevel@tonic-gate int port; 409*7c478bd9Sstevel@tonic-gate } serv; 410*7c478bd9Sstevel@tonic-gate const char *proto; 411*7c478bd9Sstevel@tonic-gate } serv; 412*7c478bd9Sstevel@tonic-gate void *ether; 413*7c478bd9Sstevel@tonic-gate struct { 414*7c478bd9Sstevel@tonic-gate const char *name; 415*7c478bd9Sstevel@tonic-gate const char *keytype; 416*7c478bd9Sstevel@tonic-gate } pkey; 417*7c478bd9Sstevel@tonic-gate struct { 418*7c478bd9Sstevel@tonic-gate const char *name; 419*7c478bd9Sstevel@tonic-gate int af_family; 420*7c478bd9Sstevel@tonic-gate int flags; 421*7c478bd9Sstevel@tonic-gate } ipnode; 422*7c478bd9Sstevel@tonic-gate void *attrp; /* for the new attr databases */ 423*7c478bd9Sstevel@tonic-gate }; 424*7c478bd9Sstevel@tonic-gate 425*7c478bd9Sstevel@tonic-gate typedef struct nss_XbyY_args { 426*7c478bd9Sstevel@tonic-gate 427*7c478bd9Sstevel@tonic-gate /* IN */ 428*7c478bd9Sstevel@tonic-gate nss_XbyY_buf_t buf; 429*7c478bd9Sstevel@tonic-gate int stayopen; 430*7c478bd9Sstevel@tonic-gate /* 431*7c478bd9Sstevel@tonic-gate * Support for setXXXent(stayopen) 432*7c478bd9Sstevel@tonic-gate * Used only in hosts, protocols, 433*7c478bd9Sstevel@tonic-gate * networks, rpc, and services. 434*7c478bd9Sstevel@tonic-gate */ 435*7c478bd9Sstevel@tonic-gate #if defined(__STDC__) 436*7c478bd9Sstevel@tonic-gate int (*str2ent) (const char *instr, 437*7c478bd9Sstevel@tonic-gate int instr_len, 438*7c478bd9Sstevel@tonic-gate void *ent, char *buffer, int buflen); 439*7c478bd9Sstevel@tonic-gate #else 440*7c478bd9Sstevel@tonic-gate int (*str2ent)(); 441*7c478bd9Sstevel@tonic-gate #endif 442*7c478bd9Sstevel@tonic-gate union nss_XbyY_key key; 443*7c478bd9Sstevel@tonic-gate 444*7c478bd9Sstevel@tonic-gate /* OUT */ 445*7c478bd9Sstevel@tonic-gate void *returnval; 446*7c478bd9Sstevel@tonic-gate int erange; 447*7c478bd9Sstevel@tonic-gate int h_errno; /* For gethost*_r() */ 448*7c478bd9Sstevel@tonic-gate nss_status_t status; /* from the backend last called */ 449*7c478bd9Sstevel@tonic-gate } nss_XbyY_args_t; 450*7c478bd9Sstevel@tonic-gate 451*7c478bd9Sstevel@tonic-gate /* status returned by the str2ent parsing routines */ 452*7c478bd9Sstevel@tonic-gate #define NSS_STR_PARSE_SUCCESS 0 453*7c478bd9Sstevel@tonic-gate #define NSS_STR_PARSE_PARSE 1 454*7c478bd9Sstevel@tonic-gate #define NSS_STR_PARSE_ERANGE 2 455*7c478bd9Sstevel@tonic-gate 456*7c478bd9Sstevel@tonic-gate #define NSS_XbyY_INIT(str, res, bufp, len, func) (\ 457*7c478bd9Sstevel@tonic-gate (str)->buf.result = (res), \ 458*7c478bd9Sstevel@tonic-gate (str)->buf.buffer = (bufp), \ 459*7c478bd9Sstevel@tonic-gate (str)->buf.buflen = (len), \ 460*7c478bd9Sstevel@tonic-gate (str)->stayopen = 0, \ 461*7c478bd9Sstevel@tonic-gate (str)->str2ent = (func), \ 462*7c478bd9Sstevel@tonic-gate (str)->returnval = 0, \ 463*7c478bd9Sstevel@tonic-gate (str)->erange = 0) 464*7c478bd9Sstevel@tonic-gate 465*7c478bd9Sstevel@tonic-gate #define NSS_XbyY_FINI(str) (\ 466*7c478bd9Sstevel@tonic-gate (str)->returnval == 0 && (str)->erange && (errno = ERANGE), \ 467*7c478bd9Sstevel@tonic-gate (str)->returnval) 468*7c478bd9Sstevel@tonic-gate 469*7c478bd9Sstevel@tonic-gate #if defined(__STDC__) 470*7c478bd9Sstevel@tonic-gate extern char **_nss_netdb_aliases 471*7c478bd9Sstevel@tonic-gate (const char *, int, char *, int); 472*7c478bd9Sstevel@tonic-gate #else 473*7c478bd9Sstevel@tonic-gate extern char **_nss_netdb_aliases(); 474*7c478bd9Sstevel@tonic-gate #endif 475*7c478bd9Sstevel@tonic-gate 476*7c478bd9Sstevel@tonic-gate /* 477*7c478bd9Sstevel@tonic-gate * nss_dbop_t values for searches with various keys; values for 478*7c478bd9Sstevel@tonic-gate * destructor/endent/setent/getent are defined in <nss_common.h> 479*7c478bd9Sstevel@tonic-gate */ 480*7c478bd9Sstevel@tonic-gate 481*7c478bd9Sstevel@tonic-gate #define NSS_DBOP_GROUP_BYNAME (NSS_DBOP_next_iter) 482*7c478bd9Sstevel@tonic-gate #define NSS_DBOP_GROUP_BYGID (NSS_DBOP_GROUP_BYNAME + 1) 483*7c478bd9Sstevel@tonic-gate #define NSS_DBOP_GROUP_BYMEMBER (NSS_DBOP_GROUP_BYGID + 1) 484*7c478bd9Sstevel@tonic-gate 485*7c478bd9Sstevel@tonic-gate #define NSS_DBOP_PASSWD_BYNAME (NSS_DBOP_next_iter) 486*7c478bd9Sstevel@tonic-gate #define NSS_DBOP_PASSWD_BYUID (NSS_DBOP_PASSWD_BYNAME + 1) 487*7c478bd9Sstevel@tonic-gate 488*7c478bd9Sstevel@tonic-gate /* The "compat" backend requires that PASSWD_BYNAME == SHADOW_BYNAME */ 489*7c478bd9Sstevel@tonic-gate /* (it also requires that both use key.name to pass the username). */ 490*7c478bd9Sstevel@tonic-gate #define NSS_DBOP_SHADOW_BYNAME (NSS_DBOP_PASSWD_BYNAME) 491*7c478bd9Sstevel@tonic-gate 492*7c478bd9Sstevel@tonic-gate #define NSS_DBOP_PROJECT_BYNAME (NSS_DBOP_next_iter) 493*7c478bd9Sstevel@tonic-gate #define NSS_DBOP_PROJECT_BYID (NSS_DBOP_PROJECT_BYNAME + 1) 494*7c478bd9Sstevel@tonic-gate 495*7c478bd9Sstevel@tonic-gate #define NSS_DBOP_HOSTS_BYNAME (NSS_DBOP_next_iter) 496*7c478bd9Sstevel@tonic-gate #define NSS_DBOP_HOSTS_BYADDR (NSS_DBOP_HOSTS_BYNAME + 1) 497*7c478bd9Sstevel@tonic-gate 498*7c478bd9Sstevel@tonic-gate #define NSS_DBOP_IPNODES_BYNAME (NSS_DBOP_next_iter) 499*7c478bd9Sstevel@tonic-gate #define NSS_DBOP_IPNODES_BYADDR (NSS_DBOP_IPNODES_BYNAME + 1) 500*7c478bd9Sstevel@tonic-gate 501*7c478bd9Sstevel@tonic-gate /* 502*7c478bd9Sstevel@tonic-gate * NSS_DBOP_NAME_2ADDR 503*7c478bd9Sstevel@tonic-gate * NSS_DBOP_ADDR_2NAME 504*7c478bd9Sstevel@tonic-gate * : are defines for ipv6 api's 505*7c478bd9Sstevel@tonic-gate */ 506*7c478bd9Sstevel@tonic-gate 507*7c478bd9Sstevel@tonic-gate #define NSS_DBOP_NAME_2ADDR (NSS_DBOP_next_ipv6_iter) 508*7c478bd9Sstevel@tonic-gate #define NSS_DBOP_ADDR_2NAME (NSS_DBOP_NAME_2ADDR + 1) 509*7c478bd9Sstevel@tonic-gate 510*7c478bd9Sstevel@tonic-gate #define NSS_DBOP_RPC_BYNAME (NSS_DBOP_next_iter) 511*7c478bd9Sstevel@tonic-gate #define NSS_DBOP_RPC_BYNUMBER (NSS_DBOP_RPC_BYNAME + 1) 512*7c478bd9Sstevel@tonic-gate 513*7c478bd9Sstevel@tonic-gate #define NSS_DBOP_NETWORKS_BYNAME (NSS_DBOP_next_iter) 514*7c478bd9Sstevel@tonic-gate #define NSS_DBOP_NETWORKS_BYADDR (NSS_DBOP_NETWORKS_BYNAME + 1) 515*7c478bd9Sstevel@tonic-gate 516*7c478bd9Sstevel@tonic-gate #define NSS_DBOP_SERVICES_BYNAME (NSS_DBOP_next_iter) 517*7c478bd9Sstevel@tonic-gate #define NSS_DBOP_SERVICES_BYPORT (NSS_DBOP_SERVICES_BYNAME + 1) 518*7c478bd9Sstevel@tonic-gate 519*7c478bd9Sstevel@tonic-gate #define NSS_DBOP_PROTOCOLS_BYNAME (NSS_DBOP_next_iter) 520*7c478bd9Sstevel@tonic-gate #define NSS_DBOP_PROTOCOLS_BYNUMBER (NSS_DBOP_PROTOCOLS_BYNAME + 1) 521*7c478bd9Sstevel@tonic-gate 522*7c478bd9Sstevel@tonic-gate #define NSS_DBOP_ETHERS_HOSTTON (NSS_DBOP_next_noiter) 523*7c478bd9Sstevel@tonic-gate #define NSS_DBOP_ETHERS_NTOHOST (NSS_DBOP_ETHERS_HOSTTON + 1) 524*7c478bd9Sstevel@tonic-gate 525*7c478bd9Sstevel@tonic-gate #define NSS_DBOP_BOOTPARAMS_BYNAME (NSS_DBOP_next_noiter) 526*7c478bd9Sstevel@tonic-gate #define NSS_DBOP_NETMASKS_BYNET (NSS_DBOP_next_noiter) 527*7c478bd9Sstevel@tonic-gate 528*7c478bd9Sstevel@tonic-gate #define NSS_DBOP_PRINTERS_BYNAME (NSS_DBOP_next_iter) 529*7c478bd9Sstevel@tonic-gate 530*7c478bd9Sstevel@tonic-gate /* 531*7c478bd9Sstevel@tonic-gate * The "real" backend for netgroup (__multi_innetgr, setnetgrent) 532*7c478bd9Sstevel@tonic-gate */ 533*7c478bd9Sstevel@tonic-gate #define NSS_DBOP_NETGROUP_IN (NSS_DBOP_next_iter) 534*7c478bd9Sstevel@tonic-gate #define NSS_DBOP_NETGROUP_SET (NSS_DBOP_NETGROUP_IN + 1) 535*7c478bd9Sstevel@tonic-gate 536*7c478bd9Sstevel@tonic-gate /* 537*7c478bd9Sstevel@tonic-gate * The backend for getpublickey and getsecretkey (getkeys) 538*7c478bd9Sstevel@tonic-gate */ 539*7c478bd9Sstevel@tonic-gate #define NSS_DBOP_KEYS_BYNAME (NSS_DBOP_next_iter) 540*7c478bd9Sstevel@tonic-gate 541*7c478bd9Sstevel@tonic-gate /* 542*7c478bd9Sstevel@tonic-gate * The pseudo-backend for netgroup (returned by setnetgrent) doesn't have 543*7c478bd9Sstevel@tonic-gate * any getXXXbyYYY operations, just the usual destr/end/set/get ops, 544*7c478bd9Sstevel@tonic-gate * so needs no definitions here. 545*7c478bd9Sstevel@tonic-gate */ 546*7c478bd9Sstevel@tonic-gate 547*7c478bd9Sstevel@tonic-gate #define NSS_DBOP_ATTRDB_BYNAME (NSS_DBOP_next_iter) 548*7c478bd9Sstevel@tonic-gate 549*7c478bd9Sstevel@tonic-gate #define NSS_DBOP_AUDITUSER_BYNAME NSS_DBOP_ATTRDB_BYNAME 550*7c478bd9Sstevel@tonic-gate #define NSS_DBOP_AUTHATTR_BYNAME NSS_DBOP_ATTRDB_BYNAME 551*7c478bd9Sstevel@tonic-gate #define NSS_DBOP_EXECATTR_BYNAME NSS_DBOP_ATTRDB_BYNAME 552*7c478bd9Sstevel@tonic-gate #define NSS_DBOP_EXECATTR_BYID (NSS_DBOP_EXECATTR_BYNAME + 1) 553*7c478bd9Sstevel@tonic-gate #define NSS_DBOP_EXECATTR_BYNAMEID (NSS_DBOP_EXECATTR_BYID + 1) 554*7c478bd9Sstevel@tonic-gate #define NSS_DBOP_PROFATTR_BYNAME NSS_DBOP_ATTRDB_BYNAME 555*7c478bd9Sstevel@tonic-gate #define NSS_DBOP_USERATTR_BYNAME NSS_DBOP_ATTRDB_BYNAME 556*7c478bd9Sstevel@tonic-gate 557*7c478bd9Sstevel@tonic-gate /* 558*7c478bd9Sstevel@tonic-gate * Used all over in the switch code. The best home for it I can think of. 559*7c478bd9Sstevel@tonic-gate * Power-of-two alignments only. 560*7c478bd9Sstevel@tonic-gate */ 561*7c478bd9Sstevel@tonic-gate #define ROUND_DOWN(n, align) (((uintptr_t)n) & ~((align) - 1l)) 562*7c478bd9Sstevel@tonic-gate #define ROUND_UP(n, align) ROUND_DOWN(((uintptr_t)n) + (align) - 1l, \ 563*7c478bd9Sstevel@tonic-gate (align)) 564*7c478bd9Sstevel@tonic-gate 565*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 566*7c478bd9Sstevel@tonic-gate } 567*7c478bd9Sstevel@tonic-gate #endif 568*7c478bd9Sstevel@tonic-gate 569*7c478bd9Sstevel@tonic-gate #endif /* _NSS_DBDEFS_H */ 570