2 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
4 * Copyright (c) 2001-2002 Chris D. Faulhaber
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 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 #include <sys/cdefs.h>
30 __FBSDID("$FreeBSD$");
32 #include <sys/types.h>
33 #include "namespace.h"
35 #include "un-namespace.h"
41 _perm_is_invalid(acl_perm_t perm)
44 /* Check if more than a single bit is set. */
45 if ((perm & -perm) == perm &&
46 (perm & (ACL_POSIX1E_BITS | ACL_NFS4_PERM_BITS)) == perm)
55 * acl_add_perm() (23.4.1): add the permission contained in perm to the
56 * permission set permset_d
59 acl_add_perm(acl_permset_t permset_d, acl_perm_t perm)
62 if (permset_d == NULL) {
67 if (_perm_is_invalid(perm))
76 * acl_clear_perms() (23.4.3): clear all permisions from the permission
80 acl_clear_perms(acl_permset_t permset_d)
83 if (permset_d == NULL) {
88 *permset_d = ACL_PERM_NONE;
94 * acl_delete_perm() (23.4.10): remove the permission in perm from the
95 * permission set permset_d
98 acl_delete_perm(acl_permset_t permset_d, acl_perm_t perm)
101 if (permset_d == NULL) {
106 if (_perm_is_invalid(perm))
115 acl_get_perm_np(acl_permset_t permset_d, acl_perm_t perm)
118 if (permset_d == NULL) {
123 if (_perm_is_invalid(perm))
126 if (*permset_d & perm)