file_cmds-321.40.3.tar.gz
[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 #ifndef _CHMOD_ACL_H_
35 #define _CHMOD_ACL_H_
36
37 #ifdef __APPLE__
38 #include <pwd.h>
39 #include <grp.h>
40 #include <ctype.h>
41 #include <sys/acl.h>
42 #include <sys/kauth.h>
43 #include <uuid/uuid.h>
44
45 #define ACL_FLAG (1<<0)
46 #define ACL_SET_FLAG (1<<1)
47 #define ACL_DELETE_FLAG (1<<2)
48 #define ACL_REWRITE_FLAG (1<<3)
49 #define ACL_ORDER_FLAG (1<<4)
50 #define ACL_INHERIT_FLAG (1<<5)
51 #define ACL_FOLLOW_LINK (1<<6)
52 #define ACL_FROM_STDIN (1<<7)
53 #define ACL_CHECK_CANONICITY (1<<8)
54 #define ACL_REMOVE_INHERIT_FLAG (1<<9)
55 #define ACL_REMOVE_INHERITED_ENTRIES (1<<10)
56 #define ACL_NO_TRANSLATE (1<<11)
57 #define ACL_INVOKE_EDITOR (1<<12)
58 #define ACL_TO_STDOUT (1<<13)
59 #define ACL_CLEAR_FLAG (1<<14)
60
61 #define INHERITANCE_TIER (-5)
62 #define MINIMUM_TIER (-1000)
63
64 #define MATCH_EXACT (2)
65 #define MATCH_PARTIAL (1)
66 #define MATCH_NONE (-1)
67 #define MATCH_SUBSET (-2)
68 #define MATCH_SUPERSET (-3)
69
70 #define MAX_ACL_TEXT_SIZE 4096
71 #define MAX_INHERITANCE_LEVEL 1024
72
73 extern int search_acl_block(char *tok);
74 extern int parse_entry(char *entrybuf, acl_entry_t newent);
75 extern acl_t parse_acl_entries(const char *input);
76 extern int score_acl_entry(acl_entry_t entry);
77 extern unsigned get_inheritance_level(acl_entry_t entry);
78 extern int compare_acl_qualifiers(uuid_t *qa, uuid_t *qb);
79 extern int compare_acl_permsets(acl_permset_t aperms, acl_permset_t bperms);
80 extern int compare_acl_entries(acl_entry_t a, acl_entry_t b);
81 extern unsigned is_canonical(acl_t acl);
82 extern int find_matching_entry (acl_t acl, acl_entry_t modifier, acl_entry_t *rentry, unsigned match_inherited);
83 extern unsigned find_canonical_position(acl_t acl, acl_entry_t modifier);
84 extern int subtract_from_entry(acl_entry_t rentry, acl_entry_t modifier, int *valid_perms);
85 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);
86 extern int modify_file_acl(unsigned int optflags, const char *path, acl_t modifier, int position, int inheritance_level, int follow);
87 extern uuid_t *name_to_uuid(char *tok, int nametype);
88 #endif /* __APPLE__*/
89
90 #endif /* _CHMOD_ACL_H_ */