2 Copyright (c) 2008, 2009, 2010 Frank Lahm <franklahm@gmail.com>
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.
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.
17 #endif /* HAVE_CONFIG_H */
26 #ifdef HAVE_SOLARIS_ACLS
29 #ifdef HAVE_POSIX_ACLS
31 #include <acl/libacl.h>
34 #include <atalk/errchk.h>
35 #include <atalk/adouble.h>
36 #include <atalk/vfs.h>
37 #include <atalk/afp.h>
38 #include <atalk/util.h>
39 #include <atalk/cnid.h>
40 #include <atalk/logger.h>
41 #include <atalk/uuid.h>
42 #include <atalk/acl.h>
43 #include <atalk/bstrlib.h>
44 #include <atalk/bstradd.h>
46 #include "directory.h"
52 #include "acl_mappings.h"
56 #define SOLARIS_2_DARWIN 1
57 #define DARWIN_2_SOLARIS 2
58 #define POSIX_DEFAULT_2_DARWIN 3
59 #define POSIX_ACCESS_2_DARWIN 4
60 #define DARWIN_2_POSIX_DEFAULT 5
61 #define DARWIN_2_POSIX_ACCESS 6
66 /********************************************************
68 ********************************************************/
70 #ifdef HAVE_SOLARIS_ACLS
73 * Compile access rights for a user to one file-system object
75 * This combines combines all access rights for a user to one fs-object and
76 * returns the result as a Darwin allowed rights ACE.
77 * This must honor trivial ACEs which are a mode_t mapping.
79 * @param path (r) path to filesystem object
80 * @param sb (r) struct stat of path
81 * @param result (w) resulting Darwin allow ACE
83 * @returns 0 or -1 on error
85 static int solaris_acl_rights(const char *path,
86 const struct stat *sb,
90 int i, ace_count, checkgroup;
94 uint32_t rights, allowed_rights = 0, denied_rights = 0, darwin_rights;
96 /* Get ACL from file/dir */
97 EC_NEG1_LOG(ace_count = get_nfsv4_acl(path, &aces));
102 /* Now check requested rights */
104 do { /* Loop through ACEs */
106 flags = aces[i].a_flags;
107 type = aces[i].a_type;
108 rights = aces[i].a_access_mask;
110 if (flags & ACE_INHERIT_ONLY_ACE)
113 /* Now the tricky part: decide if ACE effects our user. I'll explain:
114 if its a dedicated (non trivial) ACE for the user
116 if its a ACE for a group we're member of
118 if its a trivial ACE_OWNER ACE and requested UUID is the owner
120 if its a trivial ACE_GROUP ACE and requested UUID is group
122 if its a trivial ACE_EVERYONE ACE
125 if (((who == uuid) && !(flags & (ACE_TRIVIAL|ACE_IDENTIFIER_GROUP)))
127 ((flags & ACE_IDENTIFIER_GROUP) && !(flags & ACE_GROUP) && gmem(who))
129 ((flags & ACE_OWNER) && (uuid == sb->st_uid))
131 ((flags & ACE_GROUP) && gmem(sb->st_gid))
133 (flags & ACE_EVERYONE)
135 /* Found an applicable ACE */
136 if (type == ACE_ACCESS_ALLOWED_ACE_TYPE)
137 allowed_rights |= rights;
138 else if (type == ACE_ACCESS_DENIED_ACE_TYPE)
139 /* Only or to denied rights if not previously allowed !! */
140 denied_rights |= ((!allowed_rights) & rights);
142 } while (++i < ace_count);
145 /* Darwin likes to ask for "delete_child" on dir,
146 "write_data" is actually the same, so we add that for dirs */
147 if (S_ISDIR(sb->st_mode) && (allowed_rights & ACE_WRITE_DATA))
148 allowed_rights |= ACE_DELETE_CHILD;
150 /* Remove denied from allowed rights */
151 allowed_rights &= ~denied_rights;
155 for (i=0; nfsv4_to_darwin_rights[i].from != 0; i++) {
156 if (allowed_rights & nfsv4_to_darwin_rights[i].from)
157 darwin_rights |= nfsv4_to_darwin_rights[i].to;
160 *result |= darwin_rights;
163 if (aces) free(aces);
169 Maps ACE array from Solaris to Darwin. Darwin ACEs are stored in network byte order.
170 Return numer of mapped ACEs or -1 on error.
171 All errors while mapping (e.g. getting UUIDs from LDAP) are fatal.
173 static int map_aces_solaris_to_darwin(const ace_t *aces,
174 darwin_ace_t *darwin_aces,
181 struct passwd *pwd = NULL;
182 struct group *grp = NULL;
184 LOG(log_maxdebug, logtype_afpd, "map_aces_solaris_to_darwin: parsing %d ACES", ace_count);
187 LOG(log_maxdebug, logtype_afpd, "ACE No. %d", ace_count + 1);
188 /* if its a ACE resulting from nfsv4 mode mapping, discard it */
189 if (aces->a_flags & (ACE_OWNER | ACE_GROUP | ACE_EVERYONE)) {
190 LOG(log_debug, logtype_afpd, "trivial ACE");
195 if ( ! (aces->a_flags & ACE_IDENTIFIER_GROUP) ) { /* user ace */
196 LOG(log_debug, logtype_afpd, "uid: %d", aces->a_who);
197 EC_NULL_LOG(pwd = getpwuid(aces->a_who));
198 LOG(log_debug, logtype_afpd, "uid: %d -> name: %s", aces->a_who, pwd->pw_name);
199 EC_ZERO_LOG(getuuidfromname(pwd->pw_name,
201 darwin_aces->darwin_ace_uuid));
202 } else { /* group ace */
203 LOG(log_debug, logtype_afpd, "gid: %d", aces->a_who);
204 EC_NULL_LOG(grp = getgrgid(aces->a_who));
205 LOG(log_debug, logtype_afpd, "gid: %d -> name: %s", aces->a_who, grp->gr_name);
206 EC_ZERO_LOG(getuuidfromname(grp->gr_name,
208 darwin_aces->darwin_ace_uuid));
212 if (aces->a_type == ACE_ACCESS_ALLOWED_ACE_TYPE)
213 flags = DARWIN_ACE_FLAGS_PERMIT;
214 else if (aces->a_type == ACE_ACCESS_DENIED_ACE_TYPE)
215 flags = DARWIN_ACE_FLAGS_DENY;
216 else { /* unsupported type */
220 for(i=0; nfsv4_to_darwin_flags[i].from != 0; i++) {
221 if (aces->a_flags & nfsv4_to_darwin_flags[i].from)
222 flags |= nfsv4_to_darwin_flags[i].to;
224 darwin_aces->darwin_ace_flags = htonl(flags);
228 for (i=0; nfsv4_to_darwin_rights[i].from != 0; i++) {
229 if (aces->a_access_mask & nfsv4_to_darwin_rights[i].from)
230 rights |= nfsv4_to_darwin_rights[i].to;
232 darwin_aces->darwin_ace_rights = htonl(rights);
245 Maps ACE array from Darwin to Solaris. Darwin ACEs are expected in network byte order.
246 Return numer of mapped ACEs or -1 on error.
247 All errors while mapping (e.g. getting UUIDs from LDAP) are fatal.
249 static int map_aces_darwin_to_solaris(darwin_ace_t *darwin_aces,
254 int i, mapped_aces = 0;
255 uint32_t darwin_ace_flags;
256 uint32_t darwin_ace_rights;
257 uint16_t nfsv4_ace_flags;
258 uint32_t nfsv4_ace_rights;
266 nfsv4_ace_rights = 0;
269 EC_ZERO(getnamefromuuid(darwin_aces->darwin_ace_uuid, &name, &uuidtype));
277 EC_NULL_LOG(pwd = getpwnam(name));
278 nfsv4_aces->a_who = pwd->pw_uid;
281 EC_NULL_LOG(grp = getgrnam(name));
282 nfsv4_aces->a_who = (uid_t)(grp->gr_gid);
283 nfsv4_ace_flags |= ACE_IDENTIFIER_GROUP;
289 /* now type: allow/deny */
290 darwin_ace_flags = ntohl(darwin_aces->darwin_ace_flags);
291 if (darwin_ace_flags & DARWIN_ACE_FLAGS_PERMIT)
292 nfsv4_aces->a_type = ACE_ACCESS_ALLOWED_ACE_TYPE;
293 else if (darwin_ace_flags & DARWIN_ACE_FLAGS_DENY)
294 nfsv4_aces->a_type = ACE_ACCESS_DENIED_ACE_TYPE;
295 else { /* unsupported type */
300 for(i=0; darwin_to_nfsv4_flags[i].from != 0; i++) {
301 if (darwin_ace_flags & darwin_to_nfsv4_flags[i].from)
302 nfsv4_ace_flags |= darwin_to_nfsv4_flags[i].to;
306 darwin_ace_rights = ntohl(darwin_aces->darwin_ace_rights);
307 for (i=0; darwin_to_nfsv4_rights[i].from != 0; i++) {
308 if (darwin_ace_rights & darwin_to_nfsv4_rights[i].from)
309 nfsv4_ace_rights |= darwin_to_nfsv4_rights[i].to;
312 LOG(log_debug9, logtype_afpd, "map_aces_darwin_to_solaris: ACE flags: Darwin:%08x -> NFSv4:%04x", darwin_ace_flags, nfsv4_ace_flags);
313 LOG(log_debug9, logtype_afpd, "map_aces_darwin_to_solaris: ACE rights: Darwin:%08x -> NFSv4:%08x", darwin_ace_rights, nfsv4_ace_rights);
315 nfsv4_aces->a_flags = nfsv4_ace_flags;
316 nfsv4_aces->a_access_mask = nfsv4_ace_rights;
329 #endif /* HAVE_SOLARIS_ACLS */
331 /********************************************************
333 ********************************************************/
335 #ifdef HAVE_POSIX_ACLS
337 static uint32_t posix_permset_to_darwin_rights(acl_entry_t e, int is_dir)
341 acl_permset_t permset;
343 EC_ZERO_LOG(acl_get_permset(e, &permset));
345 if (acl_get_perm(permset, ACL_READ))
346 rights = DARWIN_ACE_READ_DATA
347 | DARWIN_ACE_READ_EXTATTRIBUTES
348 | DARWIN_ACE_READ_ATTRIBUTES
349 | DARWIN_ACE_READ_SECURITY;
350 if (acl_get_perm(permset, ACL_WRITE)) {
351 rights |= DARWIN_ACE_WRITE_DATA
352 | DARWIN_ACE_APPEND_DATA
353 | DARWIN_ACE_WRITE_EXTATTRIBUTES
354 | DARWIN_ACE_WRITE_ATTRIBUTES;
356 rights |= DARWIN_ACE_DELETE_CHILD;
358 if (acl_get_perm(permset, ACL_EXECUTE))
359 rights |= DARWIN_ACE_EXECUTE;
362 LOG(log_maxdebug, logtype_afpd, "mapped rights: 0x%08x", rights);
367 * Compile access rights for a user to one file-system object
369 * This combines combines all access rights for a user to one fs-object and
370 * returns the result as a Darwin allowed rights ACE.
371 * This must honor trivial ACEs which are a mode_t mapping.
373 * @param path (r) path to filesystem object
374 * @param sb (r) struct stat of path
375 * @param result (rw) resulting Darwin allow ACE
377 * @returns 0 or -1 on error
379 static int posix_acl_rights(const char *path,
380 const struct stat *sb,
385 int entry_id = ACL_FIRST_ENTRY;
386 uint32_t rights = 0, maskrights = 0;
393 EC_NULL_LOG(acl = acl_get_file(path, ACL_TYPE_ACCESS));
395 /* itereate through all ACEs to get the mask */
396 while (!havemask && acl_get_entry(acl, entry_id, &e) == 1) {
397 entry_id = ACL_NEXT_ENTRY;
398 EC_ZERO_LOG(acl_get_tag_type(e, &tag));
401 maskrights = posix_permset_to_darwin_rights(e, S_ISDIR(sb->st_mode));
402 LOG(log_maxdebug, logtype_afpd, "maskrights: 0x%08x", maskrights);
410 /* itereate through all ACEs */
411 entry_id = ACL_FIRST_ENTRY;
412 while (acl_get_entry(acl, entry_id, &e) == 1) {
413 entry_id = ACL_NEXT_ENTRY;
414 EC_ZERO_LOG(acl_get_tag_type(e, &tag));
417 EC_NULL_LOG(uid = (uid_t *)acl_get_qualifier(e));
419 LOG(log_maxdebug, logtype_afpd, "ACL_USER: %u", *uid);
420 rights |= posix_permset_to_darwin_rights(e, S_ISDIR(sb->st_mode));
426 if (sb->st_uid == uuid) {
427 LOG(log_maxdebug, logtype_afpd, "ACL_USER_OBJ: %u", sb->st_uid);
428 rights |= posix_permset_to_darwin_rights(e, S_ISDIR(sb->st_mode));
432 EC_NULL_LOG(gid = (gid_t *)acl_get_qualifier(e));
434 LOG(log_maxdebug, logtype_afpd, "ACL_GROUP: %u", *gid);
435 rights |= (posix_permset_to_darwin_rights(e, S_ISDIR(sb->st_mode)) & maskrights);
441 if (gmem(sb->st_gid)) {
442 LOG(log_maxdebug, logtype_afpd, "ACL_GROUP_OBJ: %u", sb->st_gid);
443 rights |= posix_permset_to_darwin_rights(e, S_ISDIR(sb->st_mode));
447 LOG(log_maxdebug, logtype_afpd, "ACL_OTHER");
448 rights |= posix_permset_to_darwin_rights(e, S_ISDIR(sb->st_mode));
458 if (acl) acl_free(acl);
459 if (uid) acl_free(uid);
460 if (gid) acl_free(gid);
465 * Add entries of one acl to another acl
467 * @param aclp (rw) destination acl where new aces will be added
468 * @param acl (r) source acl where aces will be copied from
470 * @returns 0 on success, -1 on error
472 static int acl_add_acl(acl_t *aclp, const acl_t acl)
478 for (id = ACL_FIRST_ENTRY; acl_get_entry(acl, id, &se) == 1; id = ACL_NEXT_ENTRY) {
479 EC_ZERO_LOG_ERR(acl_create_entry(aclp, &de), AFPERR_MISC);
480 EC_ZERO_LOG_ERR(acl_copy_entry(de, se), AFPERR_MISC);
488 * Map Darwin ACE rights to POSIX 1e perm
490 * We can only map few rights:
491 * DARWIN_ACE_READ_DATA -> ACL_READ
492 * DARWIN_ACE_WRITE_DATA -> ACL_WRITE
493 * DARWIN_ACE_DELETE_CHILD & (is_dir == 1) -> ACL_WRITE
494 * DARWIN_ACE_EXECUTE -> ACL_EXECUTE
496 * @param entry (rw) result of the mapping
497 * @param is_dir (r) 1 for dirs, 0 for files
499 * @returns mapping result as acl_perm_t, -1 on error
501 static acl_perm_t map_darwin_right_to_posix_permset(uint32_t darwin_ace_rights, int is_dir)
505 if (darwin_ace_rights & DARWIN_ACE_READ_DATA)
508 if (darwin_ace_rights & (DARWIN_ACE_WRITE_DATA | (DARWIN_ACE_DELETE_CHILD & is_dir)))
511 if (darwin_ace_rights & DARWIN_ACE_EXECUTE)
518 * Add a ACL_USER or ACL_GROUP permission to an ACL, extending existing ACEs
520 * Add a permission of "type" for user or group "id" to an ACL. Scan the ACL
521 * for existing permissions for this type/id, if there is one add the perm,
522 * otherwise create a new ACL entry.
523 * perm can be or'ed ACL_READ, ACL_WRITE and ACL_EXECUTE.
525 * @param aclp (rw) pointer to ACL
526 * @param type (r) acl_tag_t of ACL_USER or ACL_GROUP
527 * @param id (r) uid_t uid for ACL_USER, or gid casted to uid_t for ACL_GROUP
528 * @param perm (r) acl_perm_t permissions to add
530 * @returns 0 on success, -1 on failure
532 static int posix_acl_add_perm(acl_t *aclp, acl_tag_t type, uid_t id, acl_perm_t perm)
538 int entry_id = ACL_FIRST_ENTRY;
539 acl_permset_t permset;
542 for ( ; (! found) && acl_get_entry(*aclp, entry_id, &e) == 1; entry_id = ACL_NEXT_ENTRY) {
543 EC_ZERO_LOG(acl_get_tag_type(e, &tag));
544 if (tag != ACL_USER && tag != ACL_GROUP)
546 EC_NULL_LOG(eid = (uid_t *)acl_get_qualifier(e));
547 if ((*eid == id) && (type == tag)) {
548 /* found an ACE for this type/id */
550 EC_ZERO_LOG(acl_get_permset(e, &permset));
551 EC_ZERO_LOG(acl_add_perm(permset, perm));
559 /* there was no existing ACE for this type/id */
560 EC_ZERO_LOG(acl_create_entry(aclp, &e));
561 EC_ZERO_LOG(acl_set_tag_type(e, type));
562 EC_ZERO_LOG(acl_set_qualifier(e, &id));
563 EC_ZERO_LOG(acl_get_permset(e, &permset));
564 EC_ZERO_LOG(acl_clear_perms(permset));
565 EC_ZERO_LOG(acl_add_perm(permset, perm));
566 EC_ZERO_LOG(acl_set_permset(e, permset));
570 if (eid) acl_free(eid);
576 * Map Darwin ACL to POSIX ACL.
578 * aclp must point to a acl_init'ed acl_t or an acl_t that can eg contain default ACEs.
579 * Mapping pecularities:
580 * - we create a default ace (which inherits to files and dirs) if either
581 DARWIN_ACE_FLAGS_FILE_INHERIT or DARWIN_ACE_FLAGS_DIRECTORY_INHERIT is requested
582 * - we throw away DARWIN_ACE_FLAGS_LIMIT_INHERIT (can't be mapped), thus the ACL will
585 * @param darwin_aces (r) pointer to darwin_aces buffer
586 * @param def_aclp (rw) directories: pointer to an initialized acl_t with the default acl
587 * files: *def_aclp will be NULL
588 * @param acc_aclp (rw) pointer to an initialized acl_t with the access acl
589 * @param ace_count (r) number of ACEs in darwin_aces buffer
591 * @returns 0 on success storing the result in aclp, -1 on error.
593 static int map_aces_darwin_to_posix(const darwin_ace_t *darwin_aces,
604 uint32_t darwin_ace_flags, darwin_ace_rights;
608 for ( ; ace_count != 0; ace_count--, darwin_aces++) {
609 /* type: allow/deny, posix only has allow */
610 darwin_ace_flags = ntohl(darwin_aces->darwin_ace_flags);
611 if ( ! (darwin_ace_flags & DARWIN_ACE_FLAGS_PERMIT))
614 darwin_ace_rights = ntohl(darwin_aces->darwin_ace_rights);
615 perm = map_darwin_right_to_posix_permset(darwin_ace_rights, (*def_aclp != NULL));
617 continue; /* dont add empty perm */
619 LOG(log_debug, logtype_afpd, "map_ace: no: %u, flags: %08x, darwin: %08x, posix: %02x",
620 ace_count, darwin_ace_flags, darwin_ace_rights, perm);
623 EC_ZERO_LOG(getnamefromuuid(darwin_aces->darwin_ace_uuid, &name, &uuidtype));
630 EC_NULL_LOG(pwd = getpwnam(name));
633 LOG(log_debug, logtype_afpd, "map_ace: name: %s, uid: %u", name, id);
636 EC_NULL_LOG(grp = getgrnam(name));
638 id = (uid_t)(grp->gr_gid);
639 LOG(log_debug, logtype_afpd, "map_ace: name: %s, gid: %u", name, id);
645 if (darwin_ace_flags & DARWIN_ACE_INHERIT_CONTROL_FLAGS) {
646 if (*def_aclp == NULL) {
647 /* ace request inheritane but we haven't got a default acl pointer */
648 LOG(log_warning, logtype_afpd, "map_acl: unexpected ACE, flags: 0x%04x",
652 /* add it as default ace */
653 EC_ZERO_LOG(posix_acl_add_perm(def_aclp, tag, id, perm));
656 if (! (darwin_ace_flags & DARWIN_ACE_FLAGS_ONLY_INHERIT))
657 /* if it not a "inherit only" ace, it must be added as access aces too */
658 EC_ZERO_LOG(posix_acl_add_perm(acc_aclp, tag, id, perm));
660 EC_ZERO_LOG(posix_acl_add_perm(acc_aclp, tag, id, perm));
672 * Map ACEs from POSIX to Darwin.
673 * type is either POSIX_DEFAULT_2_DARWIN or POSIX_ACCESS_2_DARWIN, cf. acl_get_file.
674 * Return number of mapped ACES, -1 on error.
676 static int map_acl_posix_to_darwin(int type, const acl_t acl, darwin_ace_t *darwin_aces)
680 int entry_id = ACL_FIRST_ENTRY;
685 struct passwd *pwd = NULL;
686 struct group *grp = NULL;
688 uint32_t rights, maskrights = 0;
689 darwin_ace_t *saved_darwin_aces = darwin_aces;
691 LOG(log_maxdebug, logtype_afpd, "map_aces_posix_to_darwin(%s)",
692 (type & MAP_MASK) == POSIX_DEFAULT_2_DARWIN ?
693 "POSIX_DEFAULT_2_DARWIN" : "POSIX_ACCESS_2_DARWIN");
695 /* itereate through all ACEs */
696 while (acl_get_entry(acl, entry_id, &e) == 1) {
697 entry_id = ACL_NEXT_ENTRY;
700 EC_ZERO_LOG(acl_get_tag_type(e, &tag));
702 /* we return user and group ACE */
705 EC_NULL_LOG(uid = (uid_t *)acl_get_qualifier(e));
706 EC_NULL_LOG(pwd = getpwuid(*uid));
707 LOG(log_debug, logtype_afpd, "map_aces_posix_to_darwin: uid: %d -> name: %s",
709 EC_ZERO_LOG(getuuidfromname(pwd->pw_name, UUID_USER, darwin_aces->darwin_ace_uuid));
715 EC_NULL_LOG(gid = (gid_t *)acl_get_qualifier(e));
716 EC_NULL_LOG(grp = getgrgid(*gid));
717 LOG(log_debug, logtype_afpd, "map_aces_posix_to_darwin: gid: %d -> name: %s",
719 EC_ZERO_LOG(getuuidfromname(grp->gr_name, UUID_GROUP, darwin_aces->darwin_ace_uuid));
725 maskrights = posix_permset_to_darwin_rights(e, type & IS_DIR);
733 flags = DARWIN_ACE_FLAGS_PERMIT;
734 if ((type & MAP_MASK) == POSIX_DEFAULT_2_DARWIN)
735 flags |= DARWIN_ACE_FLAGS_FILE_INHERIT
736 | DARWIN_ACE_FLAGS_DIRECTORY_INHERIT
737 | DARWIN_ACE_FLAGS_ONLY_INHERIT;
738 darwin_aces->darwin_ace_flags = htonl(flags);
741 rights = posix_permset_to_darwin_rights(e, type & IS_DIR);
742 darwin_aces->darwin_ace_rights = htonl(rights);
748 /* Loop through the mapped ACE buffer once again, applying the mask */
749 for (int i = mapped_aces; i > 0; i--) {
750 saved_darwin_aces->darwin_ace_rights &= htonl(maskrights);
754 EC_STATUS(mapped_aces);
757 if (uid) acl_free(uid);
758 if (gid) acl_free(gid);
764 * Multiplex ACL mapping (SOLARIS_2_DARWIN, DARWIN_2_SOLARIS, POSIX_2_DARWIN, DARWIN_2_POSIX).
765 * Reads from 'aces' buffer, writes to 'rbuf' buffer.
766 * Caller must provide buffer.
767 * Darwin ACEs are read and written in network byte order.
768 * Needs to know how many ACEs are in the ACL (ace_count) for Solaris ACLs.
769 * Ignores trivial ACEs.
770 * Return no of mapped ACEs or -1 on error.
772 static int map_acl(int type, void *acl, darwin_ace_t *buf, int ace_count)
776 LOG(log_debug9, logtype_afpd, "map_acl: BEGIN");
778 switch (type & MAP_MASK) {
780 #ifdef HAVE_SOLARIS_ACLS
781 case SOLARIS_2_DARWIN:
782 mapped_aces = map_aces_solaris_to_darwin( acl, buf, ace_count);
785 case DARWIN_2_SOLARIS:
786 mapped_aces = map_aces_darwin_to_solaris( buf, acl, ace_count);
788 #endif /* HAVE_SOLARIS_ACLS */
790 #ifdef HAVE_POSIX_ACLS
791 case POSIX_DEFAULT_2_DARWIN:
792 mapped_aces = map_acl_posix_to_darwin(type, (const acl_t)acl, buf);
795 case POSIX_ACCESS_2_DARWIN:
796 mapped_aces = map_acl_posix_to_darwin(type, (const acl_t)acl, buf);
799 case DARWIN_2_POSIX_DEFAULT:
802 case DARWIN_2_POSIX_ACCESS:
804 #endif /* HAVE_POSIX_ACLS */
811 LOG(log_debug9, logtype_afpd, "map_acl: END");
815 /* Get ACL from object omitting trivial ACEs. Map to Darwin ACL style and
816 store Darwin ACL at rbuf. Add length of ACL written to rbuf to *rbuflen.
817 Returns 0 on success, -1 on error. */
818 static int get_and_map_acl(char *name, char *rbuf, size_t *rbuflen)
823 uint32_t *darwin_ace_count = (u_int32_t *)rbuf;
824 #ifdef HAVE_SOLARIS_ACLS
828 #ifdef HAVE_POSIX_ACLS
831 LOG(log_debug9, logtype_afpd, "get_and_map_acl: BEGIN");
833 /* Skip length and flags */
838 #ifdef HAVE_SOLARIS_ACLS
839 EC_NEG1(ace_count = get_nfsv4_acl(name, &aces));
840 EC_NEG1(mapped_aces = map_acl(SOLARIS_2_DARWIN, aces, (darwin_ace_t *)rbuf, ace_count));
841 #endif /* HAVE_SOLARIS_ACLS */
843 #ifdef HAVE_POSIX_ACLS
844 acl_t defacl = NULL , accacl = NULL;
846 /* stat to check if its a dir */
847 EC_ZERO_LOG(lstat(name, &st));
849 /* if its a dir, check for default acl too */
851 if (S_ISDIR(st.st_mode)) {
853 EC_NULL_LOG(defacl = acl_get_file(name, ACL_TYPE_DEFAULT));
854 EC_NEG1(mapped_aces = map_acl(POSIX_DEFAULT_2_DARWIN | dirflag,
856 (darwin_ace_t *)rbuf,
860 EC_NULL_LOG(accacl = acl_get_file(name, ACL_TYPE_ACCESS));
863 EC_NEG1(tmp = map_acl(POSIX_ACCESS_2_DARWIN | dirflag,
865 (darwin_ace_t *)(rbuf + mapped_aces * sizeof(darwin_ace_t)),
868 #endif /* HAVE_POSIX_ACLS */
870 LOG(log_debug, logtype_afpd, "get_and_map_acl: mapped %d ACEs", mapped_aces);
872 *darwin_ace_count = htonl(mapped_aces);
873 *rbuflen += sizeof(darwin_acl_header_t) + (mapped_aces * sizeof(darwin_ace_t));
878 #ifdef HAVE_SOLARIS_ACLS
879 if (aces) free(aces);
881 #ifdef HAVE_POSIX_ACLS
882 if (defacl) acl_free(defacl);
883 if (accacl) acl_free(accacl);
884 #endif /* HAVE_POSIX_ACLS */
886 LOG(log_debug9, logtype_afpd, "get_and_map_acl: END");
891 /* Removes all non-trivial ACLs from object. Returns full AFPERR code. */
892 static int remove_acl(const struct vol *vol,const char *path, int dir)
896 #if (defined HAVE_SOLARIS_ACLS || defined HAVE_POSIX_ACLS)
897 /* Ressource etc. first */
898 if ((ret = vol->vfs->vfs_remove_acl(vol, path, dir)) != AFP_OK)
900 /* now the data fork or dir */
901 ret = remove_acl_vfs(path);
908 - the client sends a complete list of ACEs, not only new ones. So we dont need to do
909 any combination business (one exception being 'kFileSec_Inherit': see next)
910 - client might request that we add inherited ACEs via 'kFileSec_Inherit'.
911 We will store inherited ACEs first, which is Darwins canonical order.
912 - returns AFPerror code
914 #ifdef HAVE_SOLARIS_ACLS
915 static int set_acl(const struct vol *vol,
922 int i, nfsv4_ace_count;
923 int tocopy_aces_count = 0, new_aces_count = 0, trivial_ace_count = 0;
924 ace_t *old_aces, *new_aces = NULL;
927 LOG(log_debug9, logtype_afpd, "set_acl: BEGIN");
930 /* inherited + trivial ACEs */
931 flags = ACE_INHERITED_ACE | ACE_OWNER | ACE_GROUP | ACE_EVERYONE;
933 /* only trivial ACEs */
934 flags = ACE_OWNER | ACE_GROUP | ACE_EVERYONE;
936 /* Get existing ACL and count ACEs which have to be copied */
937 if ((nfsv4_ace_count = get_nfsv4_acl(name, &old_aces)) == -1)
939 for ( i=0; i < nfsv4_ace_count; i++) {
940 if (old_aces[i].a_flags & flags)
944 /* Now malloc buffer exactly sized to fit all new ACEs */
945 if ((new_aces = malloc((ace_count + tocopy_aces_count) * sizeof(ace_t))) == NULL) {
946 LOG(log_error, logtype_afpd, "set_acl: malloc %s", strerror(errno));
947 EC_STATUS(AFPERR_MISC);
951 /* Start building new ACL */
953 /* Copy local inherited ACEs. Therefore we have 'Darwin canonical order' (see chmod there):
954 inherited ACEs first. */
956 for (i=0; i < nfsv4_ace_count; i++) {
957 if (old_aces[i].a_flags & ACE_INHERITED_ACE) {
958 memcpy(&new_aces[new_aces_count], &old_aces[i], sizeof(ace_t));
963 LOG(log_debug7, logtype_afpd, "set_acl: copied %d inherited ACEs", new_aces_count);
965 /* Now the ACEs from the client */
966 if ((ret = (map_acl(DARWIN_2_SOLARIS,
967 &new_aces[new_aces_count],
969 ace_count))) == -1) {
970 EC_STATUS(AFPERR_PARAM);
973 new_aces_count += ret;
974 LOG(log_debug7, logtype_afpd, "set_acl: mapped %d ACEs from client", ret);
976 /* Now copy the trivial ACEs */
977 for (i=0; i < nfsv4_ace_count; i++) {
978 if (old_aces[i].a_flags & (ACE_OWNER | ACE_GROUP | ACE_EVERYONE)) {
979 memcpy(&new_aces[new_aces_count], &old_aces[i], sizeof(ace_t));
984 LOG(log_debug7, logtype_afpd, "set_acl: copied %d trivial ACEs", trivial_ace_count);
986 /* Ressourcefork first.
987 Note: for dirs we set the same ACL on the .AppleDouble/.Parent _file_. This
988 might be strange for ACE_DELETE_CHILD and for inheritance flags. */
989 if ((ret = (vol->vfs->vfs_acl(vol, name, ACE_SETACL, new_aces_count, new_aces))) != 0) {
990 LOG(log_error, logtype_afpd, "set_acl: error setting acl: %s", strerror(errno));
991 if (errno == (EACCES | EPERM))
992 EC_STATUS(AFPERR_ACCESS);
993 else if (errno == ENOENT)
994 EC_STATUS(AFPERR_NOITEM);
996 EC_STATUS(AFPERR_MISC);
999 if ((ret = (acl(name, ACE_SETACL, new_aces_count, new_aces))) != 0) {
1000 LOG(log_error, logtype_afpd, "set_acl: error setting acl: %s", strerror(errno));
1001 if (errno == (EACCES | EPERM))
1002 EC_STATUS(AFPERR_ACCESS);
1003 else if (errno == ENOENT)
1004 EC_STATUS(AFPERR_NOITEM);
1006 EC_STATUS(AFPERR_MISC);
1013 if (old_aces) free(old_aces);
1014 if (new_aces) free(new_aces);
1016 LOG(log_debug9, logtype_afpd, "set_acl: END");
1019 #endif /* HAVE_SOLARIS_ACLS */
1021 #ifdef HAVE_POSIX_ACLS
1022 static int set_acl(const struct vol *vol,
1025 darwin_ace_t *daces,
1029 acl_t def_acl = NULL;
1030 acl_t acc_acl = NULL;
1032 LOG(log_maxdebug, logtype_afpd, "set_acl: BEGIN");
1035 EC_ZERO_LOG_ERR(lstat(name, &st), AFPERR_NOOBJ);
1037 /* seed default ACL with access ACL */
1038 if (S_ISDIR(st.st_mode))
1039 EC_NULL_LOG_ERR(def_acl = acl_get_file(name, ACL_TYPE_ACCESS), AFPERR_MISC);
1041 /* for files def_acl will be NULL */
1043 /* create access acl from mode */
1044 EC_NULL_LOG_ERR(acc_acl = acl_from_mode(st.st_mode), AFPERR_MISC);
1046 /* adds the clients aces */
1047 EC_ZERO_ERR(map_aces_darwin_to_posix(daces, &def_acl, &acc_acl, ace_count), AFPERR_MISC);
1049 /* calcuate ACL mask */
1050 EC_ZERO_LOG_ERR(acl_calc_mask(&acc_acl), AFPERR_MISC);
1053 EC_ZERO_LOG_ERR(acl_valid(acc_acl), AFPERR_MISC);
1056 EC_ZERO_LOG_ERR(acl_set_file(name, ACL_TYPE_ACCESS, acc_acl), AFPERR_MISC);
1057 EC_ZERO_LOG_ERR(vol->vfs->vfs_acl(vol, name, ACL_TYPE_ACCESS, 0, acc_acl), AFPERR_MISC);
1060 EC_ZERO_LOG_ERR(acl_set_file(name, ACL_TYPE_DEFAULT, def_acl), AFPERR_MISC);
1061 EC_ZERO_LOG_ERR(vol->vfs->vfs_acl(vol, name, ACL_TYPE_DEFAULT, 0, def_acl), AFPERR_MISC);
1068 LOG(log_maxdebug, logtype_afpd, "set_acl: END");
1071 #endif /* HAVE_POSIX_ACLS */
1074 * Checks if a given UUID has requested_rights(type darwin_ace_rights) for path.
1076 * Note: this gets called frequently and is a good place for optimizations !
1078 * @param vol (r) volume
1079 * @param dir (r) directory
1080 * @param path (r) path to filesystem object
1081 * @param uuid (r) UUID of user
1082 * @param requested_rights (r) requested Darwin ACE
1084 * @returns AFP result code
1086 static int check_acl_access(const struct vol *vol,
1087 const struct dir *dir,
1090 uint32_t requested_rights)
1093 uint32_t allowed_rights = 0;
1094 char *username = NULL;
1095 uuidtype_t uuidtype;
1097 bstring parent = NULL;
1099 LOG(log_maxdebug, logtype_afpd, "check_access: Request: 0x%08x", requested_rights);
1101 /* Get uid or gid from UUID */
1102 EC_ZERO_LOG_ERR(getnamefromuuid(uuid, &username, &uuidtype), AFPERR_PARAM);
1103 EC_ZERO_LOG_ERR(lstat(path, &st), AFPERR_PARAM);
1109 LOG(log_warning, logtype_afpd, "check_access: afp_access not supported for groups");
1110 EC_STATUS(AFPERR_MISC);
1114 LOG(log_warning, logtype_afpd, "check_access: local UUID");
1115 EC_STATUS(AFPERR_MISC);
1119 #ifdef HAVE_SOLARIS_ACLS
1120 EC_ZERO_LOG(solaris_acl_rights(path, &st, &allowed_rights));
1122 #ifdef HAVE_POSIX_ACLS
1123 EC_ZERO_LOG(posix_acl_rights(path, &st, &allowed_rights));
1126 LOG(log_debug, logtype_afpd, "allowed rights: 0x%08x", allowed_rights);
1129 * The DARWIN_ACE_DELETE right might implicitly result from write acces to the parent
1130 * directory. As it seems the 10.6 AFP client is puzzled when this right is not
1131 * allowed where a delete would succeed because the parent dir gives write perms.
1132 * So we check the parent dir for write access and set the right accordingly.
1133 * Currentyl acl2ownermode calls us with dir = NULL, because it doesn't make sense
1134 * there to do this extra check -- afaict.
1136 if (vol && dir && (requested_rights & DARWIN_ACE_DELETE)) {
1138 uint32_t parent_rights = 0;
1140 if (dir->d_did == DIRDID_ROOT_PARENT) {
1141 /* use volume path */
1142 EC_NULL_LOG_ERR(parent = bfromcstr(vol->v_path), AFPERR_MISC);
1144 /* build path for parent */
1145 EC_NULL_LOG_ERR(parent = bstrcpy(dir->d_fullpath), AFPERR_MISC);
1146 EC_ZERO_LOG_ERR(bconchar(parent, '/'), AFPERR_MISC);
1147 EC_ZERO_LOG_ERR(bcatcstr(parent, path), AFPERR_MISC);
1148 EC_NEG1_LOG_ERR(i = bstrrchr(parent, '/'), AFPERR_MISC);
1149 EC_ZERO_LOG_ERR(binsertch(parent, i, 1, 0), AFPERR_MISC);
1152 LOG(log_debug, logtype_afpd,"parent: %s", cfrombstr(parent));
1153 EC_ZERO_LOG_ERR(lstat(cfrombstr(parent), &st), AFPERR_MISC);
1155 #ifdef HAVE_SOLARIS_ACLS
1156 EC_ZERO_LOG(solaris_acl_rights(cfrombstr(parent), &st, &parent_rights));
1158 #ifdef HAVE_POSIX_ACLS
1159 EC_ZERO_LOG(posix_acl_rights(path, &st, &allowed_rights));
1161 if (parent_rights & (DARWIN_ACE_WRITE_DATA | DARWIN_ACE_DELETE_CHILD))
1162 allowed_rights |= DARWIN_ACE_DELETE; /* man, that was a lot of work! */
1165 if ((requested_rights & allowed_rights) != requested_rights) {
1166 LOG(log_debug, logtype_afpd, "some requested right wasn't allowed: 0x%08x / 0x%08x",
1167 requested_rights, allowed_rights);
1168 EC_STATUS(AFPERR_ACCESS);
1170 LOG(log_debug, logtype_afpd, "all requested rights are allowed: 0x%08x",
1176 if (username) free(username);
1177 if (parent) bdestroy(parent);
1182 /********************************************************
1184 ********************************************************/
1186 int afp_access(AFPObj *obj, char *ibuf, size_t ibuflen _U_, char *rbuf _U_, size_t *rbuflen)
1191 uint32_t did, darwin_ace_rights;
1193 struct path *s_path;
1199 memcpy(&vid, ibuf, sizeof( vid ));
1200 ibuf += sizeof(vid);
1201 if (NULL == ( vol = getvolbyvid( vid ))) {
1202 LOG(log_error, logtype_afpd, "afp_access: error getting volid:%d", vid);
1203 return AFPERR_NOOBJ;
1206 memcpy(&did, ibuf, sizeof( did ));
1207 ibuf += sizeof( did );
1208 if (NULL == ( dir = dirlookup( vol, did ))) {
1209 LOG(log_error, logtype_afpd, "afp_access: error getting did:%d", did);
1216 /* Store UUID address */
1217 uuid = (uuidp_t)ibuf;
1218 ibuf += UUID_BINSIZE;
1220 /* Store ACE rights */
1221 memcpy(&darwin_ace_rights, ibuf, 4);
1222 darwin_ace_rights = ntohl(darwin_ace_rights);
1225 /* get full path and handle file/dir subtleties in netatalk code*/
1226 if (NULL == ( s_path = cname( vol, dir, &ibuf ))) {
1227 LOG(log_error, logtype_afpd, "afp_getacl: cname got an error!");
1228 return AFPERR_NOOBJ;
1230 if (!s_path->st_valid)
1231 of_statdir(vol, s_path);
1232 if ( s_path->st_errno != 0 ) {
1233 LOG(log_error, logtype_afpd, "afp_getacl: cant stat");
1234 return AFPERR_NOOBJ;
1237 ret = check_acl_access(vol, dir, s_path->u_name, uuid, darwin_ace_rights);
1242 int afp_getacl(AFPObj *obj, char *ibuf, size_t ibuflen _U_, char *rbuf _U_, size_t *rbuflen)
1248 uint16_t vid, bitmap;
1249 struct path *s_path;
1253 LOG(log_debug9, logtype_afpd, "afp_getacl: BEGIN");
1257 memcpy(&vid, ibuf, sizeof( vid ));
1258 ibuf += sizeof(vid);
1259 if (NULL == ( vol = getvolbyvid( vid ))) {
1260 LOG(log_error, logtype_afpd, "afp_getacl: error getting volid:%d", vid);
1261 return AFPERR_NOOBJ;
1264 memcpy(&did, ibuf, sizeof( did ));
1265 ibuf += sizeof( did );
1266 if (NULL == ( dir = dirlookup( vol, did ))) {
1267 LOG(log_error, logtype_afpd, "afp_getacl: error getting did:%d", did);
1271 memcpy(&bitmap, ibuf, sizeof( bitmap ));
1272 memcpy(rbuf, ibuf, sizeof( bitmap ));
1273 bitmap = ntohs( bitmap );
1274 ibuf += sizeof( bitmap );
1275 rbuf += sizeof( bitmap );
1276 *rbuflen += sizeof( bitmap );
1278 /* skip maxreplysize */
1281 /* get full path and handle file/dir subtleties in netatalk code*/
1282 if (NULL == ( s_path = cname( vol, dir, &ibuf ))) {
1283 LOG(log_error, logtype_afpd, "afp_getacl: cname got an error!");
1284 return AFPERR_NOOBJ;
1286 if (!s_path->st_valid)
1287 of_statdir(vol, s_path);
1288 if ( s_path->st_errno != 0 ) {
1289 LOG(log_error, logtype_afpd, "afp_getacl: cant stat");
1290 return AFPERR_NOOBJ;
1293 /* Shall we return owner UUID ? */
1294 if (bitmap & kFileSec_UUID) {
1295 LOG(log_debug, logtype_afpd, "afp_getacl: client requested files owner user UUID");
1296 if (NULL == (pw = getpwuid(s_path->st.st_uid)))
1298 LOG(log_debug, logtype_afpd, "afp_getacl: got uid: %d, name: %s", s_path->st.st_uid, pw->pw_name);
1299 if ((ret = getuuidfromname(pw->pw_name, UUID_USER, rbuf)) != 0)
1301 rbuf += UUID_BINSIZE;
1302 *rbuflen += UUID_BINSIZE;
1305 /* Shall we return group UUID ? */
1306 if (bitmap & kFileSec_GRPUUID) {
1307 LOG(log_debug, logtype_afpd, "afp_getacl: client requested files owner group UUID");
1308 if (NULL == (gr = getgrgid(s_path->st.st_gid)))
1310 LOG(log_debug, logtype_afpd, "afp_getacl: got gid: %d, name: %s", s_path->st.st_gid, gr->gr_name);
1311 if ((ret = getuuidfromname(gr->gr_name, UUID_GROUP, rbuf)) != 0)
1313 rbuf += UUID_BINSIZE;
1314 *rbuflen += UUID_BINSIZE;
1317 /* Shall we return ACL ? */
1318 if (bitmap & kFileSec_ACL) {
1319 LOG(log_debug, logtype_afpd, "afp_getacl: client requested files ACL");
1320 if (get_and_map_acl(s_path->u_name, rbuf, rbuflen) != 0) {
1321 LOG(log_error, logtype_afpd, "afp_getacl(\"%s/%s\"): mapping error",
1322 getcwdpath(), s_path->u_name);
1327 LOG(log_debug9, logtype_afpd, "afp_getacl: END");
1331 int afp_setacl(AFPObj *obj, char *ibuf, size_t ibuflen _U_, char *rbuf _U_, size_t *rbuflen)
1337 uint16_t vid, bitmap;
1338 struct path *s_path;
1340 LOG(log_debug9, logtype_afpd, "afp_setacl: BEGIN");
1344 memcpy(&vid, ibuf, sizeof( vid ));
1345 ibuf += sizeof(vid);
1346 if (NULL == ( vol = getvolbyvid( vid ))) {
1347 LOG(log_error, logtype_afpd, "afp_setacl: error getting volid:%d", vid);
1348 return AFPERR_NOOBJ;
1351 memcpy(&did, ibuf, sizeof( did ));
1352 ibuf += sizeof( did );
1353 if (NULL == ( dir = dirlookup( vol, did ))) {
1354 LOG(log_error, logtype_afpd, "afp_setacl: error getting did:%d", did);
1358 memcpy(&bitmap, ibuf, sizeof( bitmap ));
1359 bitmap = ntohs( bitmap );
1360 ibuf += sizeof( bitmap );
1362 /* get full path and handle file/dir subtleties in netatalk code*/
1363 if (NULL == ( s_path = cname( vol, dir, &ibuf ))) {
1364 LOG(log_error, logtype_afpd, "afp_setacl: cname got an error!");
1365 return AFPERR_NOOBJ;
1367 if (!s_path->st_valid)
1368 of_statdir(vol, s_path);
1369 if ( s_path->st_errno != 0 ) {
1370 LOG(log_error, logtype_afpd, "afp_setacl: cant stat");
1371 return AFPERR_NOOBJ;
1373 LOG(log_debug, logtype_afpd, "afp_setacl: unixname: %s", s_path->u_name);
1376 if ((unsigned long)ibuf & 1)
1379 /* Start processing request */
1381 /* Change owner: dont even try */
1382 if (bitmap & kFileSec_UUID) {
1383 LOG(log_note, logtype_afpd, "afp_setacl: change owner request, discarded");
1384 ret = AFPERR_ACCESS;
1385 ibuf += UUID_BINSIZE;
1388 /* Change group: certain changes might be allowed, so try it. FIXME: not implemented yet. */
1389 if (bitmap & kFileSec_UUID) {
1390 LOG(log_note, logtype_afpd, "afp_setacl: change group request, not supported");
1392 ibuf += UUID_BINSIZE;
1396 if (bitmap & kFileSec_REMOVEACL) {
1397 LOG(log_debug, logtype_afpd, "afp_setacl: Remove ACL request.");
1398 if ((ret = remove_acl(vol, s_path->u_name, S_ISDIR(s_path->st.st_mode))) != AFP_OK)
1399 LOG(log_error, logtype_afpd, "afp_setacl: error from remove_acl");
1403 if (bitmap & kFileSec_ACL) {
1404 LOG(log_debug, logtype_afpd, "afp_setacl: Change ACL request.");
1405 /* Get no of ACEs the client put on the wire */
1407 memcpy(&ace_count, ibuf, sizeof(uint32_t));
1408 ace_count = htonl(ace_count);
1409 ibuf += 8; /* skip ACL flags (see acls.h) */
1413 (bitmap & kFileSec_Inherit),
1414 (darwin_ace_t *)ibuf,
1419 LOG(log_warning, logtype_afpd, "afp_setacl(\"%s/%s\"): error",
1420 getcwdpath(), s_path->u_name);
1425 LOG(log_debug9, logtype_afpd, "afp_setacl: END");
1429 /********************************************************************
1430 * ACL funcs interfacing with other parts
1431 ********************************************************************/
1434 * map ACL to user maccess
1436 * This is the magic function that makes ACLs usable by calculating
1437 * the access granted by ACEs to the logged in user.
1439 int acltoownermode(char *path, struct stat *st, struct maccess *ma)
1442 uint32_t rights = 0;
1444 if ( ! (AFPobj->options.flags & OPTION_ACL2MACCESS)
1445 || (current_vol == NULL)
1446 || ! (current_vol->v_flags & AFPVOL_ACLS))
1449 LOG(log_maxdebug, logtype_afpd, "acltoownermode(\"%s/%s\", 0x%02x)",
1450 getcwdpath(), path, ma->ma_user);
1452 #ifdef HAVE_SOLARIS_ACLS
1453 EC_ZERO_LOG(solaris_acl_rights(path, st, &rights));
1455 #ifdef HAVE_POSIX_ACLS
1456 EC_ZERO_LOG(posix_acl_rights(path, st, &rights));
1459 LOG(log_maxdebug, logtype_afpd, "rights: 0x%08x", rights);
1461 if (rights & DARWIN_ACE_READ_DATA)
1462 ma->ma_user |= AR_UREAD;
1463 if (rights & DARWIN_ACE_WRITE_DATA)
1464 ma->ma_user |= AR_UWRITE;
1465 if (rights & (DARWIN_ACE_EXECUTE | DARWIN_ACE_SEARCH))
1466 ma->ma_user |= AR_USEARCH;
1468 LOG(log_maxdebug, logtype_afpd, "resulting user maccess: 0x%02x", ma->ma_user);
1475 * Check whether a volume supports ACLs
1477 * @param vol (r) volume
1479 * @returns 0 if not, 1 if yes
1481 int check_vol_acl_support(const struct vol *vol)
1485 #ifdef HAVE_SOLARIS_ACLS
1487 if (get_nfsv4_acl(vol->v_path, &aces) == -1)
1490 #ifdef HAVE_POSIX_ACLS
1492 if ((acl = acl_get_file(vol->v_path, ACL_TYPE_ACCESS)) == NULL)
1496 #ifdef HAVE_SOLARIS_ACLS
1497 if (aces) free(aces);
1499 #ifdef HAVE_POSIX_ACLS
1500 if (acl) acl_free(acl);
1501 #endif /* HAVE_POSIX_ACLS */
1503 LOG(log_debug, logtype_afpd, "Volume \"%s\" ACL support: %s",
1504 vol->v_path, ret ? "yes" : "no");