annotate lib/acl-internal.h @ 8476:2798cb65bd90

Add limited support for Solaris 10 ZFS-style ACLs: just enough to handle file_has_acl. * lib/acl-internal.h, lib/acl_entries.c, lib/file-has-acl.c: New files. * lib/acl.c: Move header inclusions and related macro defns into lib/acl-internal.h. (S_ISLNK): Remove defn, since that's now done for us. (file_has_acl): Move to lib/file-has-acl.c. Call acl_trivial if available. This is the crucial part of the fix. (acl_entries): Move to lib/acl_entries.c. Now extern, since it's shared within the library. Rewrite a bit, partly to make it compatible with the GNU coding style. * m4/acl.m4 (AC_FUNC_ACL): Add AC_LIBOBJ([file-has-acl]). Remove unnecessary double-quotes. Don't test for acl_to_text; the build will catch that. Replace acl_entries if it doesn't exist and it is needed. Check for -lsec and acl_trivial (as used on Solaris 10). * modules/acl (Files): Add lib/acl-internal.h, lib/acl_entries.c, lib/file-has-acl.c. (Depends-on): Add sys_stat, for S_ISLNK.
author Paul Eggert <eggert@cs.ucla.edu>
date Mon, 19 Mar 2007 21:58:57 +0000
parents
children 19b8b337ecaa
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
8476
2798cb65bd90 Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
1 /* Internal implementation of access control lists.
2798cb65bd90 Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
2
2798cb65bd90 Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
3 Copyright (C) 2002, 2003, 2005, 2006, 2007 Free Software Foundation, Inc.
2798cb65bd90 Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
4
2798cb65bd90 Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
5 This program is free software; you can redistribute it and/or modify
2798cb65bd90 Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
6 it under the terms of the GNU General Public License as published by
2798cb65bd90 Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
7 the Free Software Foundation; either version 2, or (at your option)
2798cb65bd90 Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
8 any later version.
2798cb65bd90 Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
9
2798cb65bd90 Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
10 This program is distributed in the hope that it will be useful,
2798cb65bd90 Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
2798cb65bd90 Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2798cb65bd90 Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
13 GNU General Public License for more details.
2798cb65bd90 Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
14
2798cb65bd90 Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
15 You should have received a copy of the GNU General Public License
2798cb65bd90 Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
16 along with this program; if not, write to the Free Software Foundation,
2798cb65bd90 Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
17 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
2798cb65bd90 Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
18
2798cb65bd90 Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
19 Written by Paul Eggert and Andreas Gruenbacher. */
2798cb65bd90 Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
20
2798cb65bd90 Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
21 #include <config.h>
2798cb65bd90 Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
22
2798cb65bd90 Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
23 #include "acl.h"
2798cb65bd90 Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
24
2798cb65bd90 Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
25 #include <stdbool.h>
2798cb65bd90 Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
26 #include <stdlib.h>
2798cb65bd90 Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
27
2798cb65bd90 Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
28 #ifdef HAVE_ACL_LIBACL_H
2798cb65bd90 Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
29 # include <acl/libacl.h>
2798cb65bd90 Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
30 #endif
2798cb65bd90 Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
31
2798cb65bd90 Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
32 #include "error.h"
2798cb65bd90 Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
33 #include "quote.h"
2798cb65bd90 Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
34
2798cb65bd90 Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
35 #include <errno.h>
2798cb65bd90 Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
36 #ifndef ENOSYS
2798cb65bd90 Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
37 # define ENOSYS (-1)
2798cb65bd90 Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
38 #endif
2798cb65bd90 Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
39 #ifndef ENOTSUP
2798cb65bd90 Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
40 # define ENOTSUP (-1)
2798cb65bd90 Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
41 #endif
2798cb65bd90 Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
42
2798cb65bd90 Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
43 #if ENABLE_NLS
2798cb65bd90 Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
44 # include <libintl.h>
2798cb65bd90 Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
45 # define _(Text) gettext (Text)
2798cb65bd90 Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
46 #else
2798cb65bd90 Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
47 # define _(Text) Text
2798cb65bd90 Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
48 #endif
2798cb65bd90 Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
49
2798cb65bd90 Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
50 #ifndef HAVE_FCHMOD
2798cb65bd90 Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
51 # define HAVE_FCHMOD false
2798cb65bd90 Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
52 # define fchmod(fd, mode) (-1)
2798cb65bd90 Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
53 #endif
2798cb65bd90 Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
54
2798cb65bd90 Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
55 #ifndef MIN_ACL_ENTRIES
2798cb65bd90 Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
56 # define MIN_ACL_ENTRIES 4
2798cb65bd90 Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
57 #endif
2798cb65bd90 Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
58
2798cb65bd90 Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
59 /* POSIX 1003.1e (draft 17) */
2798cb65bd90 Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
60 #ifndef HAVE_ACL_GET_FD
2798cb65bd90 Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
61 # define HAVE_ACL_GET_FD false
2798cb65bd90 Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
62 # define acl_get_fd(fd) (NULL)
2798cb65bd90 Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
63 #endif
2798cb65bd90 Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
64
2798cb65bd90 Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
65 /* POSIX 1003.1e (draft 17) */
2798cb65bd90 Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
66 #ifndef HAVE_ACL_SET_FD
2798cb65bd90 Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
67 # define HAVE_ACL_SET_FD false
2798cb65bd90 Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
68 # define acl_set_fd(fd, acl) (-1)
2798cb65bd90 Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
69 #endif
2798cb65bd90 Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
70
2798cb65bd90 Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
71 /* Linux-specific */
2798cb65bd90 Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
72 #ifndef HAVE_ACL_EXTENDED_FILE
2798cb65bd90 Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
73 # define HAVE_ACL_EXTENDED_FILE false
2798cb65bd90 Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
74 # define acl_extended_file(name) (-1)
2798cb65bd90 Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
75 #endif
2798cb65bd90 Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
76
2798cb65bd90 Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
77 /* Linux-specific */
2798cb65bd90 Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
78 #ifndef HAVE_ACL_FROM_MODE
2798cb65bd90 Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
79 # define HAVE_ACL_FROM_MODE false
2798cb65bd90 Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
80 # define acl_from_mode(mode) (NULL)
2798cb65bd90 Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
81 #endif
2798cb65bd90 Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
82
2798cb65bd90 Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
83 #define ACL_NOT_WELL_SUPPORTED(Errno) \
2798cb65bd90 Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
84 (Errno == ENOTSUP || Errno == ENOSYS || Errno == EINVAL)
2798cb65bd90 Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
85
2798cb65bd90 Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
86 /* Define a replacement for acl_entries if needed. */
2798cb65bd90 Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
87 #if USE_ACL && HAVE_ACL_GET_FILE && HAVE_ACL_FREE && !HAVE_ACL_ENTRIES
2798cb65bd90 Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
88 # define acl_entries rpl_acl_entries
2798cb65bd90 Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
89 int acl_entries (acl_t);
2798cb65bd90 Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
90 #endif