2 * Copyright (c) 1999-2003 Robert N. M. Watson
5 * This software was developed by Robert Watson for the TrustedBSD Project.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
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
29 * Developed by the TrustedBSD Project.
30 * Support for POSIX.1e access control lists.
33 #include <sys/cdefs.h>
34 __FBSDID("$FreeBSD$");
38 #include <sys/param.h>
39 #include <sys/systm.h>
40 #include <sys/sysproto.h>
41 #include <sys/kernel.h>
43 #include <sys/malloc.h>
44 #include <sys/mount.h>
45 #include <sys/vnode.h>
47 #include <sys/mutex.h>
48 #include <sys/namei.h>
50 #include <sys/filedesc.h>
52 #include <sys/sysent.h>
53 #include <sys/errno.h>
60 static int vacl_set_acl(struct thread *td, struct vnode *vp,
61 acl_type_t type, struct acl *aclp);
62 static int vacl_get_acl(struct thread *td, struct vnode *vp,
63 acl_type_t type, struct acl *aclp);
64 static int vacl_aclcheck(struct thread *td, struct vnode *vp,
65 acl_type_t type, struct acl *aclp);
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.
73 vaccess_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)
76 struct acl_entry *acl_other, *acl_mask;
79 mode_t acl_mask_granted;
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.
93 * Determine privileges now, but don't apply until we've found
94 * a DAC entry that matches but has failed to allow access.
97 if (suser_cred(cred, SUSER_ALLOWJAIL) == 0)
98 cap_granted = VALLPERM;
105 if ((acc_mode & VEXEC) && !cap_check(cred, NULL,
106 CAP_DAC_READ_SEARCH, SUSER_ALLOWJAIL))
107 cap_granted |= VEXEC;
109 if ((acc_mode & VEXEC) && !cap_check(cred, NULL,
110 CAP_DAC_EXECUTE, SUSER_ALLOWJAIL))
111 cap_granted |= VEXEC;
114 if ((acc_mode & VREAD) && !cap_check(cred, NULL, CAP_DAC_READ_SEARCH,
116 cap_granted |= VREAD;
118 if (((acc_mode & VWRITE) || (acc_mode & VAPPEND)) &&
119 !cap_check(cred, NULL, CAP_DAC_WRITE, SUSER_ALLOWJAIL))
120 cap_granted |= (VWRITE | VAPPEND);
122 if ((acc_mode & VADMIN) && !cap_check(cred, NULL, CAP_FOWNER,
124 cap_granted |= VADMIN;
125 #endif /* CAPABILITIES */
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.
133 acl_mask = acl_other = NULL;
134 for (i = 0; i < acl->acl_cnt; i++) {
135 switch (acl->acl_entry[i].ae_tag) {
137 if (file_uid != cred->cr_uid)
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)
149 if ((acc_mode & (dac_granted | cap_granted)) ==
151 if (privused != NULL)
158 acl_mask = &acl->acl_entry[i];
162 acl_other = &acl->acl_entry[i];
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.
176 if (acl_other == NULL) {
178 * XXX This should never happen
180 printf("vaccess_acl_posix1e: ACL_OTHER missing\n");
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.
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);
200 acl_mask_granted = VEXEC | VREAD | VWRITE | VAPPEND;
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.
209 * Check ACL_USER ACL entries.
211 for (i = 0; i < acl->acl_cnt; i++) {
212 switch (acl->acl_entry[i].ae_tag) {
214 if (acl->acl_entry[i].ae_id != cred->cr_uid)
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)
226 if ((acc_mode & (dac_granted | cap_granted)) !=
230 if (privused != NULL)
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.
244 for (i = 0; i < acl->acl_cnt; i++) {
245 switch (acl->acl_entry[i].ae_tag) {
247 if (!groupmember(file_gid, cred))
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;
258 if ((acc_mode & dac_granted) == acc_mode)
265 if (!groupmember(acl->acl_entry[i].ae_id, cred))
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;
276 if ((acc_mode & dac_granted) == acc_mode)
287 if (group_matched == 1) {
289 * There was a match, but it did not grant rights via
290 * pure DAC. Try again, this time with privilege.
292 for (i = 0; i < acl->acl_cnt; i++) {
293 switch (acl->acl_entry[i].ae_tag) {
295 if (!groupmember(file_gid, cred))
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;
306 if ((acc_mode & (dac_granted | cap_granted)) !=
310 if (privused != NULL)
315 if (!groupmember(acl->acl_entry[i].ae_id,
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;
327 if ((acc_mode & (dac_granted | cap_granted)) !=
331 if (privused != NULL)
340 * Even with privilege, group membership was not sufficient.
347 * Fall back on ACL_OTHER. ACL_MASK is not applied to ACL_OTHER.
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);
357 if ((acc_mode & dac_granted) == acc_mode)
359 if ((acc_mode & (dac_granted | cap_granted)) == acc_mode) {
360 if (privused != NULL)
366 return ((acc_mode & VADMIN) ? EPERM : EACCES);
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
375 acl_posix1e_mode_to_perm(acl_tag_t tag, mode_t mode)
408 printf("acl_posix1e_mode_to_perm: invalid tag (%d)\n", tag);
414 * Given inode information (uid, gid, mode), return an acl entry of the
418 acl_posix1e_mode_to_entry(acl_tag_t tag, uid_t uid, gid_t gid, mode_t mode)
420 struct acl_entry acl_entry;
422 acl_entry.ae_tag = tag;
423 acl_entry.ae_perm = acl_posix1e_mode_to_perm(tag, mode);
426 acl_entry.ae_id = uid;
430 acl_entry.ae_id = gid;
434 acl_entry.ae_id = ACL_UNDEFINED_ID;
438 acl_entry.ae_id = ACL_UNDEFINED_ID;
439 printf("acl_posix1e_mode_to_entry: invalid tag (%d)\n", tag);
446 * Utility function to generate a file mode given appropriate ACL entries.
449 acl_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)
455 if (acl_user_obj_entry->ae_perm & ACL_EXECUTE)
457 if (acl_user_obj_entry->ae_perm & ACL_READ)
459 if (acl_user_obj_entry->ae_perm & ACL_WRITE)
461 if (acl_group_obj_entry->ae_perm & ACL_EXECUTE)
463 if (acl_group_obj_entry->ae_perm & ACL_READ)
465 if (acl_group_obj_entry->ae_perm & ACL_WRITE)
467 if (acl_other_entry->ae_perm & ACL_EXECUTE)
469 if (acl_other_entry->ae_perm & ACL_READ)
471 if (acl_other_entry->ae_perm & ACL_WRITE)
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
483 acl_posix1e_acl_to_mode(struct acl *acl)
485 struct acl_entry *acl_mask, *acl_user_obj, *acl_group_obj, *acl_other;
489 * Find the ACL entries relevant to a POSIX permission mode.
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) {
495 acl_user_obj = &acl->acl_entry[i];
499 acl_group_obj = &acl->acl_entry[i];
503 acl_other = &acl->acl_entry[i];
507 acl_mask = &acl->acl_entry[i];
515 panic("acl_posix1e_acl_to_mode: bad ae_tag");
519 if (acl_user_obj == NULL || acl_group_obj == NULL || acl_other == NULL)
520 panic("acl_posix1e_acl_to_mode: missing base ae_tags");
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.
527 if (acl_mask != NULL)
528 return (acl_posix1e_perms_to_mode(acl_user_obj, acl_mask,
531 return (acl_posix1e_perms_to_mode(acl_user_obj, acl_group_obj,
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.
541 acl_posix1e_check(struct acl *acl)
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;
547 * Verify that the number of entries does not exceed the maximum
549 * Verify that the correct number of various sorts of ae_tags are
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.
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)
564 for (i = 0; i < acl->acl_cnt; i++) {
566 * Check for a valid tag.
568 switch(acl->acl_entry[i].ae_tag) {
570 acl->acl_entry[i].ae_id = ACL_UNDEFINED_ID; /* XXX */
571 if (acl->acl_entry[i].ae_id != ACL_UNDEFINED_ID)
576 acl->acl_entry[i].ae_id = ACL_UNDEFINED_ID; /* XXX */
577 if (acl->acl_entry[i].ae_id != ACL_UNDEFINED_ID)
582 if (acl->acl_entry[i].ae_id == ACL_UNDEFINED_ID)
587 if (acl->acl_entry[i].ae_id == ACL_UNDEFINED_ID)
592 acl->acl_entry[i].ae_id = ACL_UNDEFINED_ID; /* XXX */
593 if (acl->acl_entry[i].ae_id != ACL_UNDEFINED_ID)
598 acl->acl_entry[i].ae_id = ACL_UNDEFINED_ID; /* XXX */
599 if (acl->acl_entry[i].ae_id != ACL_UNDEFINED_ID)
607 * Check for valid perm entries.
609 if ((acl->acl_entry[i].ae_perm | ACL_PERM_BITS) !=
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))
616 if (((num_acl_group != 0) || (num_acl_user != 0)) &&
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.
630 acl_posix1e_newfilemode(mode_t cmode, struct acl *dacl)
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.
641 mode &= ACL_PRESERVE_MASK;
642 mode |= (ACL_OVERRIDE_MASK & cmode & acl_posix1e_acl_to_mode(dacl));
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.
657 * Given a vnode, set its ACL.
660 vacl_set_acl(struct thread *td, struct vnode *vp, acl_type_t type,
663 struct acl inkernacl;
667 error = copyin(aclp, &inkernacl, sizeof(struct acl));
670 error = vn_start_write(vp, &mp, V_WAIT | PCATCH);
673 VOP_LEASE(vp, td, td->td_ucred, LEASE_WRITE);
674 vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td);
676 error = mac_check_vnode_setacl(td->td_ucred, vp, type, &inkernacl);
680 error = VOP_SETACL(vp, type, &inkernacl, td->td_ucred, td);
684 VOP_UNLOCK(vp, 0, td);
685 vn_finished_write(mp);
690 * Given a vnode, get its ACL.
693 vacl_get_acl(struct thread *td, struct vnode *vp, acl_type_t type,
696 struct acl inkernelacl;
699 VOP_LEASE(vp, td, td->td_ucred, LEASE_WRITE);
700 vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td);
702 error = mac_check_vnode_getacl(td->td_ucred, vp, type);
706 error = VOP_GETACL(vp, type, &inkernelacl, td->td_ucred, td);
710 VOP_UNLOCK(vp, 0, td);
712 error = copyout(&inkernelacl, aclp, sizeof(struct acl));
717 * Given a vnode, delete its ACL.
720 vacl_delete(struct thread *td, struct vnode *vp, acl_type_t type)
725 error = vn_start_write(vp, &mp, V_WAIT | PCATCH);
728 VOP_LEASE(vp, td, td->td_ucred, LEASE_WRITE);
729 vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td);
731 error = mac_check_vnode_deleteacl(td->td_ucred, vp, type);
735 error = VOP_SETACL(vp, type, 0, td->td_ucred, td);
739 VOP_UNLOCK(vp, 0, td);
740 vn_finished_write(mp);
745 * Given a vnode, check whether an ACL is appropriate for it
748 vacl_aclcheck(struct thread *td, struct vnode *vp, acl_type_t type,
751 struct acl inkernelacl;
754 error = copyin(aclp, &inkernelacl, sizeof(struct acl));
757 error = VOP_ACLCHECK(vp, type, &inkernelacl, td->td_ucred, td);
762 * syscalls -- convert the path/fd to a vnode, and call vacl_whatever.
763 * Don't need to lock, as the vacl_ code will get/release any locks
768 * Given a file path, get an ACL for it
773 __acl_get_file(struct thread *td, struct __acl_get_file_args *uap)
776 int vfslocked, error;
778 NDINIT(&nd, LOOKUP, MPSAFE|FOLLOW, UIO_USERSPACE, uap->path, td);
780 vfslocked = NDHASGIANT(&nd);
782 error = vacl_get_acl(td, nd.ni_vp, uap->type, uap->aclp);
785 VFS_UNLOCK_GIANT(vfslocked);
790 * Given a file path, get an ACL for it; don't follow links.
795 __acl_get_link(struct thread *td, struct __acl_get_link_args *uap)
798 int vfslocked, error;
800 NDINIT(&nd, LOOKUP, MPSAFE|NOFOLLOW, UIO_USERSPACE, uap->path, td);
802 vfslocked = NDHASGIANT(&nd);
804 error = vacl_get_acl(td, nd.ni_vp, uap->type, uap->aclp);
807 VFS_UNLOCK_GIANT(vfslocked);
812 * Given a file path, set an ACL for it
817 __acl_set_file(struct thread *td, struct __acl_set_file_args *uap)
820 int vfslocked, error;
822 NDINIT(&nd, LOOKUP, MPSAFE|FOLLOW, UIO_USERSPACE, uap->path, td);
824 vfslocked = NDHASGIANT(&nd);
826 error = vacl_set_acl(td, nd.ni_vp, uap->type, uap->aclp);
829 VFS_UNLOCK_GIANT(vfslocked);
834 * Given a file path, set an ACL for it; don't follow links.
839 __acl_set_link(struct thread *td, struct __acl_set_link_args *uap)
842 int vfslocked, error;
844 NDINIT(&nd, LOOKUP, MPSAFE|NOFOLLOW, UIO_USERSPACE, uap->path, td);
846 vfslocked = NDHASGIANT(&nd);
848 error = vacl_set_acl(td, nd.ni_vp, uap->type, uap->aclp);
851 VFS_UNLOCK_GIANT(vfslocked);
856 * Given a file descriptor, get an ACL for it
861 __acl_get_fd(struct thread *td, struct __acl_get_fd_args *uap)
864 int vfslocked, error;
866 error = getvnode(td->td_proc->p_fd, uap->filedes, &fp);
868 vfslocked = VFS_LOCK_GIANT(fp->f_vnode->v_mount);
869 error = vacl_get_acl(td, fp->f_vnode, uap->type, uap->aclp);
871 VFS_UNLOCK_GIANT(vfslocked);
877 * Given a file descriptor, set an ACL for it
882 __acl_set_fd(struct thread *td, struct __acl_set_fd_args *uap)
885 int vfslocked, error;
887 error = getvnode(td->td_proc->p_fd, uap->filedes, &fp);
889 vfslocked = VFS_LOCK_GIANT(fp->f_vnode->v_mount);
890 error = vacl_set_acl(td, fp->f_vnode, uap->type, uap->aclp);
892 VFS_UNLOCK_GIANT(vfslocked);
898 * Given a file path, delete an ACL from it.
903 __acl_delete_file(struct thread *td, struct __acl_delete_file_args *uap)
906 int vfslocked, error;
908 NDINIT(&nd, LOOKUP, MPSAFE|FOLLOW, UIO_USERSPACE, uap->path, td);
910 vfslocked = NDHASGIANT(&nd);
912 error = vacl_delete(td, nd.ni_vp, uap->type);
915 VFS_UNLOCK_GIANT(vfslocked);
920 * Given a file path, delete an ACL from it; don't follow links.
925 __acl_delete_link(struct thread *td, struct __acl_delete_link_args *uap)
928 int vfslocked, error;
930 NDINIT(&nd, LOOKUP, MPSAFE|NOFOLLOW, UIO_USERSPACE, uap->path, td);
932 vfslocked = NDHASGIANT(&nd);
934 error = vacl_delete(td, nd.ni_vp, uap->type);
937 VFS_UNLOCK_GIANT(vfslocked);
942 * Given a file path, delete an ACL from it.
947 __acl_delete_fd(struct thread *td, struct __acl_delete_fd_args *uap)
950 int vfslocked, error;
952 error = getvnode(td->td_proc->p_fd, uap->filedes, &fp);
954 vfslocked = VFS_LOCK_GIANT(fp->f_vnode->v_mount);
955 error = vacl_delete(td, fp->f_vnode, uap->type);
957 VFS_UNLOCK_GIANT(vfslocked);
963 * Given a file path, check an ACL for it
968 __acl_aclcheck_file(struct thread *td, struct __acl_aclcheck_file_args *uap)
971 int vfslocked, error;
973 NDINIT(&nd, LOOKUP, MPSAFE|FOLLOW, UIO_USERSPACE, uap->path, td);
975 vfslocked = NDHASGIANT(&nd);
977 error = vacl_aclcheck(td, nd.ni_vp, uap->type, uap->aclp);
980 VFS_UNLOCK_GIANT(vfslocked);
985 * Given a file path, check an ACL for it; don't follow links.
990 __acl_aclcheck_link(struct thread *td, struct __acl_aclcheck_link_args *uap)
993 int vfslocked, error;
995 NDINIT(&nd, LOOKUP, MPSAFE|NOFOLLOW, UIO_USERSPACE, uap->path, td);
997 vfslocked = NDHASGIANT(&nd);
999 error = vacl_aclcheck(td, nd.ni_vp, uap->type, uap->aclp);
1002 VFS_UNLOCK_GIANT(vfslocked);
1007 * Given a file descriptor, check an ACL for it
1012 __acl_aclcheck_fd(struct thread *td, struct __acl_aclcheck_fd_args *uap)
1015 int vfslocked, error;
1017 error = getvnode(td->td_proc->p_fd, uap->filedes, &fp);
1019 vfslocked = VFS_LOCK_GIANT(fp->f_vnode->v_mount);
1020 error = vacl_aclcheck(td, fp->f_vnode, uap->type, uap->aclp);
1022 VFS_UNLOCK_GIANT(vfslocked);
1030 aclinit(void *dummy __unused)
1033 acl_zone = uma_zcreate("ACL UMA zone", sizeof(struct acl),
1034 NULL, NULL, NULL, NULL, UMA_ALIGN_PTR, 0);
1036 SYSINIT(acls, SI_SUB_ACL, SI_ORDER_FIRST, aclinit, NULL)