From 39522d06d9df2f9a55e9178137300bb37191ffdb Mon Sep 17 00:00:00 2001 From: Andrea Mazzoleni Date: Sat, 16 May 2026 16:55:53 +0200 Subject: [PATCH] Add new build option to allow symlinks --- HISTORY | 2 ++ cmdline/unix.c | 5 ++++- configure.ac | 9 +++++++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/HISTORY b/HISTORY index 8b443aa3..e9111c6f 100644 --- a/HISTORY +++ b/HISTORY @@ -34,6 +34,8 @@ SnapRAID HISTORY build time. When not specified, the existing runtime discovery behaviour is preserved. Primarily intended for NixOS and other non-FHS systems. + * Added --enable-symlink-tools configure option to allow the validation + logic to accept symbolic links for the specified --with-* paths. 14.6 2026/06 ============ diff --git a/cmdline/unix.c b/cmdline/unix.c index ebf69ee1..0bd2c34d 100644 --- a/cmdline/unix.c +++ b/cmdline/unix.c @@ -198,7 +198,10 @@ static int verify_executable(const char* exec_path, char* resolved_path) * Open the executable * O_NOFOLLOW prevents following symlinks to mitigate redirection attacks */ - int fd = openat(dir_fd, exec_name, O_RDONLY | O_NOFOLLOW + int fd = openat(dir_fd, exec_name, O_RDONLY +#if !HAVE_SYMLINK_TOOLS + | O_NOFOLLOW +#endif #if !HAVE_FEXECVE | O_CLOEXEC /* with fexecve cannot use O_CLOEXEC (Close on Exec) */ #endif diff --git a/configure.ac b/configure.ac index 946f9cee..47a0a33b 100644 --- a/configure.ac +++ b/configure.ac @@ -498,6 +498,15 @@ WITH_TOOL([zfs], [zfs], [ZFS pool management]) WITH_TOOL([zpool], [zpool], [ZFS pool status]) WITH_TOOL([bcachefs], [bcachefs], [Bcachefs management]) +# Enable support for symlinked tool paths +AC_ARG_ENABLE([symlink-tools], + [AS_HELP_STRING([--enable-symlink-tools], [allow paths specified with --with-* options to be symbolic links])], + [ + AS_IF([test "x$enableval" = "xyes"], [ + AC_DEFINE([HAVE_SYMLINK_TOOLS], [1], [Define to 1 if paths specified with --with-* options are allowed to be symlinks.]) + ]) + ]) + AC_ARG_VAR([TESTENV], [Test environment]) AC_ARG_VAR([FAILENV], [Test environment for failing tests]) AC_ARG_VAR([TESTENV_SSE2], [Test environment for SSE2])