summaryrefslogtreecommitdiffstats
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
parent4b8669f968aae6dc0267c8d46ef265432c681b46 (diff)
downloadbfs-f133d71fc49a6ae2ddd64c73e630227e1e7a9ba5.tar.xz
fsade: Implement ACL detection on Illumos
-rw-r--r--config/acl-is-trivial-np.c1
-rw-r--r--config/acl-trivial.c8
-rw-r--r--config/flags.mk2
-rw-r--r--config/header.mk1
-rw-r--r--src/fsade.c31
-rw-r--r--src/fsade.h2
6 files changed, 32 insertions, 13 deletions
diff --git a/config/acl-is-trivial-np.c b/config/acl-is-trivial-np.c
index 4178238..9ca9fc7 100644
--- a/config/acl-is-trivial-np.c
+++ b/config/acl-is-trivial-np.c
@@ -1,6 +1,7 @@
// Copyright © Tavian Barnes <tavianator@tavianator.com>
// SPDX-License-Identifier: 0BSD
+#include <sys/types.h>
#include <sys/acl.h>
int main(void) {
diff --git a/config/acl-trivial.c b/config/acl-trivial.c
new file mode 100644
index 0000000..7efc838
--- /dev/null
+++ b/config/acl-trivial.c
@@ -0,0 +1,8 @@
+// Copyright © Tavian Barnes <tavianator@tavianator.com>
+// SPDX-License-Identifier: 0BSD
+
+#include <sys/acl.h>
+
+int main(void) {
+ return acl_trivial(".");
+}
diff --git a/config/flags.mk b/config/flags.mk
index 8a2e50e..ee13f06 100644
--- a/config/flags.mk
+++ b/config/flags.mk
@@ -45,7 +45,7 @@ export BFS_CFLAGS= -std=c17 -pthread
LDLIBS,DragonFly := -lposix1e
LDLIBS,Linux := -lrt
LDLIBS,NetBSD := -lutil
-LDLIBS,SunOS := -lsocket -lnsl
+LDLIBS,SunOS := -lsec -lsocket -lnsl
export BFS_LDLIBS=${LDLIBS,${OS}}
# Build profiles
diff --git a/config/header.mk b/config/header.mk
index 5da0629..7fd2f78 100644
--- a/config/header.mk
+++ b/config/header.mk
@@ -13,6 +13,7 @@ HEADERS := \
${GEN}/acl-get-file.h \
${GEN}/acl-get-tag-type.h \
${GEN}/acl-is-trivial-np.h \
+ ${GEN}/acl-trivial.h \
${GEN}/aligned-alloc.h \
${GEN}/confstr.h \
${GEN}/extattr-get-file.h \
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