summaryrefslogtreecommitdiff
path: root/usr/src/uts/common/nfs/nfs_acl.h
blob: f3ab47646796cb2ea810bc35baf81a4964f59362 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License (the "License").
 * You may not use this file except in compliance with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 *	Copyright 2006 Sun Microsystems, Inc.
 *	All rights reserved.
 *	Use is subject to license terms.
 */
/*
 * Copyright 2014 Nexenta Systems, Inc.  All rights reserved.
 */

#ifndef _NFS_NFS_ACL_H
#define	_NFS_NFS_ACL_H

#ifdef	__cplusplus
extern "C" {
#endif

#define	NFS_ACL_MAX_ENTRIES	1024

typedef ushort_t o_mode;

struct aclent {
	int type;
	uid32_t id;
	o_mode perm;
};
typedef struct aclent aclent;

#define	NA_USER_OBJ	0x1
#define	NA_USER		0x2
#define	NA_GROUP_OBJ	0x4
#define	NA_GROUP	0x8
#define	NA_CLASS_OBJ	0x10
#define	NA_OTHER_OBJ	0x20
#define	NA_ACL_DEFAULT	0x1000

#define	NA_READ		0x4
#define	NA_WRITE	0x2
#define	NA_EXEC		0x1

struct secattr {
	uint32 mask;
	int aclcnt;
	struct {
		uint_t aclent_len;
		aclent *aclent_val;
	} aclent;
	int dfaclcnt;
	struct {
		uint_t dfaclent_len;
		aclent *dfaclent_val;
	} dfaclent;
};
typedef struct secattr secattr;

#define	NA_ACL		0x1
#define	NA_ACLCNT	0x2
#define	NA_DFACL	0x4
#define	NA_DFACLCNT	0x8

struct GETACL2args {
	fhandle_t fh;
	uint32 mask;
};
typedef struct GETACL2args GETACL2args;

struct GETACL2resok {
	struct nfsfattr attr;
	vsecattr_t acl;
};
typedef struct GETACL2resok GETACL2resok;

struct GETACL2res {
	enum nfsstat status;
	union {
		GETACL2resok ok;
	} res_u;
};
typedef struct GETACL2res GETACL2res;

struct SETACL2args {
	fhandle_t fh;
	vsecattr_t acl;
};
typedef struct SETACL2args SETACL2args;

struct SETACL2resok {
	struct nfsfattr attr;
};
typedef struct SETACL2resok SETACL2resok;

struct SETACL2res {
	enum nfsstat status;
	union {
		SETACL2resok ok;
	} res_u;
};
typedef struct SETACL2res SETACL2res;

struct GETATTR2args {
	fhandle_t fh;
};
typedef struct GETATTR2args GETATTR2args;

struct GETATTR2resok {
	struct nfsfattr attr;
};
typedef struct GETATTR2resok GETATTR2resok;

struct GETATTR2res {
	enum nfsstat status;
	union {
		GETATTR2resok ok;
	} res_u;
};
typedef struct GETATTR2res GETATTR2res;

struct ACCESS2args {
	fhandle_t fh;
	uint32 access;
};
typedef struct ACCESS2args ACCESS2args;

#define	ACCESS2_READ	0x1
#define	ACCESS2_LOOKUP	0x2
#define	ACCESS2_MODIFY	0x4
#define	ACCESS2_EXTEND	0x8
#define	ACCESS2_DELETE	0x10
#define	ACCESS2_EXECUTE	0x20

struct ACCESS2resok {
	struct nfsfattr attr;
	uint32 access;
};
typedef struct ACCESS2resok ACCESS2resok;

struct ACCESS2res {
	enum nfsstat status;
	union {
		ACCESS2resok ok;
	} res_u;
};
typedef struct ACCESS2res ACCESS2res;

struct GETXATTRDIR2args {
	fhandle_t fh;
	bool_t create;
};
typedef struct GETXATTRDIR2args GETXATTRDIR2args;

struct GETXATTRDIR2resok {
	fhandle_t fh;
	struct nfsfattr attr;
};
typedef struct GETXATTRDIR2resok GETXATTRDIR2resok;

struct GETXATTRDIR2res {
	enum nfsstat status;
	union {
		GETXATTRDIR2resok ok;
	} res_u;
};
typedef struct GETXATTRDIR2res GETXATTRDIR2res;

struct GETACL3args {
	nfs_fh3 fh;
	uint32 mask;
};
typedef struct GETACL3args GETACL3args;

struct GETACL3resok {
	post_op_attr attr;
	vsecattr_t acl;
};
typedef struct GETACL3resok GETACL3resok;

struct GETACL3resfail {
	post_op_attr attr;
};
typedef struct GETACL3resfail GETACL3resfail;

struct GETACL3res {
	nfsstat3 status;
	union {
		GETACL3resok ok;
		GETACL3resfail fail;
	} res_u;
};
typedef struct GETACL3res GETACL3res;

struct SETACL3args {
	nfs_fh3 fh;
	vsecattr_t acl;
};
typedef struct SETACL3args SETACL3args;

struct SETACL3resok {
	post_op_attr attr;
};
typedef struct SETACL3resok SETACL3resok;

struct SETACL3resfail {
	post_op_attr attr;
};
typedef struct SETACL3resfail SETACL3resfail;

struct SETACL3res {
	nfsstat3 status;
	union {
		SETACL3resok ok;
		SETACL3resfail fail;
	} res_u;
};
typedef struct SETACL3res SETACL3res;

struct GETXATTRDIR3args {
	nfs_fh3 fh;
	bool_t create;
};
typedef struct GETXATTRDIR3args GETXATTRDIR3args;

struct GETXATTRDIR3resok {
	nfs_fh3 fh;
	post_op_attr attr;
};
typedef struct GETXATTRDIR3resok GETXATTRDIR3resok;

struct GETXATTRDIR3res {
	nfsstat3 status;
	union {
		GETXATTRDIR3resok ok;
	} res_u;
};
typedef struct GETXATTRDIR3res GETXATTRDIR3res;

#define	NFS_ACL_PROGRAM	((rpcprog_t)(100227))
#define	NFS_ACL_VERSMIN	((rpcvers_t)(2))
#define	NFS_ACL_VERSMAX	((rpcvers_t)(3))

#define	NFS_ACL_V2		((rpcvers_t)(2))
#define	ACLPROC2_NULL		((rpcproc_t)(0))
#define	ACLPROC2_GETACL		((rpcproc_t)(1))
#define	ACLPROC2_SETACL		((rpcproc_t)(2))
#define	ACLPROC2_GETATTR	((rpcproc_t)(3))
#define	ACLPROC2_ACCESS		((rpcproc_t)(4))
#define	ACLPROC2_GETXATTRDIR	((rpcproc_t)(5))

#define	NFS_ACL_V3		((rpcvers_t)(3))
#define	ACLPROC3_NULL		((rpcproc_t)(0))
#define	ACLPROC3_GETACL		((rpcproc_t)(1))
#define	ACLPROC3_SETACL		((rpcproc_t)(2))
#define	ACLPROC3_GETXATTRDIR	((rpcproc_t)(3))

#ifdef _KERNEL
/* the xdr functions */
extern bool_t xdr_uid(XDR *, uid32_t *);
extern bool_t xdr_o_mode(XDR *, o_mode *);
extern bool_t xdr_aclent(XDR *, aclent_t *);
extern bool_t xdr_secattr(XDR *, vsecattr_t *);

extern bool_t xdr_GETACL2args(XDR *, GETACL2args *);
extern bool_t xdr_fastGETACL2args(XDR *, GETACL2args **);
extern bool_t xdr_GETACL2resok(XDR *, GETACL2resok *);
extern bool_t xdr_GETACL2res(XDR *, GETACL2res *);
extern bool_t xdr_SETACL2args(XDR *, SETACL2args *);
extern bool_t xdr_SETACL2resok(XDR *, SETACL2resok *);
#ifdef _LITTLE_ENDIAN
extern bool_t xdr_fastSETACL2resok(XDR *, SETACL2resok *);
#endif
extern bool_t xdr_SETACL2res(XDR *, SETACL2res *);
#ifdef _LITTLE_ENDIAN
extern bool_t xdr_fastSETACL2res(XDR *, SETACL2res *);
#endif
extern bool_t xdr_GETATTR2args(XDR *, GETATTR2args *);
extern bool_t xdr_fastGETATTR2args(XDR *, GETATTR2args **);
extern bool_t xdr_GETATTR2resok(XDR *, GETATTR2resok *);
#ifdef _LITTLE_ENDIAN
extern bool_t xdr_fastGETATTR2resok(XDR *, GETATTR2resok *);
#endif
extern bool_t xdr_GETATTR2res(XDR *, GETATTR2res *);
#ifdef _LITTLE_ENDIAN
extern bool_t xdr_fastGETATTR2res(XDR *, GETATTR2res *);
#endif
extern bool_t xdr_ACCESS2args(XDR *, ACCESS2args *);
extern bool_t xdr_fastACCESS2args(XDR *, ACCESS2args **);
extern bool_t xdr_ACCESS2resok(XDR *, ACCESS2resok *);
#ifdef _LITTLE_ENDIAN
extern bool_t xdr_fastACCESS2resok(XDR *, ACCESS2resok *);
#endif
extern bool_t xdr_ACCESS2res(XDR *, ACCESS2res *);
#ifdef _LITTLE_ENDIAN
extern bool_t xdr_fastACCESS2res(XDR *, ACCESS2res *);
#endif
extern bool_t xdr_GETXATTRDIR2args(XDR *, GETXATTRDIR2args *);
extern bool_t xdr_GETXATTRDIR2res(XDR *, GETXATTRDIR2res *);

extern bool_t xdr_GETACL3args(XDR *, GETACL3args *);
extern bool_t xdr_GETACL3resok(XDR *, GETACL3resok *);
extern bool_t xdr_GETACL3resfail(XDR *, GETACL3resfail *);
extern bool_t xdr_GETACL3res(XDR *, GETACL3res *);
extern bool_t xdr_SETACL3args(XDR *, SETACL3args *);
extern bool_t xdr_SETACL3resok(XDR *, SETACL3resok *);
extern bool_t xdr_SETACL3resfail(XDR *, SETACL3resfail *);
extern bool_t xdr_SETACL3res(XDR *, SETACL3res *);
extern bool_t xdr_GETXATTRDIR3args(XDR *, GETXATTRDIR3args *);
extern bool_t xdr_GETXATTRDIR3res(XDR *, GETXATTRDIR3res *);

#endif

#ifdef _KERNEL
/* the service procedures */
extern void acl2_getacl(GETACL2args *, GETACL2res *,
    struct exportinfo *, struct svc_req *, cred_t *, bool_t);
extern void *acl2_getacl_getfh(GETACL2args *);
extern void acl2_getacl_free(GETACL2res *);
extern void acl2_setacl(SETACL2args *, SETACL2res *,
    struct exportinfo *, struct svc_req *, cred_t *, bool_t);
extern void *acl2_setacl_getfh(SETACL2args *);
extern void acl2_getattr(GETATTR2args *, GETATTR2res *,
    struct exportinfo *, struct svc_req *, cred_t *, bool_t);
extern void *acl2_getattr_getfh(GETATTR2args *);
extern void acl2_access(ACCESS2args *, ACCESS2res *,
    struct exportinfo *, struct svc_req *, cred_t *, bool_t);
extern void *acl2_access_getfh(ACCESS2args *);
extern void acl2_getxattrdir(GETXATTRDIR2args *, GETXATTRDIR2res *,
    struct exportinfo *, struct svc_req *, cred_t *, bool_t);
extern void *acl2_getxattrdir_getfh(GETXATTRDIR2args *);

extern void acl3_getacl(GETACL3args *, GETACL3res *,
    struct exportinfo *, struct svc_req *, cred_t *, bool_t);
extern void *acl3_getacl_getfh(GETACL3args *);
extern void acl3_getacl_free(GETACL3res *);
extern void acl3_setacl(SETACL3args *, SETACL3res *,
    struct exportinfo *, struct svc_req *, cred_t *, bool_t);
extern void *acl3_setacl_getfh(SETACL3args *);
extern void acl3_getxattrdir(GETXATTRDIR3args *, GETXATTRDIR3res *,
    struct exportinfo *, struct svc_req *, cred_t *, bool_t);
extern void *acl3_getxattrdir_getfh(GETXATTRDIR3args *);

#endif

#ifdef _KERNEL
/* the client side procedures */
extern int acl_getacl2(vnode_t *, vsecattr_t *, int, cred_t *);
extern int acl_setacl2(vnode_t *, vsecattr_t *, int, cred_t *);
extern int acl_getattr2_otw(vnode_t *, vattr_t *, cred_t *);
extern int acl_access2(vnode_t *, int, int, cred_t *);
extern int acl_getxattrdir2(vnode_t *, vnode_t **, bool_t, cred_t *, int);
extern int acl_getacl3(vnode_t *, vsecattr_t *, int, cred_t *);
extern int acl_setacl3(vnode_t *, vsecattr_t *, int, cred_t *);
extern int acl_getxattrdir3(vnode_t *, vnode_t **, bool_t, cred_t *, int);
extern int acl2call(mntinfo_t *, rpcproc_t, xdrproc_t, caddr_t, xdrproc_t,
			caddr_t, cred_t *, int *, enum nfsstat *, int,
			failinfo_t *);
extern int acl3call(mntinfo_t *, rpcproc_t, xdrproc_t, caddr_t, xdrproc_t,
			caddr_t, cred_t *, int *, nfsstat3 *, int,
			failinfo_t *);
extern void nfs_acl_free(vsecattr_t *);
#endif

#ifdef _KERNEL
/* server and client data structures */

extern char		*aclnames_v2[];
extern uchar_t		acl_call_type_v2[];
extern uchar_t		acl_ss_call_type_v2[];
extern uchar_t		acl_timer_type_v2[];

extern char		*aclnames_v3[];
extern uchar_t		acl_call_type_v3[];
extern uchar_t		acl_ss_call_type_v3[];
extern uchar_t		acl_timer_type_v3[];
#endif

#ifdef	__cplusplus
}
#endif

#endif	/* _NFS_NFS_ACL_H */