2 File: __apply_mask_to_mode.c
3 (Linux Access Control List Management)
5 Copyright (C) 1999-2002
6 Andreas Gruenbacher, <a.gruenbacher@bestbits.at>
8 This program is free software; you can redistribute it and/or
9 modify it under the terms of the GNU Lesser General Public
10 License as published by the Free Software Foundation; either
11 version 2.1 of the License, or (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Lesser General Public License for more details.
18 You should have received a copy of the GNU Lesser General Public
19 License along with this library; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 #include <acl/libacl.h>
27 #if defined(HAVE_ACL_ENTRIES) && \
28 defined (HAVE_ACL_GET_ENTRY) && defined(HAVE_ACL_GET_TAG_TYPE) && \
29 defined (HAVE_ACL_GET_PERMSET) && defined(HAVE_ACL_GET_PERM)
31 __apply_mask_to_mode(mode_t *mode, acl_t acl)
34 int entry_id=ACL_FIRST_ENTRY;
36 /* A mimimal ACL which has three entries has no mask entry; the
37 group file mode permission bits are exact. */
38 if (acl_entries(acl) == 3)
41 while (acl_get_entry(acl, entry_id, &entry) == 1) {
44 acl_get_tag_type(entry, &tag_type);
45 if (tag_type == ACL_MASK) {
46 acl_permset_t permset;
48 acl_get_permset(entry, &permset);
49 if (acl_get_perm(permset, ACL_READ) != 1)
51 if (acl_get_perm(permset, ACL_WRITE) != 1)
53 if (acl_get_perm(permset, ACL_EXECUTE) != 1)
58 entry_id = ACL_NEXT_ENTRY;
61 /* This is unexpected; if the ACL didn't include a mask entry
62 we should have exited before the loop! */