xref: /titanic_44/usr/src/lib/libidmap/common/idmap_priv.h (revision 21bf64a78855d076f09716ea1c06175d954e934c)
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 2008 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 /*
27  * Additional API for Identity Mapping Service
28  */
29 
30 #ifndef _IDMAP_PRIV_H
31 #define	_IDMAP_PRIV_H
32 
33 #pragma ident	"%Z%%M%	%I%	%E% SMI"
34 
35 #include "idmap.h"
36 #include "idmap_prot.h"
37 
38 #ifdef __cplusplus
39 extern "C" {
40 #endif
41 
42 #define	IDMAP_MAX_NAME_LEN	512
43 
44 #define	IDMAP_ERROR(rc)		(rc != IDMAP_SUCCESS && rc != IDMAP_NEXT)
45 #define	IDMAP_FATAL_ERROR(rc)	(rc == IDMAP_ERR_MEMORY ||\
46 				rc == IDMAP_ERR_DB)
47 
48 /* Direction in which mapping is valid */
49 #define	IDMAP_DIRECTION_UNDEF	-1	/* not defined */
50 #define	IDMAP_DIRECTION_BI	0	/* bi-directional */
51 #define	IDMAP_DIRECTION_W2U	1	/* windows to unix only */
52 #define	IDMAP_DIRECTION_U2W	2	/* unix to windows only */
53 
54 /* Opaque handle to batch config add/remove operations */
55 typedef struct idmap_udt_handle idmap_udt_handle_t;
56 
57 /* Opaque iterator */
58 typedef struct idmap_iter idmap_iter_t;
59 
60 /*
61  * Update API
62  */
63 
64 /* Create handle for updates */
65 extern idmap_stat idmap_udt_create(idmap_handle_t *,
66 	idmap_udt_handle_t **);
67 
68 /* Commit */
69 extern idmap_stat idmap_udt_commit(idmap_udt_handle_t *);
70 
71 /* Get index of the failed batch element */
72 extern idmap_stat idmap_udt_get_error_index(idmap_udt_handle_t *, int64_t *);
73 
74 /* Get the rule which caused the batch to failed */
75 extern idmap_stat idmap_udt_get_error_rule(idmap_udt_handle_t *, char **,
76     char **, char **, boolean_t *, boolean_t *, boolean_t *, int *);
77 
78 /* Get the rule which caused a conflict */
79 extern idmap_stat idmap_udt_get_conflict_rule(idmap_udt_handle_t *, char **,
80     char **, char **, boolean_t *, boolean_t *, boolean_t *, int *);
81 
82 /* Destroy the update handle */
83 extern void idmap_udt_destroy(idmap_udt_handle_t *);
84 
85 /* Add name-based mapping rule */
86 extern idmap_stat idmap_udt_add_namerule(idmap_udt_handle_t *, const char *,
87 	boolean_t, boolean_t, const char *, const char *, boolean_t, int);
88 
89 /* Remove name-based mapping rule */
90 extern idmap_stat idmap_udt_rm_namerule(idmap_udt_handle_t *, boolean_t,
91 	boolean_t, const char *, const char *, const char *, int);
92 
93 /* Flush name-based mapping rules */
94 extern idmap_stat idmap_udt_flush_namerules(idmap_udt_handle_t *);
95 
96 
97 /*
98  * Iterator API
99  */
100 
101 /* Create a iterator to get SID to UID/GID mappings */
102 extern idmap_stat idmap_iter_mappings(idmap_handle_t *,	idmap_iter_t **,
103 	int flag);
104 
105 /* Iterate through the SID to UID/GID mappings */
106 extern idmap_stat idmap_iter_next_mapping(idmap_iter_t *, char **,
107 	idmap_rid_t *, uid_t *, char **, char **, char **, boolean_t *,
108 	boolean_t *, int *, idmap_info *);
109 
110 /* Create a iterator to get name-based mapping rules */
111 extern idmap_stat idmap_iter_namerules(idmap_handle_t *, const char *,
112 	boolean_t, boolean_t, const char *, const char *, idmap_iter_t **);
113 
114 /* Iterate through the name-based mapping rules */
115 extern idmap_stat idmap_iter_next_namerule(idmap_iter_t *, char **,
116 	char **, char **, boolean_t *, boolean_t *, boolean_t *, int *);
117 
118 /* Set the number of entries requested per batch */
119 extern idmap_stat idmap_iter_set_limit(idmap_iter_t *, uint64_t);
120 
121 /* Destroy the iterator */
122 extern void idmap_iter_destroy(idmap_iter_t *);
123 
124 
125 /*
126  * Get mapping
127  */
128 extern idmap_stat idmap_get_w2u_mapping(idmap_handle_t *, const char *,
129 	idmap_rid_t *, const char *, const char *, int, int *, int *,
130 	uid_t *, char **, int *, idmap_info *);
131 
132 extern idmap_stat idmap_get_u2w_mapping(idmap_handle_t *, uid_t *,
133 	const char *, int, int, int *, char **, idmap_rid_t *, char **,
134 	char **, int *, idmap_info *);
135 
136 
137 /*
138  * Miscellaneous
139  */
140 
141 /* string to status */
142 extern idmap_stat idmap_string2stat(const char *);
143 
144 /* internal status to protocol status */
145 extern idmap_stat idmap_stat4prot(idmap_stat);
146 
147 /* copy idmap_namerule including strings */
148 extern idmap_stat idmap_namerule_cpy(idmap_namerule *, idmap_namerule *);
149 
150 /* copy idmap_info info including strings */
151 extern idmap_stat idmap_info_cpy(idmap_info *to, idmap_info *from);
152 
153 /* Move  idmap_info info including strings */
154 extern idmap_stat idmap_info_mov(idmap_info *to, idmap_info *from);
155 
156 /* free idmap_info info from  user supplied struct */
157 extern void idmap_info_free(idmap_info *);
158 
159 
160 /*
161  * Extended API to batch SID to UID/GID mapping requests
162  */
163 
164 /* Given SID, get UID */
165 extern idmap_stat idmap_getext_uidbysid(idmap_get_handle_t *, char *,
166 	idmap_rid_t, int, uid_t *, idmap_info *, idmap_stat *);
167 
168 /* Given SID, get GID */
169 extern idmap_stat idmap_getext_gidbysid(idmap_get_handle_t *, char *,
170 	idmap_rid_t, int, gid_t *, idmap_info *, idmap_stat *);
171 
172 /* Given SID, get UID or GID */
173 extern idmap_stat idmap_getext_pidbysid(idmap_get_handle_t *, char *,
174 	idmap_rid_t, int, uid_t *, int *, idmap_info *, idmap_stat *);
175 
176 /* Given UID, get SID */
177 extern idmap_stat idmap_getext_sidbyuid(idmap_get_handle_t *, uid_t, int,
178 	char **, idmap_rid_t *, idmap_info *, idmap_stat *);
179 
180 /* Given GID, get SID */
181 extern idmap_stat idmap_getext_sidbygid(idmap_get_handle_t *, gid_t, int,
182 	char **, idmap_rid_t *, idmap_info *, idmap_stat *);
183 
184 
185 
186 #ifdef __cplusplus
187 }
188 #endif
189 
190 #endif /* _IDMAP_PRIV_H */
191