1c5c4113dSnw /*
2c5c4113dSnw  * CDDL HEADER START
3c5c4113dSnw  *
4c5c4113dSnw  * The contents of this file are subject to the terms of the
5c5c4113dSnw  * Common Development and Distribution License (the "License").
6c5c4113dSnw  * You may not use this file except in compliance with the License.
7c5c4113dSnw  *
8c5c4113dSnw  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9c5c4113dSnw  * or http://www.opensolaris.org/os/licensing.
10c5c4113dSnw  * See the License for the specific language governing permissions
11c5c4113dSnw  * and limitations under the License.
12c5c4113dSnw  *
13c5c4113dSnw  * When distributing Covered Code, include this CDDL HEADER in each
14c5c4113dSnw  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15c5c4113dSnw  * If applicable, add the following below this CDDL HEADER, with the
16c5c4113dSnw  * fields enclosed by brackets "[]" replaced with your own identifying
17c5c4113dSnw  * information: Portions Copyright [yyyy] [name of copyright owner]
18c5c4113dSnw  *
19c5c4113dSnw  * CDDL HEADER END
20c5c4113dSnw  */
21c5c4113dSnw /*
22148c5f43SAlan Wright  * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
23*b3700b07SGordon Ross  * Copyright 2014 Nexenta Systems, Inc.  All rights reserved.
24c5c4113dSnw  */
25c5c4113dSnw 
26c5c4113dSnw #ifndef _IDMAP_CONFIG_H
27c5c4113dSnw #define	_IDMAP_CONFIG_H
28c5c4113dSnw 
29c5c4113dSnw 
30c5c4113dSnw #include "idmap.h"
31c8e26105Sjp #include "addisc.h"
32c5c4113dSnw #include <libscf.h>
33c5c4113dSnw #include <synch.h>
34*b3700b07SGordon Ross #include <sys/uuid.h>
35c5c4113dSnw 
36c5c4113dSnw #ifdef __cplusplus
37c5c4113dSnw extern "C" {
38c5c4113dSnw #endif
39c5c4113dSnw 
40c5c4113dSnw #define	MAX_POLICY_SIZE 1023
41c5c4113dSnw 
42e3f2c991SKeyur Desai #define	DIRECTORY_MAPPING_NONE	0
43e3f2c991SKeyur Desai #define	DIRECTORY_MAPPING_NAME	1
44e3f2c991SKeyur Desai #define	DIRECTORY_MAPPING_IDMU	2
45e3f2c991SKeyur Desai 
46e3f2c991SKeyur Desai struct enum_lookup_map {
47e3f2c991SKeyur Desai 	int value;
48e3f2c991SKeyur Desai 	char *string;
49e3f2c991SKeyur Desai };
50e3f2c991SKeyur Desai 
51e3f2c991SKeyur Desai extern struct enum_lookup_map directory_mapping_map[];
52e3f2c991SKeyur Desai extern const char *enum_lookup(int value, struct enum_lookup_map *map);
53e3f2c991SKeyur Desai 
54c8e26105Sjp /* SMF and auto-discovery context handles */
55c8e26105Sjp typedef struct idmap_cfg_handles {
56c8e26105Sjp 	pthread_mutex_t		mutex;
57c5c4113dSnw 	scf_handle_t		*main;
58c5c4113dSnw 	scf_instance_t		*instance;
59c5c4113dSnw 	scf_service_t		*service;
60c5c4113dSnw 	scf_propertygroup_t	*config_pg;
61148c5f43SAlan Wright 	scf_propertygroup_t	*debug_pg;
62c8e26105Sjp 	ad_disc_t		ad_ctx;
63c8e26105Sjp } idmap_cfg_handles_t;
64c5c4113dSnw 
65c8e26105Sjp /*
66c8e26105Sjp  * This structure stores AD and AD-related configuration
67c8e26105Sjp  */
684d61c878SJulian Pullen typedef struct idmap_trustedforest {
694d61c878SJulian Pullen 	char		*forest_name;
70*b3700b07SGordon Ross 	ad_disc_ds_t	*global_catalog;	/* global catalog hosts */
714d61c878SJulian Pullen 	ad_disc_domainsinforest_t
724d61c878SJulian Pullen 			*domains_in_forest;
734d61c878SJulian Pullen } idmap_trustedforest_t;
744d61c878SJulian Pullen 
754d61c878SJulian Pullen 
76c5c4113dSnw typedef struct idmap_pg_config {
77c5c4113dSnw 	uint64_t	list_size_limit;
7848cd229bSGordon Ross 	uint64_t	id_cache_timeout;
7948cd229bSGordon Ross 	uint64_t	name_cache_timeout;
80*b3700b07SGordon Ross 	uint64_t	rediscovery_interval;
8112b65585SGordon Ross 	char		*machine_uuid;		/* machine uuid */
824d61c878SJulian Pullen 	char		*machine_sid;		/* machine sid */
83c8e26105Sjp 	char		*default_domain;	/* default domain name */
84c8e26105Sjp 	char		*domain_name;		/* AD domain name */
85*b3700b07SGordon Ross 	boolean_t	domain_name_auto_disc;
86*b3700b07SGordon Ross 	char		*domain_guid;		/* GUID (string) */
87*b3700b07SGordon Ross 	boolean_t	domain_guid_auto_disc;
88*b3700b07SGordon Ross 	ad_disc_ds_t	*domain_controller;	/* domain controller hosts */
897a8a68f5SJulian Pullen 	boolean_t	domain_controller_auto_disc;
90c8e26105Sjp 	char		*forest_name;		/* forest name */
917a8a68f5SJulian Pullen 	boolean_t	forest_name_auto_disc;
92c8e26105Sjp 	char		*site_name;		/* site name */
937a8a68f5SJulian Pullen 	boolean_t	site_name_auto_disc;
94*b3700b07SGordon Ross 	ad_disc_ds_t	*global_catalog;	/* global catalog hosts */
957a8a68f5SJulian Pullen 	boolean_t	global_catalog_auto_disc;
964d61c878SJulian Pullen 	ad_disc_domainsinforest_t
974d61c878SJulian Pullen 			*domains_in_forest;
984d61c878SJulian Pullen 	ad_disc_trusteddomains_t
994d61c878SJulian Pullen 			*trusted_domains;	/* Trusted Domains */
1004d61c878SJulian Pullen 	int		num_trusted_forests;
1014d61c878SJulian Pullen 	idmap_trustedforest_t
1024d61c878SJulian Pullen 			*trusted_forests;	/* Array of trusted forests */
1034d61c878SJulian Pullen 
104*b3700b07SGordon Ross 	ad_disc_ds_t	*preferred_dc;
105*b3700b07SGordon Ross 	boolean_t	preferred_dc_auto_disc;
106*b3700b07SGordon Ross 
107e8c27ec8Sbaban 	/*
108e8c27ec8Sbaban 	 * Following properties are associated with directory-based
109e8c27ec8Sbaban 	 * name-mappings.
110e8c27ec8Sbaban 	 */
111e8c27ec8Sbaban 	char		*ad_unixuser_attr;
112e8c27ec8Sbaban 	char		*ad_unixgroup_attr;
113e8c27ec8Sbaban 	char		*nldap_winname_attr;
114e3f2c991SKeyur Desai 	int		directory_based_mapping;	/* enum */
1157a8a68f5SJulian Pullen 	boolean_t	eph_map_unres_sids;
1161ed6b69aSGordon Ross 	boolean_t	use_ads;
117148c5f43SAlan Wright 	boolean_t	use_lsa;
118148c5f43SAlan Wright 	boolean_t	disable_cross_forest_trusts;
119c5c4113dSnw } idmap_pg_config_t;
120c5c4113dSnw 
121c5c4113dSnw typedef struct idmap_cfg {
122c8e26105Sjp 	idmap_pg_config_t	pgcfg;	    /* live AD/ID mapping config */
123c8e26105Sjp 	idmap_cfg_handles_t	handles;
124349d5d8fSnw 	int			initialized;
125c5c4113dSnw } idmap_cfg_t;
126c5c4113dSnw 
127c8e26105Sjp 
128c8e26105Sjp extern void 		idmap_cfg_unload(idmap_pg_config_t *);
129349d5d8fSnw extern int		idmap_cfg_load(idmap_cfg_t *, int);
130c8e26105Sjp extern idmap_cfg_t	*idmap_cfg_init(void);
131c5c4113dSnw extern int		idmap_cfg_fini(idmap_cfg_t *);
132e3f2c991SKeyur Desai extern int		idmap_cfg_upgrade(idmap_cfg_t *);
1330dcc7149Snw extern int		idmap_cfg_start_updates(void);
1340dcc7149Snw extern void		idmap_cfg_poke_updates(void);
135*b3700b07SGordon Ross extern void		idmap_cfg_force_rediscovery(void);
1360dcc7149Snw extern void		idmap_cfg_hup_handler(int);
137c5c4113dSnw 
138*b3700b07SGordon Ross #define	CFG_DISCOVER		0x1	/* Run discovery */
139*b3700b07SGordon Ross #define	CFG_FORGET_DC		0x2	/* Forget current DC. */
140*b3700b07SGordon Ross #define	CFG_LOG			0x4
141349d5d8fSnw 
142c5c4113dSnw #ifdef __cplusplus
143c5c4113dSnw }
144c5c4113dSnw #endif
145c5c4113dSnw 
146c5c4113dSnw #endif /* _IDMAP_CONFIG_H */
147