summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2024-04-22 11:00:37 -0400
committerTavian Barnes <tavianator@tavianator.com>2024-04-22 11:19:20 -0400
commitf133d71fc49a6ae2ddd64c73e630227e1e7a9ba5 (patch)
treef871b62fb10251f72b43534ff38e310a9df32162 /src
parent4b8669f968aae6dc0267c8d46ef265432c681b46 (diff)
downloadbfs-f133d71fc49a6ae2ddd64c73e630227e1e7a9ba5.tar.xz
fsade: Implement ACL detection on Illumos
Diffstat (limited to 'src')
-rw-r--r--src/fsade.c31
-rw-r--r--src/fsade.h2
2 files changed, 21 insertions, 12 deletions
diff --git a/src/fsade.c b/src/fsade.c
index dac2ca6..d56fb07 100644
--- a/src/fsade.c
+++ b/src/fsade.c
@@ -121,6 +121,8 @@ static bool is_absence_error(int error) {
#if BFS_CAN_CHECK_ACL
+#if BFS_HAS_ACL_GET_FILE
+
/** Unified interface for incompatible acl_get_entry() implementations. */
static int bfs_acl_entry(acl_t acl, int which, acl_entry_t *entry) {
#if BFS_HAS_ACL_GET_ENTRY
@@ -226,29 +228,35 @@ static int bfs_check_acl_type(acl_t acl, acl_type_t type) {
#endif
}
+#endif // BFS_HAS_ACL_GET_FILE
+
int bfs_check_acl(const struct BFTW *ftwbuf) {
+ if (ftwbuf->type == BFS_LNK) {
+ return 0;
+ }
+
+ const char *path = fake_at(ftwbuf);
+
+#if BFS_HAS_ACL_TRIVIAL
+ int ret = acl_trivial(path);
+ int error = errno;
+#elif BFS_HAS_ACL_GET_FILE
static const acl_type_t acl_types[] = {
-#if __APPLE__
+# if __APPLE__
// macOS gives EINVAL for either of the two standard ACL types,
// supporting only ACL_TYPE_EXTENDED
ACL_TYPE_EXTENDED,
-#else
+# else
// The two standard POSIX.1e ACL types
ACL_TYPE_ACCESS,
ACL_TYPE_DEFAULT,
-#endif
+# endif
-#ifdef ACL_TYPE_NFS4
+# ifdef ACL_TYPE_NFS4
ACL_TYPE_NFS4,
-#endif
+# endif
};
- if (ftwbuf->type == BFS_LNK) {
- return 0;
- }
-
- const char *path = fake_at(ftwbuf);
-
int ret = -1, error = 0;
for (size_t i = 0; i < countof(acl_types) && ret <= 0; ++i) {
acl_type_t type = acl_types[i];
@@ -272,6 +280,7 @@ int bfs_check_acl(const struct BFTW *ftwbuf) {
error = errno;
acl_free(acl);
}
+#endif
free_fake_at(ftwbuf, path);
errno = error;
diff --git a/src/fsade.h b/src/fsade.h
index fc0809e..eefef9f 100644
--- a/src/fsade.h
+++ b/src/fsade.h
@@ -11,7 +11,7 @@
#include "prelude.h"
-#define BFS_CAN_CHECK_ACL BFS_HAS_ACL_GET_FILE
+#define BFS_CAN_CHECK_ACL (BFS_HAS_ACL_GET_FILE || BFS_HAS_ACL_TRIVIAL)
#define BFS_CAN_CHECK_CAPABILITIES BFS_USE_LIBCAP