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 52830Sdjl * Common Development and Distribution License (the "License"). 62830Sdjl * 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*8040SBaban.Kenkre@Sun.COM * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 232830Sdjl * Use is subject to license terms. 242830Sdjl */ 252830Sdjl /* 260Sstevel@tonic-gate * Common code and structures used by name-service-switch "compat" backends. 270Sstevel@tonic-gate */ 280Sstevel@tonic-gate 290Sstevel@tonic-gate #ifndef _COMPAT_COMMON_H 300Sstevel@tonic-gate #define _COMPAT_COMMON_H 310Sstevel@tonic-gate 320Sstevel@tonic-gate #include <nss_common.h> 330Sstevel@tonic-gate #include <nss_dbdefs.h> 340Sstevel@tonic-gate #include <stdio.h> 350Sstevel@tonic-gate 360Sstevel@tonic-gate #ifdef __cplusplus 370Sstevel@tonic-gate extern "C" { 380Sstevel@tonic-gate #endif 390Sstevel@tonic-gate 400Sstevel@tonic-gate typedef struct compat_backend *compat_backend_ptr_t; 410Sstevel@tonic-gate typedef nss_status_t (*compat_backend_op_t)(compat_backend_ptr_t, void *); 420Sstevel@tonic-gate 430Sstevel@tonic-gate /* 440Sstevel@tonic-gate * ===> Fix da comments (and in files_common.h too...) 450Sstevel@tonic-gate * Iterator function for _nss_files_do_all(), which probably calls yp_all(). 460Sstevel@tonic-gate * NSS_NOTFOUND means "keep enumerating", NSS_SUCCESS means"return now", 470Sstevel@tonic-gate * other values don't make much sense. In other words we're abusing 480Sstevel@tonic-gate * (overloading) the meaning of nss_status_t, but hey... 490Sstevel@tonic-gate * _nss_compat_XY_all() is a wrapper around _nss_files_do_all() that does the 500Sstevel@tonic-gate * generic work for nss_XbyY_args_t backends (calls cstr2ent etc). 510Sstevel@tonic-gate */ 520Sstevel@tonic-gate typedef nss_status_t (*files_do_all_func_t)(const char *, int, void *args); 530Sstevel@tonic-gate /* ===> ^^ nuke this line */ 540Sstevel@tonic-gate typedef int (*compat_XY_check_func)(nss_XbyY_args_t *); 550Sstevel@tonic-gate typedef const char *(*compat_get_name)(nss_XbyY_args_t *); 560Sstevel@tonic-gate typedef int (*compat_merge_func)(compat_backend_ptr_t, 570Sstevel@tonic-gate nss_XbyY_args_t *, 580Sstevel@tonic-gate const char **fields); 590Sstevel@tonic-gate 602830Sdjl typedef struct setofstrings *strset_t; 612830Sdjl 622830Sdjl struct compat_backend { 632830Sdjl compat_backend_op_t *ops; 642830Sdjl int n_ops; 652830Sdjl const char *filename; 662830Sdjl FILE *f; 672830Sdjl int minbuf; 682830Sdjl char *buf; 692830Sdjl int linelen; /* <== Explain use, lifetime */ 702830Sdjl 712830Sdjl nss_db_initf_t db_initf; 722830Sdjl nss_db_root_t *db_rootp; /* Shared between instances */ 732830Sdjl nss_getent_t db_context; /* Per-instance enumeration */ 742830Sdjl 752830Sdjl compat_get_name getnamef; 762830Sdjl compat_merge_func mergef; 772830Sdjl 782830Sdjl /* We wouldn't need all this hokey state stuff if we */ 792830Sdjl /* used another thread to implement a coroutine... */ 802830Sdjl enum { 812830Sdjl GETENT_FILE, 822830Sdjl GETENT_NETGROUP, 832830Sdjl GETENT_ATTRDB, 842830Sdjl GETENT_ALL, 852830Sdjl GETENT_DONE 862830Sdjl } state; 872830Sdjl strset_t minuses; 882830Sdjl 892830Sdjl int permit_netgroups; 902830Sdjl const char *yp_domain; 912830Sdjl nss_backend_t *getnetgrent_backend; 922830Sdjl char *netgr_buffer; 932830Sdjl int return_string_data; 943012Smichen int (*str2ent_save)(); 953012Smichen int (*str2ent_alt)(); 963012Smichen void *workarea; 972830Sdjl }; 982830Sdjl 990Sstevel@tonic-gate #if defined(__STDC__) 1000Sstevel@tonic-gate extern nss_backend_t *_nss_compat_constr(compat_backend_op_t *ops, 1010Sstevel@tonic-gate int n_ops, 1020Sstevel@tonic-gate const char *filename, 1030Sstevel@tonic-gate int min_bufsize, 1040Sstevel@tonic-gate nss_db_root_t *rootp, 1050Sstevel@tonic-gate nss_db_initf_t initf, 1060Sstevel@tonic-gate int netgroups, 1070Sstevel@tonic-gate compat_get_name getname_func, 1080Sstevel@tonic-gate compat_merge_func merge_func); 1090Sstevel@tonic-gate extern nss_status_t _nss_compat_destr(compat_backend_ptr_t, void *dummy); 1100Sstevel@tonic-gate extern nss_status_t _nss_compat_setent(compat_backend_ptr_t, void *dummy); 1110Sstevel@tonic-gate extern nss_status_t _nss_compat_endent(compat_backend_ptr_t, void *dummy); 1120Sstevel@tonic-gate extern nss_status_t _nss_compat_getent(compat_backend_ptr_t, void *); 1130Sstevel@tonic-gate extern nss_status_t _nss_compat_XY_all(compat_backend_ptr_t, 1140Sstevel@tonic-gate nss_XbyY_args_t *args, 1150Sstevel@tonic-gate compat_XY_check_func check, 1160Sstevel@tonic-gate nss_dbop_t op_num); 1170Sstevel@tonic-gate extern nss_status_t _attrdb_compat_XY_all(compat_backend_ptr_t, 1180Sstevel@tonic-gate nss_XbyY_args_t *args, 1190Sstevel@tonic-gate int netdb, 1200Sstevel@tonic-gate compat_XY_check_func check, 1210Sstevel@tonic-gate nss_dbop_t op_num); 1220Sstevel@tonic-gate #else 1230Sstevel@tonic-gate extern nss_backend_t *_nss_compat_constr(); 1240Sstevel@tonic-gate extern nss_status_t _nss_compat_destr(); 1250Sstevel@tonic-gate extern nss_status_t _nss_compat_setent(); 1260Sstevel@tonic-gate extern nss_status_t _nss_compat_endent(); 1270Sstevel@tonic-gate extern nss_status_t _nss_compat_getent(); 1280Sstevel@tonic-gate extern nss_status_t _nss_compat_XY_all(); 1290Sstevel@tonic-gate extern nss_status_t _attrdb_compat_XY_all(); 1300Sstevel@tonic-gate #endif 1310Sstevel@tonic-gate 132*8040SBaban.Kenkre@Sun.COM /* functions to validate passwd and group ids */ 133*8040SBaban.Kenkre@Sun.COM extern int validate_passwd_ids(char *line, int *linelenp, int buflen, 134*8040SBaban.Kenkre@Sun.COM int extra_chars); 135*8040SBaban.Kenkre@Sun.COM extern int validate_group_ids(char *line, int *linelenp, int buflen, 136*8040SBaban.Kenkre@Sun.COM int extra_chars); 137*8040SBaban.Kenkre@Sun.COM 1380Sstevel@tonic-gate #ifdef __cplusplus 1390Sstevel@tonic-gate } 1400Sstevel@tonic-gate #endif 1410Sstevel@tonic-gate 1420Sstevel@tonic-gate #endif /* _COMPAT_COMMON_H */ 143