From 34103b65ecdff04eeaaf2ac1d523b3d8e0d92ebe Mon Sep 17 00:00:00 2001 From: Andrea Mazzoleni Date: Thu, 11 Jun 2026 23:26:44 +0200 Subject: [PATCH] Allow tools to be symlinks and hardlinks --- cmdline/unix.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/cmdline/unix.c b/cmdline/unix.c index 262b3691..4039eff5 100644 --- a/cmdline/unix.c +++ b/cmdline/unix.c @@ -102,8 +102,6 @@ void os_signal_init(void) * be group-writable by a group other than the daemon's real/effective GID. * - The file must be a regular file with at least one execute bit set. * - The setuid and setgid bits must not be set. - * - The file must not have more than one hard link, to prevent an attacker - * from linking a controlled file into a trusted directory. * - On systems with fexecve(2) support, the returned fd is opened without * O_CLOEXEC so it can be passed directly to fexecve(2). On other systems * O_CLOEXEC is set and execve(2) must be used with @resolved_path. @@ -195,9 +193,8 @@ 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_FEXECVE | O_CLOEXEC /* with fexecve cannot use O_CLOEXEC (Close on Exec) */ #endif @@ -259,13 +256,6 @@ static int verify_executable(const char* exec_path, char* resolved_path) return -1; } - /* verify the file has not been hardlinked multiple times */ - if (st.st_nlink > 1) { - log_error(EINVAL, "File %s has multiple hard links", resolved_path); - close(fd); - return -1; - } - return fd; }