Mercurial > hg > octave-shane > gnulib-hg
comparison lib/file-has-acl.c @ 10177:caed32fb1892
New function acl_extended_nontrivial (MacOS X only).
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Sun, 08 Jun 2008 13:58:26 +0200 |
parents | ed86dd8c386e |
children | 90f51b86b088 |
comparison
equal
deleted
inserted
replaced
10176:43bafd6ea0d8 | 10177:caed32fb1892 |
---|---|
23 | 23 |
24 #include "acl-internal.h" | 24 #include "acl-internal.h" |
25 | 25 |
26 | 26 |
27 #if USE_ACL && HAVE_ACL_GET_FILE | 27 #if USE_ACL && HAVE_ACL_GET_FILE |
28 | |
29 # if HAVE_ACL_TYPE_EXTENDED /* MacOS X */ | |
30 | |
31 /* ACL is an ACL, from a file, stored as type ACL_TYPE_EXTENDED. | |
32 Return 1 if the given ACL is non-trivial. | |
33 Return 0 if it is trivial. */ | |
34 int | |
35 acl_extended_nontrivial (acl_t acl) | |
36 { | |
37 /* acl is non-trivial if it is non-empty. */ | |
38 return (acl_entries (acl) > 0); | |
39 } | |
40 | |
41 # else /* Linux, FreeBSD, IRIX, Tru64 */ | |
28 | 42 |
29 /* ACL is an ACL, from a file, stored as type ACL_TYPE_ACCESS. | 43 /* ACL is an ACL, from a file, stored as type ACL_TYPE_ACCESS. |
30 Return 1 if the given ACL is non-trivial. | 44 Return 1 if the given ACL is non-trivial. |
31 Return 0 if it is trivial, i.e. equivalent to a simple stat() mode. | 45 Return 0 if it is trivial, i.e. equivalent to a simple stat() mode. |
32 Return -1 and set errno upon failure to determine it. */ | 46 Return -1 and set errno upon failure to determine it. */ |
33 int | 47 int |
34 acl_access_nontrivial (acl_t acl) | 48 acl_access_nontrivial (acl_t acl) |
35 { | 49 { |
36 # if MODE_INSIDE_ACL /* Linux, FreeBSD, IRIX, Tru64 */ | |
37 /* acl is non-trivial if it has some entries other than for "user::", | 50 /* acl is non-trivial if it has some entries other than for "user::", |
38 "group::", and "other::". Normally these three should be present | 51 "group::", and "other::". Normally these three should be present |
39 at least, allowing us to write | 52 at least, allowing us to write |
40 return (3 < acl_entries (acl)); | 53 return (3 < acl_entries (acl)); |
41 but the following code is more robust. */ | 54 but the following code is more robust. */ |
98 } | 111 } |
99 return 0; | 112 return 0; |
100 | 113 |
101 # endif | 114 # endif |
102 # endif | 115 # endif |
103 # else /* MacOS X */ | 116 } |
104 | 117 |
105 /* acl is non-trivial if it is non-empty. */ | |
106 return (acl_entries (acl) > 0); | |
107 # endif | 118 # endif |
108 } | |
109 | 119 |
110 #endif | 120 #endif |
111 | 121 |
112 | 122 |
113 /* Return 1 if NAME has a nontrivial access control list, 0 if NAME | 123 /* Return 1 if NAME has a nontrivial access control list, 0 if NAME |
142 these two useless calls. The real ACL is retrieved through | 152 these two useless calls. The real ACL is retrieved through |
143 acl_get_file (name, ACL_TYPE_EXTENDED). */ | 153 acl_get_file (name, ACL_TYPE_EXTENDED). */ |
144 acl_t acl = acl_get_file (name, ACL_TYPE_EXTENDED); | 154 acl_t acl = acl_get_file (name, ACL_TYPE_EXTENDED); |
145 if (acl) | 155 if (acl) |
146 { | 156 { |
147 ret = (0 < acl_entries (acl)); | 157 ret = acl_extended_nontrivial (acl); |
148 acl_free (acl); | 158 acl_free (acl); |
149 } | 159 } |
150 else | 160 else |
151 ret = -1; | 161 ret = -1; |
152 # else /* FreeBSD, IRIX, Tru64 */ | 162 # else /* FreeBSD, IRIX, Tru64 */ |