]> git.saurik.com Git - apple/file_cmds.git/blob - chmod/chmod_acl.h
31fe1436db5e9faced10f4939b99895fa3438b77
[apple/file_cmds.git] / chmod / chmod_acl.h
1 /*
2 * Copyright (c) 1989, 1993, 1994
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by the University of
16 * California, Berkeley and its contributors.
17 * 4. Neither the name of the University nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 */
33
34 #ifdef __APPLE__
35 #include <pwd.h>
36 #include <grp.h>
37 #include <ctype.h>
38 #include <sys/acl.h>
39 #include <sys/kauth.h>
40 #include <uuid/uuid.h>
41
42 #define ACL_FLAG (1<<0)
43 #define ACL_SET_FLAG (1<<1)
44 #define ACL_DELETE_FLAG (1<<2)
45 #define ACL_REWRITE_FLAG (1<<3)
46 #define ACL_ORDER_FLAG (1<<4)
47 #define ACL_INHERIT_FLAG (1<<5)
48 #define ACL_FOLLOW_LINK (1<<6)
49 #define ACL_FROM_STDIN (1<<7)
50 #define ACL_CHECK_CANONICITY (1<<8)
51 #define ACL_REMOVE_INHERIT_FLAG (1<<9)
52 #define ACL_REMOVE_INHERITED_ENTRIES (1<<10)
53 #define ACL_NO_TRANSLATE (1<<11)
54 #define ACL_INVOKE_EDITOR (1<<12)
55 #define ACL_TO_STDOUT (1<<13)
56 #define ACL_CLEAR_FLAG (1<<14)
57
58 #define INHERITANCE_TIER (-5)
59 #define MINIMUM_TIER (-1000)
60
61 #define MATCH_EXACT (2)
62 #define MATCH_PARTIAL (1)
63 #define MATCH_NONE (-1)
64 #define MATCH_SUBSET (-2)
65 #define MATCH_SUPERSET (-3)
66
67 #define MAX_ACL_TEXT_SIZE 4096
68 #define MAX_INHERITANCE_LEVEL 1024
69
70 extern int search_acl_block(char *tok);
71 extern int parse_entry(char *entrybuf, acl_entry_t newent);
72 extern acl_t parse_acl_entries(const char *input);
73 extern int score_acl_entry(acl_entry_t entry);
74 extern unsigned get_inheritance_level(acl_entry_t entry);
75 extern int compare_acl_qualifiers(uuid_t *qa, uuid_t *qb);
76 extern int compare_acl_permsets(acl_permset_t aperms, acl_permset_t bperms);
77 extern int compare_acl_entries(acl_entry_t a, acl_entry_t b);
78 extern unsigned is_canonical(acl_t acl);
79 extern int find_matching_entry (acl_t acl, acl_entry_t modifier, acl_entry_t *rentry, unsigned match_inherited);
80 extern unsigned find_canonical_position(acl_t acl, acl_entry_t modifier);
81 extern int subtract_from_entry(acl_entry_t rentry, acl_entry_t modifier, int *valid_perms);
82 extern int modify_acl(acl_t *oaclp, acl_entry_t modifier, unsigned int optflags, int position, int inheritance_level, unsigned flag_new_acl, const char* path);
83 extern int modify_file_acl(unsigned int optflags, const char *path, acl_t modifier, int position, int inheritance_level);
84 extern uuid_t *name_to_uuid(char *tok, int nametype);
85 #endif /* __APPLE__*/