xref: /titanic_50/usr/src/uts/common/nfs/nfs_acl.h (revision c13de8f6a88563211bd4432ca11ca38ed3bf0fc0)
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 2006 Sun Microsystems, Inc.
23  *	All rights reserved.
24  *	Use is subject to license terms.
25  */
26 
27 #ifndef _NFS_NFS_ACL_H
28 #define	_NFS_NFS_ACL_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #ifdef	__cplusplus
33 extern "C" {
34 #endif
35 
36 #define	NFS_ACL_MAX_ENTRIES	1024
37 
38 typedef ushort_t o_mode;
39 
40 struct aclent {
41 	int type;
42 	uid32_t id;
43 	o_mode perm;
44 };
45 typedef struct aclent aclent;
46 
47 #define	NA_USER_OBJ	0x1
48 #define	NA_USER		0x2
49 #define	NA_GROUP_OBJ	0x4
50 #define	NA_GROUP	0x8
51 #define	NA_CLASS_OBJ	0x10
52 #define	NA_OTHER_OBJ	0x20
53 #define	NA_ACL_DEFAULT	0x1000
54 
55 #define	NA_READ		0x4
56 #define	NA_WRITE	0x2
57 #define	NA_EXEC		0x1
58 
59 struct secattr {
60 	uint32 mask;
61 	int aclcnt;
62 	struct {
63 		uint_t aclent_len;
64 		aclent *aclent_val;
65 	} aclent;
66 	int dfaclcnt;
67 	struct {
68 		uint_t dfaclent_len;
69 		aclent *dfaclent_val;
70 	} dfaclent;
71 };
72 typedef struct secattr secattr;
73 
74 #define	NA_ACL		0x1
75 #define	NA_ACLCNT	0x2
76 #define	NA_DFACL	0x4
77 #define	NA_DFACLCNT	0x8
78 
79 struct GETACL2args {
80 	fhandle_t fh;
81 	uint32 mask;
82 };
83 typedef struct GETACL2args GETACL2args;
84 
85 struct GETACL2resok {
86 	struct nfsfattr attr;
87 	vsecattr_t acl;
88 };
89 typedef struct GETACL2resok GETACL2resok;
90 
91 struct GETACL2res {
92 	enum nfsstat status;
93 	union {
94 		GETACL2resok ok;
95 	} res_u;
96 };
97 typedef struct GETACL2res GETACL2res;
98 
99 struct SETACL2args {
100 	fhandle_t fh;
101 	vsecattr_t acl;
102 };
103 typedef struct SETACL2args SETACL2args;
104 
105 struct SETACL2resok {
106 	struct nfsfattr attr;
107 };
108 typedef struct SETACL2resok SETACL2resok;
109 
110 struct SETACL2res {
111 	enum nfsstat status;
112 	union {
113 		SETACL2resok ok;
114 	} res_u;
115 };
116 typedef struct SETACL2res SETACL2res;
117 
118 struct GETATTR2args {
119 	fhandle_t fh;
120 };
121 typedef struct GETATTR2args GETATTR2args;
122 
123 struct GETATTR2resok {
124 	struct nfsfattr attr;
125 };
126 typedef struct GETATTR2resok GETATTR2resok;
127 
128 struct GETATTR2res {
129 	enum nfsstat status;
130 	union {
131 		GETATTR2resok ok;
132 	} res_u;
133 };
134 typedef struct GETATTR2res GETATTR2res;
135 
136 struct ACCESS2args {
137 	fhandle_t fh;
138 	uint32 access;
139 };
140 typedef struct ACCESS2args ACCESS2args;
141 
142 #define	ACCESS2_READ	0x1
143 #define	ACCESS2_LOOKUP	0x2
144 #define	ACCESS2_MODIFY	0x4
145 #define	ACCESS2_EXTEND	0x8
146 #define	ACCESS2_DELETE	0x10
147 #define	ACCESS2_EXECUTE	0x20
148 
149 struct ACCESS2resok {
150 	struct nfsfattr attr;
151 	uint32 access;
152 };
153 typedef struct ACCESS2resok ACCESS2resok;
154 
155 struct ACCESS2res {
156 	enum nfsstat status;
157 	union {
158 		ACCESS2resok ok;
159 	} res_u;
160 };
161 typedef struct ACCESS2res ACCESS2res;
162 
163 struct GETXATTRDIR2args {
164 	fhandle_t fh;
165 	bool_t create;
166 };
167 typedef struct GETXATTRDIR2args GETXATTRDIR2args;
168 
169 struct GETXATTRDIR2resok {
170 	fhandle_t fh;
171 	struct nfsfattr attr;
172 };
173 typedef struct GETXATTRDIR2resok GETXATTRDIR2resok;
174 
175 struct GETXATTRDIR2res {
176 	enum nfsstat status;
177 	union {
178 		GETXATTRDIR2resok ok;
179 	} res_u;
180 };
181 typedef struct GETXATTRDIR2res GETXATTRDIR2res;
182 
183 struct GETACL3args {
184 	nfs_fh3 fh;
185 	uint32 mask;
186 };
187 typedef struct GETACL3args GETACL3args;
188 
189 struct GETACL3resok {
190 	post_op_attr attr;
191 	vsecattr_t acl;
192 };
193 typedef struct GETACL3resok GETACL3resok;
194 
195 struct GETACL3resfail {
196 	post_op_attr attr;
197 };
198 typedef struct GETACL3resfail GETACL3resfail;
199 
200 struct GETACL3res {
201 	nfsstat3 status;
202 	union {
203 		GETACL3resok ok;
204 		GETACL3resfail fail;
205 	} res_u;
206 };
207 typedef struct GETACL3res GETACL3res;
208 
209 struct SETACL3args {
210 	nfs_fh3 fh;
211 	vsecattr_t acl;
212 };
213 typedef struct SETACL3args SETACL3args;
214 
215 struct SETACL3resok {
216 	post_op_attr attr;
217 };
218 typedef struct SETACL3resok SETACL3resok;
219 
220 struct SETACL3resfail {
221 	post_op_attr attr;
222 };
223 typedef struct SETACL3resfail SETACL3resfail;
224 
225 struct SETACL3res {
226 	nfsstat3 status;
227 	union {
228 		SETACL3resok ok;
229 		SETACL3resfail fail;
230 	} res_u;
231 };
232 typedef struct SETACL3res SETACL3res;
233 
234 struct GETXATTRDIR3args {
235 	nfs_fh3 fh;
236 	bool_t create;
237 };
238 typedef struct GETXATTRDIR3args GETXATTRDIR3args;
239 
240 struct GETXATTRDIR3resok {
241 	nfs_fh3 fh;
242 	post_op_attr attr;
243 };
244 typedef struct GETXATTRDIR3resok GETXATTRDIR3resok;
245 
246 struct GETXATTRDIR3res {
247 	nfsstat3 status;
248 	union {
249 		GETXATTRDIR3resok ok;
250 	} res_u;
251 };
252 typedef struct GETXATTRDIR3res GETXATTRDIR3res;
253 
254 #define	NFS_ACL_PROGRAM	((rpcprog_t)(100227))
255 #define	NFS_ACL_VERSMIN	((rpcvers_t)(2))
256 #define	NFS_ACL_VERSMAX	((rpcvers_t)(3))
257 
258 #define	NFS_ACL_V2		((rpcvers_t)(2))
259 #define	ACLPROC2_NULL		((rpcproc_t)(0))
260 #define	ACLPROC2_GETACL		((rpcproc_t)(1))
261 #define	ACLPROC2_SETACL		((rpcproc_t)(2))
262 #define	ACLPROC2_GETATTR	((rpcproc_t)(3))
263 #define	ACLPROC2_ACCESS		((rpcproc_t)(4))
264 #define	ACLPROC2_GETXATTRDIR	((rpcproc_t)(5))
265 
266 #define	NFS_ACL_V3		((rpcvers_t)(3))
267 #define	ACLPROC3_NULL		((rpcproc_t)(0))
268 #define	ACLPROC3_GETACL		((rpcproc_t)(1))
269 #define	ACLPROC3_SETACL		((rpcproc_t)(2))
270 #define	ACLPROC3_GETXATTRDIR	((rpcproc_t)(3))
271 
272 #ifdef _KERNEL
273 /* the xdr functions */
274 extern bool_t xdr_uid(XDR *, uid32_t *);
275 extern bool_t xdr_o_mode(XDR *, o_mode *);
276 extern bool_t xdr_aclent(XDR *, aclent_t *);
277 extern bool_t xdr_secattr(XDR *, vsecattr_t *);
278 
279 extern bool_t xdr_GETACL2args(XDR *, GETACL2args *);
280 extern bool_t xdr_fastGETACL2args(XDR *, GETACL2args **);
281 extern bool_t xdr_GETACL2resok(XDR *, GETACL2resok *);
282 extern bool_t xdr_GETACL2res(XDR *, GETACL2res *);
283 extern bool_t xdr_SETACL2args(XDR *, SETACL2args *);
284 extern bool_t xdr_SETACL2resok(XDR *, SETACL2resok *);
285 #ifdef _LITTLE_ENDIAN
286 extern bool_t xdr_fastSETACL2resok(XDR *, SETACL2resok *);
287 #endif
288 extern bool_t xdr_SETACL2res(XDR *, SETACL2res *);
289 #ifdef _LITTLE_ENDIAN
290 extern bool_t xdr_fastSETACL2res(XDR *, SETACL2res *);
291 #endif
292 extern bool_t xdr_GETATTR2args(XDR *, GETATTR2args *);
293 extern bool_t xdr_fastGETATTR2args(XDR *, GETATTR2args **);
294 extern bool_t xdr_GETATTR2resok(XDR *, GETATTR2resok *);
295 #ifdef _LITTLE_ENDIAN
296 extern bool_t xdr_fastGETATTR2resok(XDR *, GETATTR2resok *);
297 #endif
298 extern bool_t xdr_GETATTR2res(XDR *, GETATTR2res *);
299 #ifdef _LITTLE_ENDIAN
300 extern bool_t xdr_fastGETATTR2res(XDR *, GETATTR2res *);
301 #endif
302 extern bool_t xdr_ACCESS2args(XDR *, ACCESS2args *);
303 extern bool_t xdr_fastACCESS2args(XDR *, ACCESS2args **);
304 extern bool_t xdr_ACCESS2resok(XDR *, ACCESS2resok *);
305 #ifdef _LITTLE_ENDIAN
306 extern bool_t xdr_fastACCESS2resok(XDR *, ACCESS2resok *);
307 #endif
308 extern bool_t xdr_ACCESS2res(XDR *, ACCESS2res *);
309 #ifdef _LITTLE_ENDIAN
310 extern bool_t xdr_fastACCESS2res(XDR *, ACCESS2res *);
311 #endif
312 extern bool_t xdr_GETXATTRDIR2args(XDR *, GETXATTRDIR2args *);
313 extern bool_t xdr_GETXATTRDIR2res(XDR *, GETXATTRDIR2res *);
314 
315 extern bool_t xdr_GETACL3args(XDR *, GETACL3args *);
316 extern bool_t xdr_GETACL3resok(XDR *, GETACL3resok *);
317 extern bool_t xdr_GETACL3resfail(XDR *, GETACL3resfail *);
318 extern bool_t xdr_GETACL3res(XDR *, GETACL3res *);
319 extern bool_t xdr_SETACL3args(XDR *, SETACL3args *);
320 extern bool_t xdr_SETACL3resok(XDR *, SETACL3resok *);
321 extern bool_t xdr_SETACL3resfail(XDR *, SETACL3resfail *);
322 extern bool_t xdr_SETACL3res(XDR *, SETACL3res *);
323 extern bool_t xdr_GETXATTRDIR3args(XDR *, GETXATTRDIR3args *);
324 extern bool_t xdr_GETXATTRDIR3res(XDR *, GETXATTRDIR3res *);
325 
326 #endif
327 
328 #ifdef _KERNEL
329 /* the service procedures */
330 extern void acl2_getacl(GETACL2args *, GETACL2res *,
331 			struct exportinfo *, struct svc_req *, cred_t *);
332 extern void *acl2_getacl_getfh(GETACL2args *);
333 extern void acl2_getacl_free(GETACL2res *);
334 extern void acl2_setacl(SETACL2args *, SETACL2res *,
335 			struct exportinfo *, struct svc_req *, cred_t *);
336 extern void *acl2_setacl_getfh(SETACL2args *);
337 extern void acl2_getattr(GETATTR2args *, GETATTR2res *,
338 			struct exportinfo *, struct svc_req *, cred_t *);
339 extern void *acl2_getattr_getfh(GETATTR2args *);
340 extern void acl2_access(ACCESS2args *, ACCESS2res *,
341 			struct exportinfo *, struct svc_req *, cred_t *);
342 extern void *acl2_access_getfh(ACCESS2args *);
343 extern void acl2_getxattrdir(GETXATTRDIR2args *, GETXATTRDIR2res *,
344 			struct exportinfo *, struct svc_req *, cred_t *);
345 extern void *acl2_getxattrdir_getfh(GETXATTRDIR2args *);
346 
347 extern void acl3_getacl(GETACL3args *, GETACL3res *,
348 			struct exportinfo *, struct svc_req *, cred_t *);
349 extern void *acl3_getacl_getfh(GETACL3args *);
350 extern void acl3_getacl_free(GETACL3res *);
351 extern void acl3_setacl(SETACL3args *, SETACL3res *,
352 			struct exportinfo *, struct svc_req *, cred_t *);
353 extern void *acl3_setacl_getfh(SETACL3args *);
354 extern void acl3_getxattrdir(GETXATTRDIR3args *, GETXATTRDIR3res *,
355 			struct exportinfo *, struct svc_req *, cred_t *);
356 extern void *acl3_getxattrdir_getfh(GETXATTRDIR3args *);
357 
358 #endif
359 
360 #ifdef _KERNEL
361 /* the client side procedures */
362 extern int acl_getacl2(vnode_t *, vsecattr_t *, int, cred_t *);
363 extern int acl_setacl2(vnode_t *, vsecattr_t *, int, cred_t *);
364 extern int acl_getattr2_otw(vnode_t *, vattr_t *, cred_t *);
365 extern int acl_access2(vnode_t *, int, int, cred_t *);
366 extern int acl_getxattrdir2(vnode_t *, vnode_t **, bool_t, cred_t *, int);
367 extern int acl_getacl3(vnode_t *, vsecattr_t *, int, cred_t *);
368 extern int acl_setacl3(vnode_t *, vsecattr_t *, int, cred_t *);
369 extern int acl_getxattrdir3(vnode_t *, vnode_t **, bool_t, cred_t *, int);
370 extern int acl2call(mntinfo_t *, rpcproc_t, xdrproc_t, caddr_t, xdrproc_t,
371 			caddr_t, cred_t *, int *, enum nfsstat *, int,
372 			failinfo_t *);
373 extern int acl3call(mntinfo_t *, rpcproc_t, xdrproc_t, caddr_t, xdrproc_t,
374 			caddr_t, cred_t *, int *, nfsstat3 *, int,
375 			failinfo_t *);
376 extern void nfs_acl_free(vsecattr_t *);
377 #endif
378 
379 #ifdef _KERNEL
380 /* server and client data structures */
381 extern kstat_named_t	*aclproccnt_v2_ptr;
382 extern kstat_named_t	*aclproccnt_v3_ptr;
383 
384 extern char		*aclnames_v2[];
385 extern uchar_t		acl_call_type_v2[];
386 extern uchar_t		acl_ss_call_type_v2[];
387 extern uchar_t		acl_timer_type_v2[];
388 
389 extern char		*aclnames_v3[];
390 extern uchar_t		acl_call_type_v3[];
391 extern uchar_t		acl_ss_call_type_v3[];
392 extern uchar_t		acl_timer_type_v3[];
393 #endif
394 
395 #ifdef	__cplusplus
396 }
397 #endif
398 
399 #endif	/* _NFS_NFS_ACL_H */
400