]> arthur.barton.de Git - netatalk.git/blob - etc/afpd/acls.h
Merge remote-tracking branch 'origin/branch-netatalk-3-0' into develop
[netatalk.git] / etc / afpd / acls.h
1 /*
2    Copyright (c) 2008,2009 Frank Lahm <franklahm@gmail.com>
3
4    This program is free software; you can redistribute it and/or modify
5    it under the terms of the GNU General Public License as published by
6    the Free Software Foundation; either version 2 of the License, or
7    (at your option) any later version.
8  
9    This program is distributed in the hope that it will be useful,
10    but WITHOUT ANY WARRANTY; without even the implied warranty of
11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12    GNU General Public License for more details.
13  */
14
15 #ifndef AFPD_ACLS_H 
16 #define AFPD_ACLS_H
17
18 #ifdef HAVE_SOLARIS_ACLS
19 #include <sys/acl.h>
20 #endif
21 #ifdef HAVE_FREEBSD_SUNACL
22 #include <sunacl.h>
23 #endif
24
25 #include <atalk/uuid.h>         /* for atalk_uuid_t */
26
27 /*
28  * This is what Apple says about ACL flags in sys/kauth.h:
29  *
30  * <Apple> The low 16 bits of the flags field are reserved for filesystem
31  * internal use and must be preserved by all APIs.  This includes
32  * round-tripping flags through user-space interfaces.
33  * The high 16 bits of the flags are used to store attributes and
34  * to request specific handling of the ACL. </Apple>
35  * 
36  * The constants are included for reference. We DONT expect them on
37  * the wire! We will ignore and spoil em.
38  */
39
40 #ifdef HAVE_NFSV4_ACLS
41 /* Some stuff for the handling of NFSv4 ACLs */
42 #define ACE_TRIVIAL (ACE_OWNER | ACE_GROUP | ACE_EVERYONE)
43 #endif /* HAVE_NFSV4_ACLS */
44
45 /* FPGet|Set Bitmap */
46 enum {
47     kFileSec_UUID      = (1<<0),
48     kFileSec_GRPUUID   = (1<<1),
49     kFileSec_ACL       = (1<<2),
50     kFileSec_REMOVEACL = (1<<3),
51     kFileSec_Inherit   = (1<<4)
52 };
53
54 /* ACL Flags */
55 #define DARWIN_ACL_FLAGS_PRIVATE       (0xffff)
56 /* inheritance will be deferred until the first rename operation */
57 #define KAUTH_ACL_DEFER_INHERIT (1<<16)
58 /* this ACL must not be overwritten as part of an inheritance operation */
59 #define KAUTH_ACL_NO_INHERIT (1<<17)
60
61 /* ACE Flags */
62 #define DARWIN_ACE_FLAGS_KINDMASK           0xf
63 #define DARWIN_ACE_FLAGS_PERMIT             (1<<0) /* 0x00000001 */
64 #define DARWIN_ACE_FLAGS_DENY               (1<<1) /* 0x00000002 */
65 #define DARWIN_ACE_FLAGS_INHERITED          (1<<4) /* 0x00000010 */
66 #define DARWIN_ACE_FLAGS_FILE_INHERIT       (1<<5) /* 0x00000020 */
67 #define DARWIN_ACE_FLAGS_DIRECTORY_INHERIT  (1<<6) /* 0x00000040 */
68 #define DARWIN_ACE_FLAGS_LIMIT_INHERIT      (1<<7) /* 0x00000080 */
69 #define DARWIN_ACE_FLAGS_ONLY_INHERIT       (1<<8) /* 0x00000100 */
70
71 /* All flag bits controlling ACE inheritance */
72 #define DARWIN_ACE_INHERIT_CONTROL_FLAGS \
73        (DARWIN_ACE_FLAGS_FILE_INHERIT |\
74         DARWIN_ACE_FLAGS_DIRECTORY_INHERIT |\
75         DARWIN_ACE_FLAGS_LIMIT_INHERIT |\
76         DARWIN_ACE_FLAGS_ONLY_INHERIT)
77
78 /* ACE Rights */
79 #define DARWIN_ACE_READ_DATA           0x00000002
80 #define DARWIN_ACE_LIST_DIRECTORY      0x00000002
81 #define DARWIN_ACE_WRITE_DATA          0x00000004
82 #define DARWIN_ACE_ADD_FILE            0x00000004
83 #define DARWIN_ACE_EXECUTE             0x00000008
84 #define DARWIN_ACE_SEARCH              0x00000008
85 #define DARWIN_ACE_DELETE              0x00000010
86 #define DARWIN_ACE_APPEND_DATA         0x00000020
87 #define DARWIN_ACE_ADD_SUBDIRECTORY    0x00000020
88 #define DARWIN_ACE_DELETE_CHILD        0x00000040
89 #define DARWIN_ACE_READ_ATTRIBUTES     0x00000080
90 #define DARWIN_ACE_WRITE_ATTRIBUTES    0x00000100
91 #define DARWIN_ACE_READ_EXTATTRIBUTES  0x00000200
92 #define DARWIN_ACE_WRITE_EXTATTRIBUTES 0x00000400
93 #define DARWIN_ACE_READ_SECURITY       0x00000800
94 #define DARWIN_ACE_WRITE_SECURITY      0x00001000
95 #define DARWIN_ACE_TAKE_OWNERSHIP      0x00002000
96
97 /* Access Control List Entry (ACE) */
98 typedef struct {
99     atalk_uuid_t      darwin_ace_uuid;
100     uint32_t    darwin_ace_flags;
101     uint32_t    darwin_ace_rights;
102 } darwin_ace_t;
103
104 /* Access Control List */
105 typedef struct {
106     uint32_t darwin_acl_count;
107     uint32_t darwin_acl_flags;
108 } darwin_acl_header_t;
109
110 /* FP functions */
111 int afp_access (AFPObj *obj, char *ibuf, size_t ibuflen, char *rbuf,  size_t *rbuflen);
112 int afp_getacl (AFPObj *obj, char *ibuf, size_t ibuflen, char *rbuf,  size_t *rbuflen);
113 int afp_setacl (AFPObj *obj, char *ibuf, size_t ibuflen, char *rbuf,  size_t *rbuflen);
114
115 /* Parse afp.conf */
116 extern int acl_ldap_readconfig(char *name);
117
118 /* Misc funcs */
119 extern int acltoownermode(const AFPObj *obj, const struct vol *vol, char *path, struct stat *st, struct maccess *ma);
120 #endif