vfs_acl.c (150262) | vfs_acl.c (160146) |
---|---|
1/*- | 1/*- |
2 * Copyright (c) 1999-2003 Robert N. M. Watson | 2 * Copyright (c) 1999-2006 Robert N. M. Watson |
3 * All rights reserved. 4 * 5 * This software was developed by Robert Watson for the TrustedBSD Project. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 1. Redistributions of source code must retain the above copyright --- 11 unchanged lines hidden (view full) --- 22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 * SUCH DAMAGE. 27 */ 28/* 29 * Developed by the TrustedBSD Project. | 3 * All rights reserved. 4 * 5 * This software was developed by Robert Watson for the TrustedBSD Project. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 1. Redistributions of source code must retain the above copyright --- 11 unchanged lines hidden (view full) --- 22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 * SUCH DAMAGE. 27 */ 28/* 29 * Developed by the TrustedBSD Project. |
30 * Support for POSIX.1e access control lists. | 30 * 31 * ACL system calls and other functions common across different ACL types. 32 * Type-specific routines go into subr_acl_<type>.c. |
31 */ 32 33#include <sys/cdefs.h> | 33 */ 34 35#include <sys/cdefs.h> |
34__FBSDID("$FreeBSD: head/sys/kern/vfs_acl.c 150262 2005-09-17 22:01:14Z csjp $"); | 36__FBSDID("$FreeBSD: head/sys/kern/vfs_acl.c 160146 2006-07-06 23:37:39Z rwatson $"); |
35 36#include "opt_mac.h" 37 38#include <sys/param.h> 39#include <sys/systm.h> 40#include <sys/sysproto.h> 41#include <sys/kernel.h> 42#include <sys/mac.h> 43#include <sys/malloc.h> 44#include <sys/mount.h> 45#include <sys/vnode.h> 46#include <sys/lock.h> 47#include <sys/mutex.h> 48#include <sys/namei.h> 49#include <sys/file.h> 50#include <sys/filedesc.h> 51#include <sys/proc.h> 52#include <sys/sysent.h> | 37 38#include "opt_mac.h" 39 40#include <sys/param.h> 41#include <sys/systm.h> 42#include <sys/sysproto.h> 43#include <sys/kernel.h> 44#include <sys/mac.h> 45#include <sys/malloc.h> 46#include <sys/mount.h> 47#include <sys/vnode.h> 48#include <sys/lock.h> 49#include <sys/mutex.h> 50#include <sys/namei.h> 51#include <sys/file.h> 52#include <sys/filedesc.h> 53#include <sys/proc.h> 54#include <sys/sysent.h> |
53#include <sys/errno.h> 54#include <sys/stat.h> | |
55#include <sys/acl.h> 56 57#include <vm/uma.h> 58 59uma_zone_t acl_zone; 60static int vacl_set_acl(struct thread *td, struct vnode *vp, 61 acl_type_t type, struct acl *aclp); 62static int vacl_get_acl(struct thread *td, struct vnode *vp, 63 acl_type_t type, struct acl *aclp); 64static int vacl_aclcheck(struct thread *td, struct vnode *vp, 65 acl_type_t type, struct acl *aclp); 66 67/* | 55#include <sys/acl.h> 56 57#include <vm/uma.h> 58 59uma_zone_t acl_zone; 60static int vacl_set_acl(struct thread *td, struct vnode *vp, 61 acl_type_t type, struct acl *aclp); 62static int vacl_get_acl(struct thread *td, struct vnode *vp, 63 acl_type_t type, struct acl *aclp); 64static int vacl_aclcheck(struct thread *td, struct vnode *vp, 65 acl_type_t type, struct acl *aclp); 66 67/* |
68 * Implement a version of vaccess() that understands POSIX.1e ACL semantics. 69 * Return 0 on success, else an errno value. Should be merged into 70 * vaccess() eventually. 71 */ 72int 73vaccess_acl_posix1e(enum vtype type, uid_t file_uid, gid_t file_gid, 74 struct acl *acl, mode_t acc_mode, struct ucred *cred, int *privused) 75{ 76 struct acl_entry *acl_other, *acl_mask; 77 mode_t dac_granted; 78 mode_t cap_granted; 79 mode_t acl_mask_granted; 80 int group_matched, i; 81 82 /* 83 * Look for a normal, non-privileged way to access the file/directory 84 * as requested. If it exists, go with that. Otherwise, attempt 85 * to use privileges granted via cap_granted. In some cases, 86 * which privileges to use may be ambiguous due to "best match", 87 * in which case fall back on first match for the time being. 88 */ 89 if (privused != NULL) 90 *privused = 0; 91 92 /* 93 * Determine privileges now, but don't apply until we've found 94 * a DAC entry that matches but has failed to allow access. 95 */ 96#ifndef CAPABILITIES 97 if (suser_cred(cred, SUSER_ALLOWJAIL) == 0) 98 cap_granted = VALLPERM; 99 else 100 cap_granted = 0; 101#else 102 cap_granted = 0; 103 104 if (type == VDIR) { 105 if ((acc_mode & VEXEC) && !cap_check(cred, NULL, 106 CAP_DAC_READ_SEARCH, SUSER_ALLOWJAIL)) 107 cap_granted |= VEXEC; 108 } else { 109 if ((acc_mode & VEXEC) && !cap_check(cred, NULL, 110 CAP_DAC_EXECUTE, SUSER_ALLOWJAIL)) 111 cap_granted |= VEXEC; 112 } 113 114 if ((acc_mode & VREAD) && !cap_check(cred, NULL, CAP_DAC_READ_SEARCH, 115 SUSER_ALLOWJAIL)) 116 cap_granted |= VREAD; 117 118 if (((acc_mode & VWRITE) || (acc_mode & VAPPEND)) && 119 !cap_check(cred, NULL, CAP_DAC_WRITE, SUSER_ALLOWJAIL)) 120 cap_granted |= (VWRITE | VAPPEND); 121 122 if ((acc_mode & VADMIN) && !cap_check(cred, NULL, CAP_FOWNER, 123 SUSER_ALLOWJAIL)) 124 cap_granted |= VADMIN; 125#endif /* CAPABILITIES */ 126 127 /* 128 * The owner matches if the effective uid associated with the 129 * credential matches that of the ACL_USER_OBJ entry. While we're 130 * doing the first scan, also cache the location of the ACL_MASK 131 * and ACL_OTHER entries, preventing some future iterations. 132 */ 133 acl_mask = acl_other = NULL; 134 for (i = 0; i < acl->acl_cnt; i++) { 135 switch (acl->acl_entry[i].ae_tag) { 136 case ACL_USER_OBJ: 137 if (file_uid != cred->cr_uid) 138 break; 139 dac_granted = 0; 140 dac_granted |= VADMIN; 141 if (acl->acl_entry[i].ae_perm & ACL_EXECUTE) 142 dac_granted |= VEXEC; 143 if (acl->acl_entry[i].ae_perm & ACL_READ) 144 dac_granted |= VREAD; 145 if (acl->acl_entry[i].ae_perm & ACL_WRITE) 146 dac_granted |= (VWRITE | VAPPEND); 147 if ((acc_mode & dac_granted) == acc_mode) 148 return (0); 149 if ((acc_mode & (dac_granted | cap_granted)) == 150 acc_mode) { 151 if (privused != NULL) 152 *privused = 1; 153 return (0); 154 } 155 goto error; 156 157 case ACL_MASK: 158 acl_mask = &acl->acl_entry[i]; 159 break; 160 161 case ACL_OTHER: 162 acl_other = &acl->acl_entry[i]; 163 break; 164 165 default: 166 break; 167 } 168 } 169 170 /* 171 * An ACL_OTHER entry should always exist in a valid access 172 * ACL. If it doesn't, then generate a serious failure. For now, 173 * this means a debugging message and EPERM, but in the future 174 * should probably be a panic. 175 */ 176 if (acl_other == NULL) { 177 /* 178 * XXX This should never happen 179 */ 180 printf("vaccess_acl_posix1e: ACL_OTHER missing\n"); 181 return (EPERM); 182 } 183 184 /* 185 * Checks against ACL_USER, ACL_GROUP_OBJ, and ACL_GROUP fields 186 * are masked by an ACL_MASK entry, if any. As such, first identify 187 * the ACL_MASK field, then iterate through identifying potential 188 * user matches, then group matches. If there is no ACL_MASK, 189 * assume that the mask allows all requests to succeed. 190 */ 191 if (acl_mask != NULL) { 192 acl_mask_granted = 0; 193 if (acl_mask->ae_perm & ACL_EXECUTE) 194 acl_mask_granted |= VEXEC; 195 if (acl_mask->ae_perm & ACL_READ) 196 acl_mask_granted |= VREAD; 197 if (acl_mask->ae_perm & ACL_WRITE) 198 acl_mask_granted |= (VWRITE | VAPPEND); 199 } else 200 acl_mask_granted = VEXEC | VREAD | VWRITE | VAPPEND; 201 202 /* 203 * Iterate through user ACL entries. Do checks twice, first 204 * without privilege, and then if a match is found but failed, 205 * a second time with privilege. 206 */ 207 208 /* 209 * Check ACL_USER ACL entries. 210 */ 211 for (i = 0; i < acl->acl_cnt; i++) { 212 switch (acl->acl_entry[i].ae_tag) { 213 case ACL_USER: 214 if (acl->acl_entry[i].ae_id != cred->cr_uid) 215 break; 216 dac_granted = 0; 217 if (acl->acl_entry[i].ae_perm & ACL_EXECUTE) 218 dac_granted |= VEXEC; 219 if (acl->acl_entry[i].ae_perm & ACL_READ) 220 dac_granted |= VREAD; 221 if (acl->acl_entry[i].ae_perm & ACL_WRITE) 222 dac_granted |= (VWRITE | VAPPEND); 223 dac_granted &= acl_mask_granted; 224 if ((acc_mode & dac_granted) == acc_mode) 225 return (0); 226 if ((acc_mode & (dac_granted | cap_granted)) != 227 acc_mode) 228 goto error; 229 230 if (privused != NULL) 231 *privused = 1; 232 return (0); 233 } 234 } 235 236 /* 237 * Group match is best-match, not first-match, so find a 238 * "best" match. Iterate across, testing each potential group 239 * match. Make sure we keep track of whether we found a match 240 * or not, so that we know if we should try again with any 241 * available privilege, or if we should move on to ACL_OTHER. 242 */ 243 group_matched = 0; 244 for (i = 0; i < acl->acl_cnt; i++) { 245 switch (acl->acl_entry[i].ae_tag) { 246 case ACL_GROUP_OBJ: 247 if (!groupmember(file_gid, cred)) 248 break; 249 dac_granted = 0; 250 if (acl->acl_entry[i].ae_perm & ACL_EXECUTE) 251 dac_granted |= VEXEC; 252 if (acl->acl_entry[i].ae_perm & ACL_READ) 253 dac_granted |= VREAD; 254 if (acl->acl_entry[i].ae_perm & ACL_WRITE) 255 dac_granted |= (VWRITE | VAPPEND); 256 dac_granted &= acl_mask_granted; 257 258 if ((acc_mode & dac_granted) == acc_mode) 259 return (0); 260 261 group_matched = 1; 262 break; 263 264 case ACL_GROUP: 265 if (!groupmember(acl->acl_entry[i].ae_id, cred)) 266 break; 267 dac_granted = 0; 268 if (acl->acl_entry[i].ae_perm & ACL_EXECUTE) 269 dac_granted |= VEXEC; 270 if (acl->acl_entry[i].ae_perm & ACL_READ) 271 dac_granted |= VREAD; 272 if (acl->acl_entry[i].ae_perm & ACL_WRITE) 273 dac_granted |= (VWRITE | VAPPEND); 274 dac_granted &= acl_mask_granted; 275 276 if ((acc_mode & dac_granted) == acc_mode) 277 return (0); 278 279 group_matched = 1; 280 break; 281 282 default: 283 break; 284 } 285 } 286 287 if (group_matched == 1) { 288 /* 289 * There was a match, but it did not grant rights via 290 * pure DAC. Try again, this time with privilege. 291 */ 292 for (i = 0; i < acl->acl_cnt; i++) { 293 switch (acl->acl_entry[i].ae_tag) { 294 case ACL_GROUP_OBJ: 295 if (!groupmember(file_gid, cred)) 296 break; 297 dac_granted = 0; 298 if (acl->acl_entry[i].ae_perm & ACL_EXECUTE) 299 dac_granted |= VEXEC; 300 if (acl->acl_entry[i].ae_perm & ACL_READ) 301 dac_granted |= VREAD; 302 if (acl->acl_entry[i].ae_perm & ACL_WRITE) 303 dac_granted |= (VWRITE | VAPPEND); 304 dac_granted &= acl_mask_granted; 305 306 if ((acc_mode & (dac_granted | cap_granted)) != 307 acc_mode) 308 break; 309 310 if (privused != NULL) 311 *privused = 1; 312 return (0); 313 314 case ACL_GROUP: 315 if (!groupmember(acl->acl_entry[i].ae_id, 316 cred)) 317 break; 318 dac_granted = 0; 319 if (acl->acl_entry[i].ae_perm & ACL_EXECUTE) 320 dac_granted |= VEXEC; 321 if (acl->acl_entry[i].ae_perm & ACL_READ) 322 dac_granted |= VREAD; 323 if (acl->acl_entry[i].ae_perm & ACL_WRITE) 324 dac_granted |= (VWRITE | VAPPEND); 325 dac_granted &= acl_mask_granted; 326 327 if ((acc_mode & (dac_granted | cap_granted)) != 328 acc_mode) 329 break; 330 331 if (privused != NULL) 332 *privused = 1; 333 return (0); 334 335 default: 336 break; 337 } 338 } 339 /* 340 * Even with privilege, group membership was not sufficient. 341 * Return failure. 342 */ 343 goto error; 344 } 345 346 /* 347 * Fall back on ACL_OTHER. ACL_MASK is not applied to ACL_OTHER. 348 */ 349 dac_granted = 0; 350 if (acl_other->ae_perm & ACL_EXECUTE) 351 dac_granted |= VEXEC; 352 if (acl_other->ae_perm & ACL_READ) 353 dac_granted |= VREAD; 354 if (acl_other->ae_perm & ACL_WRITE) 355 dac_granted |= (VWRITE | VAPPEND); 356 357 if ((acc_mode & dac_granted) == acc_mode) 358 return (0); 359 if ((acc_mode & (dac_granted | cap_granted)) == acc_mode) { 360 if (privused != NULL) 361 *privused = 1; 362 return (0); 363 } 364 365error: 366 return ((acc_mode & VADMIN) ? EPERM : EACCES); 367} 368 369/* 370 * For the purposes of filesystems maintaining the _OBJ entries in an 371 * inode with a mode_t field, this routine converts a mode_t entry 372 * to an acl_perm_t. 373 */ 374acl_perm_t 375acl_posix1e_mode_to_perm(acl_tag_t tag, mode_t mode) 376{ 377 acl_perm_t perm = 0; 378 379 switch(tag) { 380 case ACL_USER_OBJ: 381 if (mode & S_IXUSR) 382 perm |= ACL_EXECUTE; 383 if (mode & S_IRUSR) 384 perm |= ACL_READ; 385 if (mode & S_IWUSR) 386 perm |= ACL_WRITE; 387 return (perm); 388 389 case ACL_GROUP_OBJ: 390 if (mode & S_IXGRP) 391 perm |= ACL_EXECUTE; 392 if (mode & S_IRGRP) 393 perm |= ACL_READ; 394 if (mode & S_IWGRP) 395 perm |= ACL_WRITE; 396 return (perm); 397 398 case ACL_OTHER: 399 if (mode & S_IXOTH) 400 perm |= ACL_EXECUTE; 401 if (mode & S_IROTH) 402 perm |= ACL_READ; 403 if (mode & S_IWOTH) 404 perm |= ACL_WRITE; 405 return (perm); 406 407 default: 408 printf("acl_posix1e_mode_to_perm: invalid tag (%d)\n", tag); 409 return (0); 410 } 411} 412 413/* 414 * Given inode information (uid, gid, mode), return an acl entry of the 415 * appropriate type. 416 */ 417struct acl_entry 418acl_posix1e_mode_to_entry(acl_tag_t tag, uid_t uid, gid_t gid, mode_t mode) 419{ 420 struct acl_entry acl_entry; 421 422 acl_entry.ae_tag = tag; 423 acl_entry.ae_perm = acl_posix1e_mode_to_perm(tag, mode); 424 switch(tag) { 425 case ACL_USER_OBJ: 426 acl_entry.ae_id = uid; 427 break; 428 429 case ACL_GROUP_OBJ: 430 acl_entry.ae_id = gid; 431 break; 432 433 case ACL_OTHER: 434 acl_entry.ae_id = ACL_UNDEFINED_ID; 435 break; 436 437 default: 438 acl_entry.ae_id = ACL_UNDEFINED_ID; 439 printf("acl_posix1e_mode_to_entry: invalid tag (%d)\n", tag); 440 } 441 442 return (acl_entry); 443} 444 445/* 446 * Utility function to generate a file mode given appropriate ACL entries. 447 */ 448mode_t 449acl_posix1e_perms_to_mode(struct acl_entry *acl_user_obj_entry, 450 struct acl_entry *acl_group_obj_entry, struct acl_entry *acl_other_entry) 451{ 452 mode_t mode; 453 454 mode = 0; 455 if (acl_user_obj_entry->ae_perm & ACL_EXECUTE) 456 mode |= S_IXUSR; 457 if (acl_user_obj_entry->ae_perm & ACL_READ) 458 mode |= S_IRUSR; 459 if (acl_user_obj_entry->ae_perm & ACL_WRITE) 460 mode |= S_IWUSR; 461 if (acl_group_obj_entry->ae_perm & ACL_EXECUTE) 462 mode |= S_IXGRP; 463 if (acl_group_obj_entry->ae_perm & ACL_READ) 464 mode |= S_IRGRP; 465 if (acl_group_obj_entry->ae_perm & ACL_WRITE) 466 mode |= S_IWGRP; 467 if (acl_other_entry->ae_perm & ACL_EXECUTE) 468 mode |= S_IXOTH; 469 if (acl_other_entry->ae_perm & ACL_READ) 470 mode |= S_IROTH; 471 if (acl_other_entry->ae_perm & ACL_WRITE) 472 mode |= S_IWOTH; 473 474 return (mode); 475} 476 477/* 478 * Utility function to generate a file mode given a complete POSIX.1e 479 * access ACL. Note that if the ACL is improperly formed, this may 480 * result in a panic. 481 */ 482mode_t 483acl_posix1e_acl_to_mode(struct acl *acl) 484{ 485 struct acl_entry *acl_mask, *acl_user_obj, *acl_group_obj, *acl_other; 486 int i; 487 488 /* 489 * Find the ACL entries relevant to a POSIX permission mode. 490 */ 491 acl_user_obj = acl_group_obj = acl_other = acl_mask = NULL; 492 for (i = 0; i < acl->acl_cnt; i++) { 493 switch (acl->acl_entry[i].ae_tag) { 494 case ACL_USER_OBJ: 495 acl_user_obj = &acl->acl_entry[i]; 496 break; 497 498 case ACL_GROUP_OBJ: 499 acl_group_obj = &acl->acl_entry[i]; 500 break; 501 502 case ACL_OTHER: 503 acl_other = &acl->acl_entry[i]; 504 break; 505 506 case ACL_MASK: 507 acl_mask = &acl->acl_entry[i]; 508 break; 509 510 case ACL_USER: 511 case ACL_GROUP: 512 break; 513 514 default: 515 panic("acl_posix1e_acl_to_mode: bad ae_tag"); 516 } 517 } 518 519 if (acl_user_obj == NULL || acl_group_obj == NULL || acl_other == NULL) 520 panic("acl_posix1e_acl_to_mode: missing base ae_tags"); 521 522 /* 523 * POSIX.1e specifies that if there is an ACL_MASK entry, we replace 524 * the mode "group" bits with its permissions. If there isn't, we 525 * use the ACL_GROUP_OBJ permissions. 526 */ 527 if (acl_mask != NULL) 528 return (acl_posix1e_perms_to_mode(acl_user_obj, acl_mask, 529 acl_other)); 530 else 531 return (acl_posix1e_perms_to_mode(acl_user_obj, acl_group_obj, 532 acl_other)); 533} 534 535/* 536 * Perform a syntactic check of the ACL, sufficient to allow an 537 * implementing filesystem to determine if it should accept this and 538 * rely on the POSIX.1e ACL properties. 539 */ 540int 541acl_posix1e_check(struct acl *acl) 542{ 543 int num_acl_user_obj, num_acl_user, num_acl_group_obj, num_acl_group; 544 int num_acl_mask, num_acl_other, i; 545 546 /* 547 * Verify that the number of entries does not exceed the maximum 548 * defined for acl_t. 549 * Verify that the correct number of various sorts of ae_tags are 550 * present: 551 * Exactly one ACL_USER_OBJ 552 * Exactly one ACL_GROUP_OBJ 553 * Exactly one ACL_OTHER 554 * If any ACL_USER or ACL_GROUP entries appear, then exactly one 555 * ACL_MASK entry must also appear. 556 * Verify that all ae_perm entries are in ACL_PERM_BITS. 557 * Verify all ae_tag entries are understood by this implementation. 558 * Note: Does not check for uniqueness of qualifier (ae_id) field. 559 */ 560 num_acl_user_obj = num_acl_user = num_acl_group_obj = num_acl_group = 561 num_acl_mask = num_acl_other = 0; 562 if (acl->acl_cnt > ACL_MAX_ENTRIES || acl->acl_cnt < 0) 563 return (EINVAL); 564 for (i = 0; i < acl->acl_cnt; i++) { 565 /* 566 * Check for a valid tag. 567 */ 568 switch(acl->acl_entry[i].ae_tag) { 569 case ACL_USER_OBJ: 570 acl->acl_entry[i].ae_id = ACL_UNDEFINED_ID; /* XXX */ 571 if (acl->acl_entry[i].ae_id != ACL_UNDEFINED_ID) 572 return (EINVAL); 573 num_acl_user_obj++; 574 break; 575 case ACL_GROUP_OBJ: 576 acl->acl_entry[i].ae_id = ACL_UNDEFINED_ID; /* XXX */ 577 if (acl->acl_entry[i].ae_id != ACL_UNDEFINED_ID) 578 return (EINVAL); 579 num_acl_group_obj++; 580 break; 581 case ACL_USER: 582 if (acl->acl_entry[i].ae_id == ACL_UNDEFINED_ID) 583 return (EINVAL); 584 num_acl_user++; 585 break; 586 case ACL_GROUP: 587 if (acl->acl_entry[i].ae_id == ACL_UNDEFINED_ID) 588 return (EINVAL); 589 num_acl_group++; 590 break; 591 case ACL_OTHER: 592 acl->acl_entry[i].ae_id = ACL_UNDEFINED_ID; /* XXX */ 593 if (acl->acl_entry[i].ae_id != ACL_UNDEFINED_ID) 594 return (EINVAL); 595 num_acl_other++; 596 break; 597 case ACL_MASK: 598 acl->acl_entry[i].ae_id = ACL_UNDEFINED_ID; /* XXX */ 599 if (acl->acl_entry[i].ae_id != ACL_UNDEFINED_ID) 600 return (EINVAL); 601 num_acl_mask++; 602 break; 603 default: 604 return (EINVAL); 605 } 606 /* 607 * Check for valid perm entries. 608 */ 609 if ((acl->acl_entry[i].ae_perm | ACL_PERM_BITS) != 610 ACL_PERM_BITS) 611 return (EINVAL); 612 } 613 if ((num_acl_user_obj != 1) || (num_acl_group_obj != 1) || 614 (num_acl_other != 1) || (num_acl_mask != 0 && num_acl_mask != 1)) 615 return (EINVAL); 616 if (((num_acl_group != 0) || (num_acl_user != 0)) && 617 (num_acl_mask != 1)) 618 return (EINVAL); 619 return (0); 620} 621 622/* 623 * Given a requested mode for a new object, and a default ACL, combine 624 * the two to produce a new mode. Be careful not to clear any bits that 625 * aren't intended to be affected by the POSIX.1e ACL. Eventually, 626 * this might also take the cmask as an argument, if we push that down 627 * into per-filesystem-code. 628 */ 629mode_t 630acl_posix1e_newfilemode(mode_t cmode, struct acl *dacl) 631{ 632 mode_t mode; 633 634 mode = cmode; 635 /* 636 * The current composition policy is that a permission bit must 637 * be set in *both* the ACL and the requested creation mode for 638 * it to appear in the resulting mode/ACL. First clear any 639 * possibly effected bits, then reconstruct. 640 */ 641 mode &= ACL_PRESERVE_MASK; 642 mode |= (ACL_OVERRIDE_MASK & cmode & acl_posix1e_acl_to_mode(dacl)); 643 644 return (mode); 645} 646 647/* | |
648 * These calls wrap the real vnode operations, and are called by the 649 * syscall code once the syscall has converted the path or file 650 * descriptor to a vnode (unlocked). The aclp pointer is assumed 651 * still to point to userland, so this should not be consumed within 652 * the kernel except by syscall code. Other code should directly 653 * invoke VOP_{SET,GET}ACL. 654 */ 655 --- 381 unchanged lines hidden --- | 68 * These calls wrap the real vnode operations, and are called by the 69 * syscall code once the syscall has converted the path or file 70 * descriptor to a vnode (unlocked). The aclp pointer is assumed 71 * still to point to userland, so this should not be consumed within 72 * the kernel except by syscall code. Other code should directly 73 * invoke VOP_{SET,GET}ACL. 74 */ 75 --- 381 unchanged lines hidden --- |