xref: /titanic_50/usr/src/lib/libidmap/common/idmap_impl.h (revision ff3124eff995e6cd8ebd8c6543648e0670920034)
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  * Private Header for Identity Mapping
28  */
29 
30 #ifndef _IDMAP_IMPL_H
31 #define	_IDMAP_IMPL_H
32 
33 #pragma ident	"%Z%%M%	%I%	%E% SMI"
34 
35 #include <rpc/xdr.h>
36 #include <libscf.h>
37 #include <syslog.h>
38 #include <resolv.h>
39 
40 #include "idmap_prot.h"
41 #include "idmap_priv.h"
42 #include "addisc.h"
43 
44 
45 #ifdef __cplusplus
46 extern "C" {
47 #endif
48 
49 #define	_IDMAP_HANDLE_RPC_DOORS		1
50 
51 #define	_IDMAP_GET_CLIENT_HANDLE(h, clnt) \
52 		if (h == NULL) \
53 			return (IDMAP_ERR_CLIENT_HANDLE);\
54 		if (h->type != _IDMAP_HANDLE_RPC_DOORS) \
55 			return (IDMAP_ERR_NOTSUPPORTED);\
56 		clnt = (CLIENT *)h->privhandle;\
57 		if (clnt == NULL)\
58 			return (IDMAP_ERR_RPC_HANDLE);
59 
60 struct idmap_handle {
61 	int	type;
62 	void	*privhandle;
63 	/* locks */
64 };
65 
66 struct idmap_udt_handle {
67 	struct idmap_handle	*ih;
68 	idmap_update_batch	batch;
69 	uint64_t		next;
70 	int64_t			error_index;
71 	idmap_stat		commit_stat;
72 	idmap_namerule		error_rule;
73 	idmap_namerule		conflict_rule;
74 };
75 
76 #define	_IDMAP_RESET_UDT_HANDLE(uh) \
77 	(void) xdr_free(xdr_idmap_update_batch, (caddr_t)&uh->batch);\
78 	uh->next = 0;\
79 	uh->error_index = -1;\
80 	(void) xdr_free(xdr_idmap_namerule, (caddr_t)&uh->error_rule);\
81 	(void) xdr_free(xdr_idmap_namerule, (caddr_t)&uh->conflict_rule);
82 
83 typedef struct idmap_get_res {
84 	idmap_id_type	idtype;
85 	uid_t		*uid;
86 	gid_t		*gid;
87 	int		*is_user;
88 	char		**sidprefix;
89 	idmap_rid_t	*rid;
90 	idmap_stat	*stat;
91 	idmap_info	*info;
92 } idmap_get_res_t;
93 
94 struct idmap_get_handle {
95 	struct idmap_handle	*ih;
96 	idmap_mapping_batch	batch;
97 	idmap_get_res_t		*retlist;
98 	uint64_t		next;
99 };
100 
101 #define	_IDMAP_RESET_GET_HANDLE(gh) \
102 	(void) xdr_free(xdr_idmap_mapping_batch, (caddr_t)&gh->batch);\
103 	if (gh->retlist) \
104 		free(gh->retlist);\
105 	gh->retlist = NULL;\
106 	gh->next = 0;
107 
108 struct idmap_iter {
109 	struct idmap_handle	*ih;
110 	int			type;
111 	uint64_t		limit;
112 	void			*arg;
113 	idmap_retcode		retcode;
114 	uint64_t		lastrowid;
115 	uint64_t		next;
116 	void			*retlist;
117 };
118 
119 typedef struct stat_table {
120 	idmap_retcode	retcode;
121 	const char	*msg;
122 	int		errnum;
123 } stat_table_t;
124 
125 typedef idmap_retcode	_idmap_stat;
126 
127 extern idmap_retcode	_udt_extend_batch(idmap_udt_handle_t *);
128 extern idmap_retcode	_get_ids_extend_batch(idmap_get_handle_t *);
129 extern idmap_stat	_iter_get_next_list(int, idmap_iter_t *, void *,
130 				uchar_t **, size_t, xdrproc_t, xdrproc_t);
131 extern idmap_stat	_idmap_rpc2stat(CLIENT *);
132 
133 extern idmap_stat idmap_get_prop_ds(idmap_handle_t *, idmap_prop_type,
134     idmap_ad_disc_ds_t *);
135 extern idmap_stat idmap_get_prop_str(idmap_handle_t *, idmap_prop_type,
136     char **);
137 
138 
139 #ifdef __cplusplus
140 }
141 #endif
142 
143 #endif /* _IDMAP_IMPL_H */
144