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