17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5cb5caa98Sdjl * Common Development and Distribution License (the "License"). 6cb5caa98Sdjl * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 217c478bd9Sstevel@tonic-gate /* 22ba3594baSGarrett D'Amore * Copyright 2014 Garrett D'Amore <garrett@damore.org> 23ba3594baSGarrett D'Amore * 24cb5caa98Sdjl * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 25cb5caa98Sdjl * Use is subject to license terms. 267c478bd9Sstevel@tonic-gate */ 277c478bd9Sstevel@tonic-gate 287c478bd9Sstevel@tonic-gate /* 297c478bd9Sstevel@tonic-gate * nsswitch.h 307c478bd9Sstevel@tonic-gate * 317c478bd9Sstevel@tonic-gate * Low-level interface to the name-service switch. The interface defined 327c478bd9Sstevel@tonic-gate * in <nss_common.h> should be used in preference to this. 337c478bd9Sstevel@tonic-gate * 347c478bd9Sstevel@tonic-gate * This is a Project Private interface. It may change in future releases. 357c478bd9Sstevel@tonic-gate */ 367c478bd9Sstevel@tonic-gate 377c478bd9Sstevel@tonic-gate #ifndef _NSSWITCH_H 387c478bd9Sstevel@tonic-gate #define _NSSWITCH_H 397c478bd9Sstevel@tonic-gate 407c478bd9Sstevel@tonic-gate #ifdef __cplusplus 417c478bd9Sstevel@tonic-gate extern "C" { 427c478bd9Sstevel@tonic-gate #endif 437c478bd9Sstevel@tonic-gate 44cb5caa98Sdjl #ifndef __NSW_CONFIG_FILE 457c478bd9Sstevel@tonic-gate #define __NSW_CONFIG_FILE "/etc/nsswitch.conf" 46cb5caa98Sdjl #endif 477c478bd9Sstevel@tonic-gate #define __NSW_DEFAULT_FILE "/etc/default/nss" 487c478bd9Sstevel@tonic-gate 497c478bd9Sstevel@tonic-gate #define __NSW_HOSTS_DB "hosts" 507c478bd9Sstevel@tonic-gate #define __NSW_PASSWD_DB "passwd" 517c478bd9Sstevel@tonic-gate #define __NSW_GROUP_DB "group" 527c478bd9Sstevel@tonic-gate #define __NSW_NETGROUP_DB "netgroup" 537c478bd9Sstevel@tonic-gate #define __NSW_NETWORKS_DB "networks" 547c478bd9Sstevel@tonic-gate #define __NSW_PROTOCOLS_DB "protocols" 557c478bd9Sstevel@tonic-gate #define __NSW_RPC_DB "rpc" 567c478bd9Sstevel@tonic-gate #define __NSW_SERVICES_DB "services" 577c478bd9Sstevel@tonic-gate #define __NSW_ETHERS_DB "ethers" 587c478bd9Sstevel@tonic-gate #define __NSW_BOOTPARAMS_DB "bootparams" 597c478bd9Sstevel@tonic-gate #define __NSW_NETMASKS_DB "netmasks" 607c478bd9Sstevel@tonic-gate #define __NSW_BROADCASTADDRS_DB "broadcastaddrs" 617c478bd9Sstevel@tonic-gate #define __NSW_MAIL_ALIASES_DB "aliases" 627c478bd9Sstevel@tonic-gate #define __NSW_AUDITUSER_DB "audit_user" 637c478bd9Sstevel@tonic-gate #define __NSW_AUTHATTR_DB "auth_attr" 647c478bd9Sstevel@tonic-gate #define __NSW_EXECATTR_DB "exec_attr" 657c478bd9Sstevel@tonic-gate #define __NSW_PROFATTR_DB "prof_attr" 667c478bd9Sstevel@tonic-gate #define __NSW_USERATTR_DB "user_attr" 677c478bd9Sstevel@tonic-gate #define __NSW_PROJECT_DB "project" 687c478bd9Sstevel@tonic-gate 697c478bd9Sstevel@tonic-gate #define __NSW_STD_ERRS 4 /* number of reserved errors that follow */ 707c478bd9Sstevel@tonic-gate 717c478bd9Sstevel@tonic-gate #define __NSW_SUCCESS 0 /* found the required data */ 727c478bd9Sstevel@tonic-gate #define __NSW_NOTFOUND 1 /* the naming service returned lookup failure */ 737c478bd9Sstevel@tonic-gate #define __NSW_UNAVAIL 2 /* could not call the naming service */ 747c478bd9Sstevel@tonic-gate #define __NSW_TRYAGAIN 3 /* bind error to suggest a retry */ 757c478bd9Sstevel@tonic-gate 767c478bd9Sstevel@tonic-gate typedef unsigned char action_t; 777c478bd9Sstevel@tonic-gate #define __NSW_CONTINUE 0 /* the action is to continue to next service */ 787c478bd9Sstevel@tonic-gate #define __NSW_RETURN 1 /* the action is to return to the user */ 797c478bd9Sstevel@tonic-gate 807c478bd9Sstevel@tonic-gate #define __NSW_STR_RETURN "return" 817c478bd9Sstevel@tonic-gate #define __NSW_STR_CONTINUE "continue" 827c478bd9Sstevel@tonic-gate #define __NSW_STR_SUCCESS "success" 837c478bd9Sstevel@tonic-gate #define __NSW_STR_NOTFOUND "notfound" 847c478bd9Sstevel@tonic-gate #define __NSW_STR_UNAVAIL "unavail" 857c478bd9Sstevel@tonic-gate #define __NSW_STR_TRYAGAIN "tryagain" 867c478bd9Sstevel@tonic-gate 877c478bd9Sstevel@tonic-gate /* prefix for all switch shared objects */ 887c478bd9Sstevel@tonic-gate #define __NSW_LIB "nsw" 897c478bd9Sstevel@tonic-gate 907c478bd9Sstevel@tonic-gate enum __nsw_parse_err { 917c478bd9Sstevel@tonic-gate __NSW_CONF_PARSE_SUCCESS = 0, /* parser found the required policy */ 927c478bd9Sstevel@tonic-gate __NSW_CONF_PARSE_NOFILE = 1, /* the policy files does not exist */ 937c478bd9Sstevel@tonic-gate __NSW_CONF_PARSE_NOPOLICY = 2, /* the required policy is not set */ 947c478bd9Sstevel@tonic-gate /* in the file */ 957c478bd9Sstevel@tonic-gate __NSW_CONF_PARSE_SYSERR = 3 /* system error in the parser */ 967c478bd9Sstevel@tonic-gate }; 977c478bd9Sstevel@tonic-gate 987c478bd9Sstevel@tonic-gate 997c478bd9Sstevel@tonic-gate struct __nsw_long_err { 1007c478bd9Sstevel@tonic-gate int nsw_errno; 1017c478bd9Sstevel@tonic-gate action_t action; 1027c478bd9Sstevel@tonic-gate struct __nsw_long_err *next; 1037c478bd9Sstevel@tonic-gate }; 1047c478bd9Sstevel@tonic-gate 1057c478bd9Sstevel@tonic-gate struct __nsw_lookup { 1067c478bd9Sstevel@tonic-gate char *service_name; 1077c478bd9Sstevel@tonic-gate action_t actions[__NSW_STD_ERRS]; 1087c478bd9Sstevel@tonic-gate struct __nsw_long_err *long_errs; 1097c478bd9Sstevel@tonic-gate struct __nsw_lookup *next; 1107c478bd9Sstevel@tonic-gate }; 1117c478bd9Sstevel@tonic-gate 1127c478bd9Sstevel@tonic-gate struct __nsw_switchconfig { 1137c478bd9Sstevel@tonic-gate int vers; 1147c478bd9Sstevel@tonic-gate char *dbase; 1157c478bd9Sstevel@tonic-gate int num_lookups; 1167c478bd9Sstevel@tonic-gate struct __nsw_lookup *lookups; 1177c478bd9Sstevel@tonic-gate }; 1187c478bd9Sstevel@tonic-gate 119*6e270ca8SMarcel Telka #define __NSW_ACTION(lkp, err) \ 1207c478bd9Sstevel@tonic-gate ((lkp)->next == NULL ? \ 1217c478bd9Sstevel@tonic-gate __NSW_RETURN \ 1227c478bd9Sstevel@tonic-gate : \ 1237c478bd9Sstevel@tonic-gate ((err) >= 0 && (err) < __NSW_STD_ERRS ? \ 1247c478bd9Sstevel@tonic-gate (lkp)->actions[err] \ 1257c478bd9Sstevel@tonic-gate : \ 1267c478bd9Sstevel@tonic-gate __nsw_extended_action(lkp, err))) 1277c478bd9Sstevel@tonic-gate 1287c478bd9Sstevel@tonic-gate struct __nsw_switchconfig *__nsw_getconfig 1297c478bd9Sstevel@tonic-gate (const char *, enum __nsw_parse_err *); 1307c478bd9Sstevel@tonic-gate int __nsw_freeconfig(struct __nsw_switchconfig *); 1317c478bd9Sstevel@tonic-gate action_t __nsw_extended_action(struct __nsw_lookup *, int); 1327c478bd9Sstevel@tonic-gate 1337c478bd9Sstevel@tonic-gate #ifdef __cplusplus 1347c478bd9Sstevel@tonic-gate } 1357c478bd9Sstevel@tonic-gate #endif 1367c478bd9Sstevel@tonic-gate 1377c478bd9Sstevel@tonic-gate #endif /* _NSSWITCH_H */ 138