1*0Sstevel@tonic-gate /* 2*0Sstevel@tonic-gate * CDDL HEADER START 3*0Sstevel@tonic-gate * 4*0Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*0Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*0Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*0Sstevel@tonic-gate * with the License. 8*0Sstevel@tonic-gate * 9*0Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*0Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*0Sstevel@tonic-gate * See the License for the specific language governing permissions 12*0Sstevel@tonic-gate * and limitations under the License. 13*0Sstevel@tonic-gate * 14*0Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*0Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*0Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*0Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*0Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*0Sstevel@tonic-gate * 20*0Sstevel@tonic-gate * CDDL HEADER END 21*0Sstevel@tonic-gate */ 22*0Sstevel@tonic-gate /* 23*0Sstevel@tonic-gate * Copyright (c) 1992-1999 by Sun Microsystems, Inc. 24*0Sstevel@tonic-gate * All rights reserved. 25*0Sstevel@tonic-gate */ 26*0Sstevel@tonic-gate 27*0Sstevel@tonic-gate /* 28*0Sstevel@tonic-gate * 29*0Sstevel@tonic-gate * NOTE: The interfaces documented in this file may change in a minor 30*0Sstevel@tonic-gate * release. It is intended that in the future a stronger committment 31*0Sstevel@tonic-gate * will be made to these interface definitions which will guarantee 32*0Sstevel@tonic-gate * them across minor releases. 33*0Sstevel@tonic-gate */ 34*0Sstevel@tonic-gate 35*0Sstevel@tonic-gate #ifndef _NSS_COMMON_H 36*0Sstevel@tonic-gate #define _NSS_COMMON_H 37*0Sstevel@tonic-gate 38*0Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 39*0Sstevel@tonic-gate 40*0Sstevel@tonic-gate #include <synch.h> 41*0Sstevel@tonic-gate 42*0Sstevel@tonic-gate #ifdef __cplusplus 43*0Sstevel@tonic-gate extern "C" { 44*0Sstevel@tonic-gate #endif 45*0Sstevel@tonic-gate 46*0Sstevel@tonic-gate /* 47*0Sstevel@tonic-gate * The name-service switch 48*0Sstevel@tonic-gate * ----------------------- 49*0Sstevel@tonic-gate * 50*0Sstevel@tonic-gate * From nsswitch.conf(4): 51*0Sstevel@tonic-gate * 52*0Sstevel@tonic-gate * The operating system uses a number of ``databases'' of information 53*0Sstevel@tonic-gate * about hosts, users (passwd/shadow), groups and so forth. Data for 54*0Sstevel@tonic-gate * these can come from a variety of ``sources'': host-names and 55*0Sstevel@tonic-gate * -addresses, for example, may be found in /etc/hosts, NIS, NIS+ or 56*0Sstevel@tonic-gate * DNS. One or more sources may be used for each database; the 57*0Sstevel@tonic-gate * sources and their lookup order are specified in the 58*0Sstevel@tonic-gate * /etc/nsswitch.conf file. 59*0Sstevel@tonic-gate * 60*0Sstevel@tonic-gate * The implementation of this consists of: 61*0Sstevel@tonic-gate * 62*0Sstevel@tonic-gate * - a ``frontend'' for each database, which provides a programming 63*0Sstevel@tonic-gate * interface for that database [for example, the "passwd" frontend 64*0Sstevel@tonic-gate * consists of getpwnam_r(), getpwuid_r(), getpwent_r(), setpwent(), 65*0Sstevel@tonic-gate * endpwent(), and the old MT-unsafe routines getpwnam() and getpwuid()] 66*0Sstevel@tonic-gate * and is implemented by calls to... 67*0Sstevel@tonic-gate * 68*0Sstevel@tonic-gate * - the common core of the switch (``switch engine''); it determines 69*0Sstevel@tonic-gate * which sources to use and invokes... 70*0Sstevel@tonic-gate * 71*0Sstevel@tonic-gate * - A ``backend'' for each useful <database, source> pair. Each backend 72*0Sstevel@tonic-gate * consists of whatever private data it needs and a set of functions 73*0Sstevel@tonic-gate * that the switch engine may invoke on behalf of the frontend 74*0Sstevel@tonic-gate * [e.g. the "nis" backend for "passwd" provides routines to lookup 75*0Sstevel@tonic-gate * by name and by uid, as well as set/get/end iterator routines]. 76*0Sstevel@tonic-gate * The set of functions, and their expected arguments and results, 77*0Sstevel@tonic-gate * constitutes a (database-specific) interface between a frontend and 78*0Sstevel@tonic-gate * all its backends. The switch engine knows as little as possible 79*0Sstevel@tonic-gate * about these interfaces. 80*0Sstevel@tonic-gate * 81*0Sstevel@tonic-gate * (The term ``backend'' is used ambiguously; it may also refer to a 82*0Sstevel@tonic-gate * particular instantiation of a backend, or to the set of all backends 83*0Sstevel@tonic-gate * for a particular source, e.g. "the nis backend"). 84*0Sstevel@tonic-gate * 85*0Sstevel@tonic-gate * This header file defines the interface between the switch engine and the 86*0Sstevel@tonic-gate * frontends and backends. Interfaces between specific frontends and 87*0Sstevel@tonic-gate * backends are defined elsewhere; many are in <nss_dbdefs.h>. 88*0Sstevel@tonic-gate * 89*0Sstevel@tonic-gate * 90*0Sstevel@tonic-gate * Switch-engine outline 91*0Sstevel@tonic-gate * --------------------- 92*0Sstevel@tonic-gate * 93*0Sstevel@tonic-gate * Frontends may call the following routines in the switch engine: 94*0Sstevel@tonic-gate * 95*0Sstevel@tonic-gate * nss_search() does getXXXbyYYY, e.g. getpwnam_r(), getpwuid_r() 96*0Sstevel@tonic-gate * nss_getent() does getXXXent, e.g. getpwent_r() 97*0Sstevel@tonic-gate * nss_setent() does setXXXent, e.g. setpwent() 98*0Sstevel@tonic-gate * nss_endent() does endXXXent, e.g. endpwent() 99*0Sstevel@tonic-gate * nss_delete() releases resources, in the style of endpwent(). 100*0Sstevel@tonic-gate * 101*0Sstevel@tonic-gate * A getpwnam_r() call might proceed thus (with many details omitted): 102*0Sstevel@tonic-gate * 103*0Sstevel@tonic-gate * (1) getpwnam_r fills in (getpwnam-specific) argument/result struct, 104*0Sstevel@tonic-gate * calls nss_search(), 105*0Sstevel@tonic-gate * (2) nss_search looks up configuration info, gets "passwd: files nis", 106*0Sstevel@tonic-gate * (3) nss_search decides to try first source ("files"), 107*0Sstevel@tonic-gate * (a) nss_search locates code for <"passwd", "files"> backend, 108*0Sstevel@tonic-gate * (b) nss_search creates instance of backend, 109*0Sstevel@tonic-gate * (c) nss_search calls get-by-name routine in backend, 110*0Sstevel@tonic-gate * (d) backend searches /etc/passwd, doesn't find the name, 111*0Sstevel@tonic-gate * returns "not found" status to nss_search, 112*0Sstevel@tonic-gate * (4) nss_search examines status and config info, decides to try 113*0Sstevel@tonic-gate * next source ("nis"), 114*0Sstevel@tonic-gate * (a) nss_search locates code for <"passwd", "nis"> backend, 115*0Sstevel@tonic-gate * (b) nss_search creates instance of backend, 116*0Sstevel@tonic-gate * (c) nss_search calls get-by-name routine in backend, 117*0Sstevel@tonic-gate * (d) backend searches passwd.byname, finds the desired entry, 118*0Sstevel@tonic-gate * fills in the result part of the getpwnam-specific 119*0Sstevel@tonic-gate * struct, returns "success" status to nss_search, 120*0Sstevel@tonic-gate * (5) nss_search examines status and config info, decides to return 121*0Sstevel@tonic-gate * to caller, 122*0Sstevel@tonic-gate * (6) getpwnam_r extracts result from getpwnam-specific struct, 123*0Sstevel@tonic-gate * returns to caller. 124*0Sstevel@tonic-gate * 125*0Sstevel@tonic-gate * 126*0Sstevel@tonic-gate * Data structures 127*0Sstevel@tonic-gate * --------------- 128*0Sstevel@tonic-gate * 129*0Sstevel@tonic-gate * Both databases and sources are represented by case-sensitive strings 130*0Sstevel@tonic-gate * (the same strings that appear in the configuration file). 131*0Sstevel@tonic-gate * 132*0Sstevel@tonic-gate * The switch engine maintains a per-frontend data structure so that the 133*0Sstevel@tonic-gate * results of steps (2), (a) and (b) can be cached. The frontend holds a 134*0Sstevel@tonic-gate * handle (nss_db_root_t) to this structure and passes it in to the 135*0Sstevel@tonic-gate * nss_*() routines. 136*0Sstevel@tonic-gate * 137*0Sstevel@tonic-gate * The nss_setent(), nss_getent() and nss_endent() routines introduce another 138*0Sstevel@tonic-gate * variety of state (the current position in the enumeration process). 139*0Sstevel@tonic-gate * Within a single source, this information is maintained by private data 140*0Sstevel@tonic-gate * in the backend instance -- but, in the presence of multiple sources, the 141*0Sstevel@tonic-gate * switch engine must keep track of the current backend instance [e.g either 142*0Sstevel@tonic-gate * <"passwd", "files"> or <"passwd", "nis"> instances]. The switch engine 143*0Sstevel@tonic-gate * has a separate per-enumeration data structure for this; again, the 144*0Sstevel@tonic-gate * frontend holds a handle (nss_getent_t) and passes it in, along with the 145*0Sstevel@tonic-gate * nss_db_root_t handle, to nss_setent(), nss_getent() and nss_endent(). 146*0Sstevel@tonic-gate * 147*0Sstevel@tonic-gate * 148*0Sstevel@tonic-gate * Multithreading 149*0Sstevel@tonic-gate * -------------- 150*0Sstevel@tonic-gate * 151*0Sstevel@tonic-gate * The switch engine takes care of locking; frontends should be written to 152*0Sstevel@tonic-gate * be reentrant, and a backend instance may assume that all calls to it are 153*0Sstevel@tonic-gate * serialized. 154*0Sstevel@tonic-gate * 155*0Sstevel@tonic-gate * If multiple threads simultaneously want to use a particular backend, the 156*0Sstevel@tonic-gate * switch engine creates multiple backend instances (up to some limit 157*0Sstevel@tonic-gate * specified by the frontend). Backends must of course lock any state that 158*0Sstevel@tonic-gate * is shared between instances, and must serialize calls to any MT-unsafe 159*0Sstevel@tonic-gate * code. 160*0Sstevel@tonic-gate * 161*0Sstevel@tonic-gate * The switch engine has no notion of per-thread state. 162*0Sstevel@tonic-gate * 163*0Sstevel@tonic-gate * Frontends can use the nss_getent_t handle to define the scope of the 164*0Sstevel@tonic-gate * enumeration (set/get/endXXXent) state: a static handle gives global state 165*0Sstevel@tonic-gate * (which is what Posix has specified for the getXXXent_r routines), handles 166*0Sstevel@tonic-gate * in Thread-Specific Data give per-thread state, and handles on the stack 167*0Sstevel@tonic-gate * give per-invocation state. 168*0Sstevel@tonic-gate */ 169*0Sstevel@tonic-gate 170*0Sstevel@tonic-gate 171*0Sstevel@tonic-gate /* 172*0Sstevel@tonic-gate * Backend instances 173*0Sstevel@tonic-gate * ----------------- 174*0Sstevel@tonic-gate * 175*0Sstevel@tonic-gate * As far as the switch engine is concerned, an instance of a backend is a 176*0Sstevel@tonic-gate * struct whose first two members are: 177*0Sstevel@tonic-gate * - A pointer to a vector of function pointers, one for each 178*0Sstevel@tonic-gate * database-specific function, 179*0Sstevel@tonic-gate * - The length of the vector (an int), used for bounds-checking. 180*0Sstevel@tonic-gate * There are four well-known function slots in the vector: 181*0Sstevel@tonic-gate * [0] is a destructor for the backend instance, 182*0Sstevel@tonic-gate * [1] is the endXXXent routine, 183*0Sstevel@tonic-gate * [2] is the setXXXent routine, 184*0Sstevel@tonic-gate * [3] is the getXXXent routine. 185*0Sstevel@tonic-gate * Any other slots are database-specific getXXXbyYYY routines; the frontend 186*0Sstevel@tonic-gate * specifies a slot-number to nss_search(). 187*0Sstevel@tonic-gate * 188*0Sstevel@tonic-gate * The functions take two arguments: 189*0Sstevel@tonic-gate * - a pointer to the backend instance (like a C++ "this" pointer) 190*0Sstevel@tonic-gate * - a single (void *) pointer to the database-specific argument/result 191*0Sstevel@tonic-gate * structure (the contents are opaque to the switch engine). 192*0Sstevel@tonic-gate * The four well-known functions ignore the (void *) pointer. 193*0Sstevel@tonic-gate * 194*0Sstevel@tonic-gate * Backend routines return one of five status codes to the switch engine: 195*0Sstevel@tonic-gate * SUCCESS, UNAVAIL, NOTFOUND, TRYAGAIN (these are the same codes that may 196*0Sstevel@tonic-gate * be specified in the config information; see nsswitch.conf(4)), or 197*0Sstevel@tonic-gate * NSS_NISSERVDNS_TRYAGAIN (should only be used by the NIS backend for 198*0Sstevel@tonic-gate * NIS server in DNS forwarding mode to indicate DNS server non-response). 199*0Sstevel@tonic-gate */ 200*0Sstevel@tonic-gate 201*0Sstevel@tonic-gate typedef enum { 202*0Sstevel@tonic-gate NSS_SUCCESS, 203*0Sstevel@tonic-gate NSS_NOTFOUND, 204*0Sstevel@tonic-gate NSS_UNAVAIL, 205*0Sstevel@tonic-gate NSS_TRYAGAIN, 206*0Sstevel@tonic-gate NSS_NISSERVDNS_TRYAGAIN 207*0Sstevel@tonic-gate } nss_status_t; 208*0Sstevel@tonic-gate 209*0Sstevel@tonic-gate struct nss_backend; 210*0Sstevel@tonic-gate 211*0Sstevel@tonic-gate #if defined(__STDC__) 212*0Sstevel@tonic-gate typedef nss_status_t (*nss_backend_op_t)(struct nss_backend *, void *args); 213*0Sstevel@tonic-gate #else 214*0Sstevel@tonic-gate typedef nss_status_t (*nss_backend_op_t)(); 215*0Sstevel@tonic-gate #endif 216*0Sstevel@tonic-gate 217*0Sstevel@tonic-gate struct nss_backend { 218*0Sstevel@tonic-gate nss_backend_op_t *ops; 219*0Sstevel@tonic-gate int n_ops; 220*0Sstevel@tonic-gate }; 221*0Sstevel@tonic-gate typedef struct nss_backend nss_backend_t; 222*0Sstevel@tonic-gate typedef int nss_dbop_t; 223*0Sstevel@tonic-gate 224*0Sstevel@tonic-gate #define NSS_DBOP_DESTRUCTOR 0 225*0Sstevel@tonic-gate #define NSS_DBOP_ENDENT 1 226*0Sstevel@tonic-gate #define NSS_DBOP_SETENT 2 227*0Sstevel@tonic-gate #define NSS_DBOP_GETENT 3 228*0Sstevel@tonic-gate #define NSS_DBOP_next_iter (NSS_DBOP_GETENT + 1) 229*0Sstevel@tonic-gate #define NSS_DBOP_next_noiter (NSS_DBOP_DESTRUCTOR + 1) 230*0Sstevel@tonic-gate #define NSS_DBOP_next_ipv6_iter (NSS_DBOP_GETENT + 3) 231*0Sstevel@tonic-gate 232*0Sstevel@tonic-gate #define NSS_LOOKUP_DBOP(instp, n) \ 233*0Sstevel@tonic-gate (((n) >= 0 && (n) < (instp)->n_ops) ? (instp)->ops[n] : 0) 234*0Sstevel@tonic-gate 235*0Sstevel@tonic-gate #define NSS_INVOKE_DBOP(instp, n, argp) (\ 236*0Sstevel@tonic-gate ((n) >= 0 && (n) < (instp)->n_ops && (instp)->ops[n] != 0) \ 237*0Sstevel@tonic-gate ? (*(instp)->ops[n])(instp, argp) \ 238*0Sstevel@tonic-gate : NSS_UNAVAIL) 239*0Sstevel@tonic-gate 240*0Sstevel@tonic-gate /* 241*0Sstevel@tonic-gate * Locating and instantiating backends 242*0Sstevel@tonic-gate * ----------------------------------- 243*0Sstevel@tonic-gate * 244*0Sstevel@tonic-gate * To perform step (a), the switch consults a list of backend-finder routines, 245*0Sstevel@tonic-gate * passing a <database, source> pair. 246*0Sstevel@tonic-gate * 247*0Sstevel@tonic-gate * There is a standard backend-finder; frontends may augment or replace this 248*0Sstevel@tonic-gate * in order to, say, indicate that some backends are "compiled in" with the 249*0Sstevel@tonic-gate * frontend. 250*0Sstevel@tonic-gate * 251*0Sstevel@tonic-gate * Backend-finders return a pointer to a constructor function for the backend. 252*0Sstevel@tonic-gate * (or NULL if they can't find the backend). The switch engine caches these 253*0Sstevel@tonic-gate * function pointers; when it needs to perform step (b), it calls the 254*0Sstevel@tonic-gate * constructor function, which returns a pointer to a new instance of the 255*0Sstevel@tonic-gate * backend, properly initialized (or returns NULL). 256*0Sstevel@tonic-gate */ 257*0Sstevel@tonic-gate 258*0Sstevel@tonic-gate #if defined(__STDC__) 259*0Sstevel@tonic-gate typedef nss_backend_t * (*nss_backend_constr_t)(const char *db_name, 260*0Sstevel@tonic-gate const char *src_name, 261*0Sstevel@tonic-gate /* Hook for (unimplemented) args in nsswitch.conf */ const char *cfg_args); 262*0Sstevel@tonic-gate #else 263*0Sstevel@tonic-gate typedef nss_backend_t * (*nss_backend_constr_t)(); 264*0Sstevel@tonic-gate #endif 265*0Sstevel@tonic-gate 266*0Sstevel@tonic-gate struct nss_backend_finder { 267*0Sstevel@tonic-gate #if defined(__STDC__) 268*0Sstevel@tonic-gate nss_backend_constr_t (*lookup) 269*0Sstevel@tonic-gate (void *lkp_priv, const char *, const char *, void **del_privp); 270*0Sstevel@tonic-gate void (*delete) 271*0Sstevel@tonic-gate (void *del_priv, nss_backend_constr_t); 272*0Sstevel@tonic-gate #else 273*0Sstevel@tonic-gate nss_backend_constr_t (*lookup)(); 274*0Sstevel@tonic-gate void (*delete)(); 275*0Sstevel@tonic-gate #endif 276*0Sstevel@tonic-gate struct nss_backend_finder *next; 277*0Sstevel@tonic-gate void *lookup_priv; 278*0Sstevel@tonic-gate }; 279*0Sstevel@tonic-gate 280*0Sstevel@tonic-gate typedef struct nss_backend_finder nss_backend_finder_t; 281*0Sstevel@tonic-gate 282*0Sstevel@tonic-gate extern nss_backend_finder_t *nss_default_finders; 283*0Sstevel@tonic-gate 284*0Sstevel@tonic-gate /* 285*0Sstevel@tonic-gate * Frontend parameters 286*0Sstevel@tonic-gate * ------------------- 287*0Sstevel@tonic-gate * 288*0Sstevel@tonic-gate * The frontend must tell the switch engine: 289*0Sstevel@tonic-gate * - the database name, 290*0Sstevel@tonic-gate * - the compiled-in default configuration entry. 291*0Sstevel@tonic-gate * It may also override default values for: 292*0Sstevel@tonic-gate * - the database name to use when looking up the configuration 293*0Sstevel@tonic-gate * information (e.g. "shadow" uses the config entry for "passwd"), 294*0Sstevel@tonic-gate * - a limit on the number of instances of each backend that are 295*0Sstevel@tonic-gate * simultaneously active, 296*0Sstevel@tonic-gate * - a limit on the number of instances of each backend that are 297*0Sstevel@tonic-gate * simultaneously dormant (waiting for new requests), 298*0Sstevel@tonic-gate * - a flag that tells the switch engine to use the default configuration 299*0Sstevel@tonic-gate * entry and ignore any other config entry for this database, 300*0Sstevel@tonic-gate * - backend-finders (see above) 301*0Sstevel@tonic-gate * - a cleanup routine that should be called when these parameters are 302*0Sstevel@tonic-gate * about to be deleted. 303*0Sstevel@tonic-gate * 304*0Sstevel@tonic-gate * In order to do this, the frontend includes a pointer to an initialization 305*0Sstevel@tonic-gate * function (nss_db_initf_t) in every nss_*() call. When necessary (normally 306*0Sstevel@tonic-gate * just on the first invocation), the switch engine allocates a parameter 307*0Sstevel@tonic-gate * structure (nss_db_params_t), fills in the default values, then calls 308*0Sstevel@tonic-gate * the initialization function, which should update the parameter structure 309*0Sstevel@tonic-gate * as necessary. 310*0Sstevel@tonic-gate * 311*0Sstevel@tonic-gate * (This might look more natural if we put nss_db_initf_t in nss_db_root_t, 312*0Sstevel@tonic-gate * or abolished nss_db_initf_t and put nss_db_params_t in nss_db_root_t. 313*0Sstevel@tonic-gate * It's done the way it is for shared-library efficiency, namely: 314*0Sstevel@tonic-gate * - keep the unshared data (nss_db_root_t) to a minimum, 315*0Sstevel@tonic-gate * - keep the symbol lookups and relocations to a minimum. 316*0Sstevel@tonic-gate * In particular this means that non-null pointers, e.g. strings and 317*0Sstevel@tonic-gate * function pointers, in global data are a bad thing). 318*0Sstevel@tonic-gate */ 319*0Sstevel@tonic-gate 320*0Sstevel@tonic-gate enum nss_dbp_flags { 321*0Sstevel@tonic-gate NSS_USE_DEFAULT_CONFIG = 0x1 322*0Sstevel@tonic-gate }; 323*0Sstevel@tonic-gate 324*0Sstevel@tonic-gate struct nss_db_params { 325*0Sstevel@tonic-gate const char *name; /* Mandatory: database name */ 326*0Sstevel@tonic-gate const char *config_name; /* config-file database name */ 327*0Sstevel@tonic-gate const char *default_config; /* Mandatory: default config */ 328*0Sstevel@tonic-gate unsigned max_active_per_src; 329*0Sstevel@tonic-gate unsigned max_dormant_per_src; 330*0Sstevel@tonic-gate enum nss_dbp_flags flags; 331*0Sstevel@tonic-gate nss_backend_finder_t *finders; 332*0Sstevel@tonic-gate void *private; /* Not used by switch */ 333*0Sstevel@tonic-gate void (*cleanup)(struct nss_db_params *); 334*0Sstevel@tonic-gate }; 335*0Sstevel@tonic-gate 336*0Sstevel@tonic-gate typedef struct nss_db_params nss_db_params_t; 337*0Sstevel@tonic-gate 338*0Sstevel@tonic-gate #if defined(__STDC__) 339*0Sstevel@tonic-gate typedef void (*nss_db_initf_t)(nss_db_params_t *); 340*0Sstevel@tonic-gate #else 341*0Sstevel@tonic-gate typedef void (*nss_db_initf_t)(); 342*0Sstevel@tonic-gate #endif 343*0Sstevel@tonic-gate 344*0Sstevel@tonic-gate /* 345*0Sstevel@tonic-gate * These structures are defined inside the implementation of the switch 346*0Sstevel@tonic-gate * engine; the interface just holds pointers to them. 347*0Sstevel@tonic-gate */ 348*0Sstevel@tonic-gate struct nss_db_state; 349*0Sstevel@tonic-gate struct nss_getent_context; 350*0Sstevel@tonic-gate 351*0Sstevel@tonic-gate /* 352*0Sstevel@tonic-gate * Finally, the two handles that frontends hold: 353*0Sstevel@tonic-gate */ 354*0Sstevel@tonic-gate 355*0Sstevel@tonic-gate struct nss_db_root { 356*0Sstevel@tonic-gate struct nss_db_state *s; 357*0Sstevel@tonic-gate mutex_t lock; 358*0Sstevel@tonic-gate }; 359*0Sstevel@tonic-gate typedef struct nss_db_root nss_db_root_t; 360*0Sstevel@tonic-gate #define NSS_DB_ROOT_INIT { 0, DEFAULTMUTEX } 361*0Sstevel@tonic-gate #define DEFINE_NSS_DB_ROOT(name) nss_db_root_t name = NSS_DB_ROOT_INIT 362*0Sstevel@tonic-gate 363*0Sstevel@tonic-gate 364*0Sstevel@tonic-gate typedef struct { 365*0Sstevel@tonic-gate struct nss_getent_context *ctx; 366*0Sstevel@tonic-gate mutex_t lock; 367*0Sstevel@tonic-gate } nss_getent_t; 368*0Sstevel@tonic-gate 369*0Sstevel@tonic-gate #define NSS_GETENT_INIT { 0, DEFAULTMUTEX } 370*0Sstevel@tonic-gate #define DEFINE_NSS_GETENT(name) nss_getent_t name = NSS_GETENT_INIT 371*0Sstevel@tonic-gate 372*0Sstevel@tonic-gate #if defined(__STDC__) 373*0Sstevel@tonic-gate extern nss_status_t nss_search(nss_db_root_t *, nss_db_initf_t, 374*0Sstevel@tonic-gate int search_fnum, void *search_args); 375*0Sstevel@tonic-gate extern nss_status_t nss_getent(nss_db_root_t *, nss_db_initf_t, nss_getent_t *, 376*0Sstevel@tonic-gate void *getent_args); 377*0Sstevel@tonic-gate extern void nss_setent(nss_db_root_t *, nss_db_initf_t, nss_getent_t *); 378*0Sstevel@tonic-gate 379*0Sstevel@tonic-gate extern void nss_endent(nss_db_root_t *, nss_db_initf_t, nss_getent_t *); 380*0Sstevel@tonic-gate /* ^^ superfluous but consistent */ 381*0Sstevel@tonic-gate extern void nss_delete(nss_db_root_t *); 382*0Sstevel@tonic-gate #else 383*0Sstevel@tonic-gate extern nss_status_t nss_search(); 384*0Sstevel@tonic-gate extern nss_status_t nss_getent(); 385*0Sstevel@tonic-gate extern void nss_setent(); 386*0Sstevel@tonic-gate extern void nss_endent(); 387*0Sstevel@tonic-gate extern void nss_delete(); 388*0Sstevel@tonic-gate #endif 389*0Sstevel@tonic-gate 390*0Sstevel@tonic-gate #ifdef __cplusplus 391*0Sstevel@tonic-gate } 392*0Sstevel@tonic-gate #endif 393*0Sstevel@tonic-gate 394*0Sstevel@tonic-gate #endif /* _NSS_COMMON_H */ 395