10Sstevel@tonic-gate /* 20Sstevel@tonic-gate * CDDL HEADER START 30Sstevel@tonic-gate * 40Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*2830Sdjl * Common Development and Distribution License (the "License"). 6*2830Sdjl * You may not use this file except in compliance with the License. 70Sstevel@tonic-gate * 80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 100Sstevel@tonic-gate * See the License for the specific language governing permissions 110Sstevel@tonic-gate * and limitations under the License. 120Sstevel@tonic-gate * 130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 180Sstevel@tonic-gate * 190Sstevel@tonic-gate * CDDL HEADER END 200Sstevel@tonic-gate */ 210Sstevel@tonic-gate /* 22*2830Sdjl * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 23*2830Sdjl * Use is subject to license terms. 240Sstevel@tonic-gate */ 250Sstevel@tonic-gate 260Sstevel@tonic-gate /* 270Sstevel@tonic-gate * nsswitch.h 280Sstevel@tonic-gate * 290Sstevel@tonic-gate * Low-level interface to the name-service switch. The interface defined 300Sstevel@tonic-gate * in <nss_common.h> should be used in preference to this. 310Sstevel@tonic-gate * 320Sstevel@tonic-gate * This is a Project Private interface. It may change in future releases. 330Sstevel@tonic-gate */ 340Sstevel@tonic-gate 350Sstevel@tonic-gate #ifndef _NSSWITCH_H 360Sstevel@tonic-gate #define _NSSWITCH_H 370Sstevel@tonic-gate 380Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 390Sstevel@tonic-gate 400Sstevel@tonic-gate #ifdef __cplusplus 410Sstevel@tonic-gate extern "C" { 420Sstevel@tonic-gate #endif 430Sstevel@tonic-gate 44*2830Sdjl #ifndef __NSW_CONFIG_FILE 450Sstevel@tonic-gate #define __NSW_CONFIG_FILE "/etc/nsswitch.conf" 46*2830Sdjl #endif 470Sstevel@tonic-gate #define __NSW_DEFAULT_FILE "/etc/default/nss" 480Sstevel@tonic-gate 490Sstevel@tonic-gate #define __NSW_HOSTS_DB "hosts" 500Sstevel@tonic-gate #define __NSW_PASSWD_DB "passwd" 510Sstevel@tonic-gate #define __NSW_GROUP_DB "group" 520Sstevel@tonic-gate #define __NSW_NETGROUP_DB "netgroup" 530Sstevel@tonic-gate #define __NSW_NETWORKS_DB "networks" 540Sstevel@tonic-gate #define __NSW_PROTOCOLS_DB "protocols" 550Sstevel@tonic-gate #define __NSW_RPC_DB "rpc" 560Sstevel@tonic-gate #define __NSW_SERVICES_DB "services" 570Sstevel@tonic-gate #define __NSW_ETHERS_DB "ethers" 580Sstevel@tonic-gate #define __NSW_BOOTPARAMS_DB "bootparams" 590Sstevel@tonic-gate #define __NSW_NETMASKS_DB "netmasks" 600Sstevel@tonic-gate #define __NSW_BROADCASTADDRS_DB "broadcastaddrs" 610Sstevel@tonic-gate #define __NSW_MAIL_ALIASES_DB "aliases" 620Sstevel@tonic-gate #define __NSW_AUDITUSER_DB "audit_user" 630Sstevel@tonic-gate #define __NSW_AUTHATTR_DB "auth_attr" 640Sstevel@tonic-gate #define __NSW_EXECATTR_DB "exec_attr" 650Sstevel@tonic-gate #define __NSW_PROFATTR_DB "prof_attr" 660Sstevel@tonic-gate #define __NSW_USERATTR_DB "user_attr" 670Sstevel@tonic-gate #define __NSW_PROJECT_DB "project" 680Sstevel@tonic-gate 690Sstevel@tonic-gate #define __NSW_STD_ERRS 4 /* number of reserved errors that follow */ 700Sstevel@tonic-gate 710Sstevel@tonic-gate #define __NSW_SUCCESS 0 /* found the required data */ 720Sstevel@tonic-gate #define __NSW_NOTFOUND 1 /* the naming service returned lookup failure */ 730Sstevel@tonic-gate #define __NSW_UNAVAIL 2 /* could not call the naming service */ 740Sstevel@tonic-gate #define __NSW_TRYAGAIN 3 /* bind error to suggest a retry */ 750Sstevel@tonic-gate 760Sstevel@tonic-gate typedef unsigned char action_t; 770Sstevel@tonic-gate #define __NSW_CONTINUE 0 /* the action is to continue to next service */ 780Sstevel@tonic-gate #define __NSW_RETURN 1 /* the action is to return to the user */ 790Sstevel@tonic-gate 800Sstevel@tonic-gate #define __NSW_STR_RETURN "return" 810Sstevel@tonic-gate #define __NSW_STR_CONTINUE "continue" 820Sstevel@tonic-gate #define __NSW_STR_SUCCESS "success" 830Sstevel@tonic-gate #define __NSW_STR_NOTFOUND "notfound" 840Sstevel@tonic-gate #define __NSW_STR_UNAVAIL "unavail" 850Sstevel@tonic-gate #define __NSW_STR_TRYAGAIN "tryagain" 860Sstevel@tonic-gate 870Sstevel@tonic-gate /* prefix for all switch shared objects */ 880Sstevel@tonic-gate #define __NSW_LIB "nsw" 890Sstevel@tonic-gate 900Sstevel@tonic-gate enum __nsw_parse_err { 910Sstevel@tonic-gate __NSW_CONF_PARSE_SUCCESS = 0, /* parser found the required policy */ 920Sstevel@tonic-gate __NSW_CONF_PARSE_NOFILE = 1, /* the policy files does not exist */ 930Sstevel@tonic-gate __NSW_CONF_PARSE_NOPOLICY = 2, /* the required policy is not set */ 940Sstevel@tonic-gate /* in the file */ 950Sstevel@tonic-gate __NSW_CONF_PARSE_SYSERR = 3 /* system error in the parser */ 960Sstevel@tonic-gate }; 970Sstevel@tonic-gate 980Sstevel@tonic-gate 990Sstevel@tonic-gate struct __nsw_long_err { 1000Sstevel@tonic-gate int nsw_errno; 1010Sstevel@tonic-gate action_t action; 1020Sstevel@tonic-gate struct __nsw_long_err *next; 1030Sstevel@tonic-gate }; 1040Sstevel@tonic-gate 1050Sstevel@tonic-gate struct __nsw_lookup { 1060Sstevel@tonic-gate char *service_name; 1070Sstevel@tonic-gate action_t actions[__NSW_STD_ERRS]; 1080Sstevel@tonic-gate struct __nsw_long_err *long_errs; 1090Sstevel@tonic-gate struct __nsw_lookup *next; 1100Sstevel@tonic-gate }; 1110Sstevel@tonic-gate 1120Sstevel@tonic-gate struct __nsw_switchconfig { 1130Sstevel@tonic-gate int vers; 1140Sstevel@tonic-gate char *dbase; 1150Sstevel@tonic-gate int num_lookups; 1160Sstevel@tonic-gate struct __nsw_lookup *lookups; 1170Sstevel@tonic-gate }; 1180Sstevel@tonic-gate 1190Sstevel@tonic-gate #define __NSW_ACTION(lkp, err) \ 1200Sstevel@tonic-gate ((lkp)->next == NULL ? \ 1210Sstevel@tonic-gate __NSW_RETURN \ 1220Sstevel@tonic-gate : \ 1230Sstevel@tonic-gate ((err) >= 0 && (err) < __NSW_STD_ERRS ? \ 1240Sstevel@tonic-gate (lkp)->actions[err] \ 1250Sstevel@tonic-gate : \ 1260Sstevel@tonic-gate __nsw_extended_action(lkp, err))) 1270Sstevel@tonic-gate 1280Sstevel@tonic-gate #ifdef __STDC__ 1290Sstevel@tonic-gate 1300Sstevel@tonic-gate struct __nsw_switchconfig *__nsw_getconfig 1310Sstevel@tonic-gate (const char *, enum __nsw_parse_err *); 1320Sstevel@tonic-gate int __nsw_freeconfig(struct __nsw_switchconfig *); 1330Sstevel@tonic-gate action_t __nsw_extended_action(struct __nsw_lookup *, int); 1340Sstevel@tonic-gate 1350Sstevel@tonic-gate #else 1360Sstevel@tonic-gate 1370Sstevel@tonic-gate struct __nsw_switchconfig *__nsw_getconfig(); 1380Sstevel@tonic-gate int __nsw_freeconfig(); 1390Sstevel@tonic-gate action_t __nsw_extended_action(); 1400Sstevel@tonic-gate 1410Sstevel@tonic-gate #endif /* __STDC__ */ 1420Sstevel@tonic-gate 1430Sstevel@tonic-gate #ifdef __cplusplus 1440Sstevel@tonic-gate } 1450Sstevel@tonic-gate #endif 1460Sstevel@tonic-gate 1470Sstevel@tonic-gate #endif /* _NSSWITCH_H */ 148