2 * Copyright (c) 1999, 2000, 2001, 2002 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 * acl_get_fd - syscall wrapper for retrieving access ACL by fd
30 * acl_get_fd_np - syscall wrapper for retrieving ACL by fd (non-POSIX)
31 * acl_get_file - syscall wrapper for retrieving ACL by filename
32 * acl_get_link_np - syscall wrapper for retrieving ACL by filename (NOFOLLOW)
34 * acl_get_perm_np() checks if a permission is in the specified
36 * acl_get_permset() returns the permission set in the ACL entry
37 * acl_get_qualifier() retrieves the qualifier of the tag from the ACL entry
38 * acl_get_tag_type() returns the tag type for the ACL entry entry_d
41 #include <sys/cdefs.h>
42 __FBSDID("$FreeBSD$");
44 #include <sys/types.h>
45 #include "namespace.h"
47 #include "un-namespace.h"
55 #include "acl_support.h"
58 acl_get_file(const char *path_p, acl_type_t type)
63 aclp = acl_init(ACL_MAX_ENTRIES);
67 type = _acl_type_unold(type);
68 error = __acl_get_file(path_p, type, &aclp->ats_acl);
74 aclp->ats_acl.acl_maxcnt = ACL_MAX_ENTRIES;
75 _acl_brand_from_type(aclp, type);
81 acl_get_link_np(const char *path_p, acl_type_t type)
86 aclp = acl_init(ACL_MAX_ENTRIES);
90 type = _acl_type_unold(type);
91 error = __acl_get_link(path_p, type, &aclp->ats_acl);
97 aclp->ats_acl.acl_maxcnt = ACL_MAX_ENTRIES;
98 _acl_brand_from_type(aclp, type);
106 if (fpathconf(fd, _PC_ACL_NFS4) == 1)
107 return (acl_get_fd_np(fd, ACL_TYPE_NFS4));
109 return (acl_get_fd_np(fd, ACL_TYPE_ACCESS));
113 acl_get_fd_np(int fd, acl_type_t type)
118 aclp = acl_init(ACL_MAX_ENTRIES);
122 type = _acl_type_unold(type);
123 error = ___acl_get_fd(fd, type, &aclp->ats_acl);
129 aclp->ats_acl.acl_maxcnt = ACL_MAX_ENTRIES;
130 _acl_brand_from_type(aclp, type);
136 * acl_get_permset() (23.4.17): return via permset_p a descriptor to
137 * the permission set in the ACL entry entry_d.
140 acl_get_permset(acl_entry_t entry_d, acl_permset_t *permset_p)
143 if (entry_d == NULL || permset_p == NULL) {
148 *permset_p = &entry_d->ae_perm;
154 * acl_get_qualifier() (23.4.18): retrieve the qualifier of the tag
155 * for the ACL entry entry_d.
158 acl_get_qualifier(acl_entry_t entry_d)
162 if (entry_d == NULL) {
167 switch(entry_d->ae_tag) {
170 retval = malloc(sizeof(uid_t));
173 *retval = entry_d->ae_id;
182 * acl_get_tag_type() (23.4.19): return the tag type for the ACL
186 acl_get_tag_type(acl_entry_t entry_d, acl_tag_t *tag_type_p)
189 if (entry_d == NULL || tag_type_p == NULL) {
194 *tag_type_p = entry_d->ae_tag;
200 acl_get_entry_type_np(acl_entry_t entry_d, acl_entry_type_t *entry_type_p)
203 if (entry_d == NULL || entry_type_p == NULL) {
208 if (!_entry_brand_may_be(entry_d, ACL_BRAND_NFS4)) {
213 *entry_type_p = entry_d->ae_entry_type;