1/* Internal implementation of access control lists. 2 3 Copyright (C) 2002, 2003, 2005, 2006, 2007 Free Software Foundation, Inc. 4 5 This program is free software: you can redistribute it and/or modify 6 it under the terms of the GNU General Public License as published by 7 the Free Software Foundation; either version 3 of the License, or 8 (at your option) any later version. 9 10 This program is distributed in the hope that it will be useful, 11 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 GNU General Public License for more details. 14 15 You should have received a copy of the GNU General Public License 16 along with this program. If not, see <http://www.gnu.org/licenses/>. 17 18 Written by Paul Eggert and Andreas Gruenbacher. */ 19 20#include "acl.h" 21 22#include <stdbool.h> 23#include <stdlib.h> 24 25#ifdef HAVE_ACL_LIBACL_H 26# include <acl/libacl.h> 27#endif 28 29#include "error.h" 30#include "quote.h" 31 32#include <errno.h> 33#ifndef ENOSYS 34# define ENOSYS (-1) 35#endif 36#ifndef ENOTSUP 37# define ENOTSUP (-1) 38#endif 39 40#include "gettext.h" 41#define _(msgid) gettext (msgid) 42 43#ifndef HAVE_FCHMOD 44# define HAVE_FCHMOD false 45# define fchmod(fd, mode) (-1) 46#endif 47 48#ifndef MIN_ACL_ENTRIES 49# define MIN_ACL_ENTRIES 4 50#endif 51 52/* POSIX 1003.1e (draft 17) */ 53#ifndef HAVE_ACL_GET_FD 54# define HAVE_ACL_GET_FD false 55# undef acl_get_fd 56# define acl_get_fd(fd) (NULL) 57#endif 58 59/* POSIX 1003.1e (draft 17) */ 60#ifndef HAVE_ACL_SET_FD 61# define HAVE_ACL_SET_FD false 62# undef acl_set_fd 63# define acl_set_fd(fd, acl) (-1) 64#endif 65 66/* Linux-specific */ 67#ifndef HAVE_ACL_EXTENDED_FILE 68# define HAVE_ACL_EXTENDED_FILE false 69# define acl_extended_file(name) (-1) 70#endif 71 72/* Linux-specific */ 73#ifndef HAVE_ACL_FROM_MODE 74# define HAVE_ACL_FROM_MODE false 75# define acl_from_mode(mode) (NULL) 76#endif 77 78#define ACL_NOT_WELL_SUPPORTED(Err) \ 79 ((Err) == ENOTSUP || (Err) == ENOSYS || (Err) == EINVAL || (Err) == EBUSY) 80 81/* Define a replacement for acl_entries if needed. */ 82#if USE_ACL && HAVE_ACL_GET_FILE && HAVE_ACL_FREE && !HAVE_ACL_ENTRIES 83# define acl_entries rpl_acl_entries 84int acl_entries (acl_t); 85#endif 86