xref: /freebsd/lib/libc/posix1e/acl_cmp_np.c (revision 4d846d260e2b9a3d4d0a701462568268cbfe7a5b)
1937f807aSGleb Popov /*-
2*4d846d26SWarner Losh  * SPDX-License-Identifier: BSD-2-Clause
3937f807aSGleb Popov  *
4937f807aSGleb Popov  * Copyright (c) 2021 Gleb Popov
5937f807aSGleb Popov  * All rights reserved.
6937f807aSGleb Popov  *
7937f807aSGleb Popov  * Redistribution and use in source and binary forms, with or without
8937f807aSGleb Popov  * modification, are permitted provided that the following conditions
9937f807aSGleb Popov  * are met:
10937f807aSGleb Popov  * 1. Redistributions of source code must retain the above copyright
11937f807aSGleb Popov  *    notice, this list of conditions and the following disclaimer.
12937f807aSGleb Popov  * 2. Redistributions in binary form must reproduce the above copyright
13937f807aSGleb Popov  *    notice, this list of conditions and the following disclaimer in the
14937f807aSGleb Popov  *    documentation and/or other materials provided with the distribution.
15937f807aSGleb Popov  *
16937f807aSGleb Popov  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17937f807aSGleb Popov  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18937f807aSGleb Popov  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19937f807aSGleb Popov  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20937f807aSGleb Popov  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21937f807aSGleb Popov  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22937f807aSGleb Popov  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23937f807aSGleb Popov  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24937f807aSGleb Popov  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25937f807aSGleb Popov  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26937f807aSGleb Popov  * SUCH DAMAGE.
27937f807aSGleb Popov  */
28937f807aSGleb Popov /*
29937f807aSGleb Popov  * acl_cmp_np: Compare two ACL's.
30937f807aSGleb Popov  */
31937f807aSGleb Popov 
32937f807aSGleb Popov #include <sys/cdefs.h>
33937f807aSGleb Popov __FBSDID("$FreeBSD$");
34937f807aSGleb Popov 
35937f807aSGleb Popov #include <sys/acl.h>
36937f807aSGleb Popov #include <sys/errno.h>
37937f807aSGleb Popov 
38937f807aSGleb Popov #include "acl_support.h"
39937f807aSGleb Popov 
40937f807aSGleb Popov /*
41937f807aSGleb Popov  * returns 0 if acl_t's are identical, 1 otherwise
42937f807aSGleb Popov  */
43937f807aSGleb Popov int
44937f807aSGleb Popov acl_cmp_np(acl_t acl1, acl_t acl2)
45937f807aSGleb Popov {
46937f807aSGleb Popov 	if (acl1 == NULL || acl2 == NULL) {
47937f807aSGleb Popov 		errno = EINVAL;
48937f807aSGleb Popov 		return (-1);
49937f807aSGleb Popov 	}
50937f807aSGleb Popov 
51937f807aSGleb Popov 	if (_acl_brand(acl1) != _acl_brand(acl2))
52937f807aSGleb Popov 		return (1);
53937f807aSGleb Popov 
54937f807aSGleb Popov 	return (_acl_differs(acl1, acl2));
55937f807aSGleb Popov }
56