12b4a7802SBaban Kenkre /* 22b4a7802SBaban Kenkre * CDDL HEADER START 32b4a7802SBaban Kenkre * 42b4a7802SBaban Kenkre * The contents of this file are subject to the terms of the 52b4a7802SBaban Kenkre * Common Development and Distribution License (the "License"). 62b4a7802SBaban Kenkre * You may not use this file except in compliance with the License. 72b4a7802SBaban Kenkre * 82b4a7802SBaban Kenkre * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 92b4a7802SBaban Kenkre * or http://www.opensolaris.org/os/licensing. 102b4a7802SBaban Kenkre * See the License for the specific language governing permissions 112b4a7802SBaban Kenkre * and limitations under the License. 122b4a7802SBaban Kenkre * 132b4a7802SBaban Kenkre * When distributing Covered Code, include this CDDL HEADER in each 142b4a7802SBaban Kenkre * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 152b4a7802SBaban Kenkre * If applicable, add the following below this CDDL HEADER, with the 162b4a7802SBaban Kenkre * fields enclosed by brackets "[]" replaced with your own identifying 172b4a7802SBaban Kenkre * information: Portions Copyright [yyyy] [name of copyright owner] 182b4a7802SBaban Kenkre * 192b4a7802SBaban Kenkre * CDDL HEADER END 202b4a7802SBaban Kenkre */ 212b4a7802SBaban Kenkre /* 221fdeec65Sjoyce mcintosh * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. 23*b3700b07SGordon Ross * Copyright 2014 Nexenta Systems, Inc. All rights reserved. 242b4a7802SBaban Kenkre */ 252b4a7802SBaban Kenkre 262b4a7802SBaban Kenkre #ifndef _AD_COMMON_H 272b4a7802SBaban Kenkre #define _AD_COMMON_H 282b4a7802SBaban Kenkre 292b4a7802SBaban Kenkre #ifdef __cplusplus 302b4a7802SBaban Kenkre extern "C" { 312b4a7802SBaban Kenkre #endif 322b4a7802SBaban Kenkre 332b4a7802SBaban Kenkre #include <ctype.h> 342b4a7802SBaban Kenkre #include <nss_dbdefs.h> 352b4a7802SBaban Kenkre #include <stdlib.h> 362b4a7802SBaban Kenkre #include <stdio.h> 372b4a7802SBaban Kenkre #include <string.h> 382b4a7802SBaban Kenkre #include <strings.h> 392b4a7802SBaban Kenkre #include <signal.h> 402b4a7802SBaban Kenkre #include <idmap.h> 412b4a7802SBaban Kenkre #include <sys/idmap.h> 429b214d32SJordan Brown #include <rpcsvc/idmap_prot.h> 432b4a7802SBaban Kenkre #include <idmap_priv.h> 442b4a7802SBaban Kenkre #include "addisc.h" 452b4a7802SBaban Kenkre #include "libadutils.h" 462b4a7802SBaban Kenkre 472b4a7802SBaban Kenkre #define _GROUP "group" 482b4a7802SBaban Kenkre #define _PASSWD "passwd" 492b4a7802SBaban Kenkre #define _SHADOW "shadow" 502b4a7802SBaban Kenkre 512b4a7802SBaban Kenkre #define WK_DOMAIN "BUILTIN" 522b4a7802SBaban Kenkre #define CFG_QUEUE_MAX_SIZE 15 532b4a7802SBaban Kenkre 542b4a7802SBaban Kenkre #define SEARCHFILTERLEN 256 552b4a7802SBaban Kenkre #define RESET_ERRNO()\ 562b4a7802SBaban Kenkre if (errno == EINVAL)\ 572b4a7802SBaban Kenkre errno = 0; 582b4a7802SBaban Kenkre 592b4a7802SBaban Kenkre /* 602b4a7802SBaban Kenkre * Superset the nss_backend_t abstract data type. This ADT has 612b4a7802SBaban Kenkre * been extended to include AD associated data structures. 622b4a7802SBaban Kenkre */ 632b4a7802SBaban Kenkre 642b4a7802SBaban Kenkre typedef struct ad_backend *ad_backend_ptr; 652b4a7802SBaban Kenkre typedef nss_status_t (*ad_backend_op_t)(ad_backend_ptr, void *); 662b4a7802SBaban Kenkre typedef int (*fnf)(ad_backend_ptr be, nss_XbyY_args_t *argp); 672b4a7802SBaban Kenkre 682b4a7802SBaban Kenkre typedef enum { 692b4a7802SBaban Kenkre NSS_AD_DB_NONE = 0, 702b4a7802SBaban Kenkre NSS_AD_DB_PASSWD_BYNAME = 1, 712b4a7802SBaban Kenkre NSS_AD_DB_PASSWD_BYUID = 2, 722b4a7802SBaban Kenkre NSS_AD_DB_GROUP_BYNAME = 3, 732b4a7802SBaban Kenkre NSS_AD_DB_GROUP_BYGID = 4, 742b4a7802SBaban Kenkre NSS_AD_DB_SHADOW_BYNAME = 5 752b4a7802SBaban Kenkre } nss_ad_db_type_t; 762b4a7802SBaban Kenkre 772b4a7802SBaban Kenkre struct ad_backend { 782b4a7802SBaban Kenkre ad_backend_op_t *ops; 792b4a7802SBaban Kenkre nss_dbop_t nops; 802b4a7802SBaban Kenkre char *tablename; 812b4a7802SBaban Kenkre const char **attrs; 822b4a7802SBaban Kenkre fnf adobj2str; 832b4a7802SBaban Kenkre char *buffer; 842b4a7802SBaban Kenkre int buflen; 852b4a7802SBaban Kenkre uid_t uid; 862b4a7802SBaban Kenkre adutils_result_t *result; 872b4a7802SBaban Kenkre nss_ad_db_type_t db_type; 882b4a7802SBaban Kenkre }; 892b4a7802SBaban Kenkre 902b4a7802SBaban Kenkre typedef struct nssad_prop { 912b4a7802SBaban Kenkre char *domain_name; 92*b3700b07SGordon Ross ad_disc_ds_t *domain_controller; 932b4a7802SBaban Kenkre } nssad_prop_t; 942b4a7802SBaban Kenkre 952b4a7802SBaban Kenkre typedef struct nssad_cfg { 962b4a7802SBaban Kenkre pthread_rwlock_t lock; 972b4a7802SBaban Kenkre nssad_prop_t props; 982b4a7802SBaban Kenkre ad_disc_t ad_ctx; 992b4a7802SBaban Kenkre adutils_ad_t *ad; 1002b4a7802SBaban Kenkre struct nssad_cfg *qnext; 1012b4a7802SBaban Kenkre } nssad_cfg_t; 1022b4a7802SBaban Kenkre 1032b4a7802SBaban Kenkre typedef struct nssad_state { 1042b4a7802SBaban Kenkre nssad_cfg_t *qhead; 1052b4a7802SBaban Kenkre nssad_cfg_t *qtail; 1062b4a7802SBaban Kenkre uint32_t qcount; 1072b4a7802SBaban Kenkre } nssad_state_t; 1082b4a7802SBaban Kenkre 1092b4a7802SBaban Kenkre extern nss_status_t _nss_ad_destr(ad_backend_ptr be, void *a); 1102b4a7802SBaban Kenkre extern nss_status_t _nss_ad_endent(ad_backend_ptr be, void *a); 1112b4a7802SBaban Kenkre extern nss_status_t _nss_ad_setent(ad_backend_ptr be, void *a); 1122b4a7802SBaban Kenkre extern nss_status_t _nss_ad_getent(ad_backend_ptr be, void *a); 1132b4a7802SBaban Kenkre nss_backend_t *_nss_ad_constr(ad_backend_op_t ops[], int nops, 1142b4a7802SBaban Kenkre char *tablename, const char **attrs, fnf ldapobj2str); 1152b4a7802SBaban Kenkre extern nss_status_t _nss_ad_lookup(ad_backend_ptr be, 1162b4a7802SBaban Kenkre nss_XbyY_args_t *argp, const char *database, 1172b4a7802SBaban Kenkre const char *searchfilter, const char *dname, 1182b4a7802SBaban Kenkre int *try_idmap); 1192b4a7802SBaban Kenkre extern nss_status_t _nss_ad_marshall_data(ad_backend_ptr be, 1202b4a7802SBaban Kenkre nss_XbyY_args_t *argp); 1212b4a7802SBaban Kenkre extern nss_status_t _nss_ad_sanitize_status(ad_backend_ptr be, 1222b4a7802SBaban Kenkre nss_XbyY_args_t *argp, nss_status_t stat); 1232b4a7802SBaban Kenkre extern int _ldap_filter_name(char *filter_name, const char *name, 1242b4a7802SBaban Kenkre int filter_name_size); 1252b4a7802SBaban Kenkre 1262b4a7802SBaban Kenkre 1272b4a7802SBaban Kenkre #ifdef __cplusplus 1282b4a7802SBaban Kenkre } 1292b4a7802SBaban Kenkre #endif 1302b4a7802SBaban Kenkre 1312b4a7802SBaban Kenkre #endif /* _AD_COMMON_H */ 132