xref: /illumos-gate/usr/src/cmd/idmap/idmapd/idmap_config.h (revision 581cede61ac9c14d8d4ea452562a567189eead78)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef _IDMAP_CONFIG_H
27 #define	_IDMAP_CONFIG_H
28 
29 
30 #include "idmap.h"
31 #include "addisc.h"
32 #include <libscf.h>
33 #include <synch.h>
34 
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
38 
39 #define	MAX_POLICY_SIZE 1023
40 
41 /* SMF and auto-discovery context handles */
42 typedef struct idmap_cfg_handles {
43 	pthread_mutex_t		mutex;
44 	scf_handle_t		*main;
45 	scf_instance_t		*instance;
46 	scf_service_t		*service;
47 	scf_propertygroup_t	*config_pg;
48 	scf_propertygroup_t	*general_pg;
49 	ad_disc_t		ad_ctx;
50 } idmap_cfg_handles_t;
51 
52 /*
53  * This structure stores AD and AD-related configuration
54  */
55 typedef struct idmap_trustedforest {
56 	char		*forest_name;
57 	idmap_ad_disc_ds_t
58 			*global_catalog;	/* global catalog hosts */
59 	ad_disc_domainsinforest_t
60 			*domains_in_forest;
61 } idmap_trustedforest_t;
62 
63 
64 typedef struct idmap_pg_config {
65 	uint64_t	list_size_limit;
66 	/*
67 	 * The idmap_cfg_update_thread() uses the ad_disc_t context in
68 	 * the idmap_cfg_handles_t (see above) to track which values
69 	 * came from SMF and which values didn't.  This works for all
70 	 * items that are discoverable, but default_domain (the domain
71 	 * that we qualify unqualified names passed to idmap show) is
72 	 * not discoverable independently of domain_name.  So we need to
73 	 * track its procedence separately.  The dflt_dom_set_in_smf
74 	 * field does just that.
75 	 */
76 	char		*machine_sid;		/* machine sid */
77 	char		*default_domain;	/* default domain name */
78 	boolean_t	dflt_dom_set_in_smf;
79 	char		*domain_name;		/* AD domain name */
80 	boolean_t		domain_name_auto_disc;
81 	idmap_ad_disc_ds_t
82 			*domain_controller;	/* domain controller hosts */
83 	boolean_t	domain_controller_auto_disc;
84 	char		*forest_name;		/* forest name */
85 	boolean_t	forest_name_auto_disc;
86 	char		*site_name;		/* site name */
87 	boolean_t	site_name_auto_disc;
88 	idmap_ad_disc_ds_t
89 			*global_catalog;	/* global catalog hosts */
90 	boolean_t	global_catalog_auto_disc;
91 	ad_disc_domainsinforest_t
92 			*domains_in_forest;
93 	ad_disc_trusteddomains_t
94 			*trusted_domains;	/* Trusted Domains */
95 	int		num_trusted_forests;
96 	idmap_trustedforest_t
97 			*trusted_forests;	/* Array of trusted forests */
98 
99 	/*
100 	 * Following properties are associated with directory-based
101 	 * name-mappings.
102 	 */
103 	char		*ad_unixuser_attr;
104 	char		*ad_unixgroup_attr;
105 	char		*nldap_winname_attr;
106 	boolean_t	ds_name_mapping_enabled;
107 	boolean_t	eph_map_unres_sids;
108 } idmap_pg_config_t;
109 
110 typedef struct idmap_cfg {
111 	idmap_pg_config_t	pgcfg;	    /* live AD/ID mapping config */
112 	idmap_cfg_handles_t	handles;
113 	int			initialized;
114 } idmap_cfg_t;
115 
116 
117 extern void 		idmap_cfg_unload(idmap_pg_config_t *);
118 extern int		idmap_cfg_load(idmap_cfg_t *, int);
119 extern idmap_cfg_t	*idmap_cfg_init(void);
120 extern int		idmap_cfg_fini(idmap_cfg_t *);
121 extern int		idmap_cfg_start_updates(void);
122 extern void		idmap_cfg_poke_updates(void);
123 extern void		idmap_cfg_hup_handler(int);
124 
125 #define	CFG_DISCOVER		0x1
126 #define	CFG_LOG			0x2
127 
128 #ifdef __cplusplus
129 }
130 #endif
131 
132 #endif /* _IDMAP_CONFIG_H */
133