2 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
4 * Copyright (c) 1999, 2000, 2001, 2002 Robert N. M. Watson
7 * This software was developed by Robert Watson for the TrustedBSD Project.
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
19 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
22 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * acl_get_fd - syscall wrapper for retrieving access ACL by fd
32 * acl_get_fd_np - syscall wrapper for retrieving ACL by fd (non-POSIX)
33 * acl_get_file - syscall wrapper for retrieving ACL by filename
34 * acl_get_link_np - syscall wrapper for retrieving ACL by filename (NOFOLLOW)
36 * acl_get_perm_np() checks if a permission is in the specified
38 * acl_get_permset() returns the permission set in the ACL entry
39 * acl_get_qualifier() retrieves the qualifier of the tag from the ACL entry
40 * acl_get_tag_type() returns the tag type for the ACL entry entry_d
43 #include <sys/cdefs.h>
44 __FBSDID("$FreeBSD$");
46 #include <sys/types.h>
47 #include "namespace.h"
49 #include "un-namespace.h"
57 #include "acl_support.h"
60 acl_get_file(const char *path_p, acl_type_t type)
65 aclp = acl_init(ACL_MAX_ENTRIES);
69 type = _acl_type_unold(type);
70 error = __acl_get_file(path_p, type, &aclp->ats_acl);
76 aclp->ats_acl.acl_maxcnt = ACL_MAX_ENTRIES;
77 _acl_brand_from_type(aclp, type);
83 acl_get_link_np(const char *path_p, acl_type_t type)
88 aclp = acl_init(ACL_MAX_ENTRIES);
92 type = _acl_type_unold(type);
93 error = __acl_get_link(path_p, type, &aclp->ats_acl);
99 aclp->ats_acl.acl_maxcnt = ACL_MAX_ENTRIES;
100 _acl_brand_from_type(aclp, type);
108 if (fpathconf(fd, _PC_ACL_NFS4) == 1)
109 return (acl_get_fd_np(fd, ACL_TYPE_NFS4));
111 return (acl_get_fd_np(fd, ACL_TYPE_ACCESS));
115 acl_get_fd_np(int fd, acl_type_t type)
120 aclp = acl_init(ACL_MAX_ENTRIES);
124 type = _acl_type_unold(type);
125 error = ___acl_get_fd(fd, type, &aclp->ats_acl);
131 aclp->ats_acl.acl_maxcnt = ACL_MAX_ENTRIES;
132 _acl_brand_from_type(aclp, type);
138 * acl_get_permset() (23.4.17): return via permset_p a descriptor to
139 * the permission set in the ACL entry entry_d.
142 acl_get_permset(acl_entry_t entry_d, acl_permset_t *permset_p)
145 if (entry_d == NULL || permset_p == NULL) {
150 *permset_p = &entry_d->ae_perm;
156 * acl_get_qualifier() (23.4.18): retrieve the qualifier of the tag
157 * for the ACL entry entry_d.
160 acl_get_qualifier(acl_entry_t entry_d)
164 if (entry_d == NULL) {
169 switch(entry_d->ae_tag) {
172 retval = malloc(sizeof(uid_t));
175 *retval = entry_d->ae_id;
184 * acl_get_tag_type() (23.4.19): return the tag type for the ACL
188 acl_get_tag_type(acl_entry_t entry_d, acl_tag_t *tag_type_p)
191 if (entry_d == NULL || tag_type_p == NULL) {
196 *tag_type_p = entry_d->ae_tag;
202 acl_get_entry_type_np(acl_entry_t entry_d, acl_entry_type_t *entry_type_p)
205 if (entry_d == NULL || entry_type_p == NULL) {
210 if (!_entry_brand_may_be(entry_d, ACL_BRAND_NFS4)) {
215 *entry_type_p = entry_d->ae_entry_type;