Date: Tue, 28 Apr 2026 19:13:38 +0000 From: bugzilla-noreply@freebsd.org To: bugs@FreeBSD.org Subject: [Bug 294780] fexecve(2) only works for scripts if /dev/fd is mounted with the non-default nodup option. Message-ID: <bug-294780-227-AB1ps8L575@https.bugs.freebsd.org/bugzilla/> In-Reply-To: <bug-294780-227@https.bugs.freebsd.org/bugzilla/>
index | next in thread | previous in thread | raw e-mail
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=294780 --- Comment #2 from Jan Bramkamp <crest@bultmann.eu> --- I wanted to avoid reresolving the name, by opening it once for reading, then reopening it for execution with O_EMPTY_PATH. This works if and only if /dev/fd is mounted with the non-default "nodup" option. In this configuration the descriptor gets reopened both my code with O_EXEC and later by the interpreter as O_RDONLY. Next I wanted to make my code work with the default /dev/fd mounted without any options (other than "rw"). For any interpreter to be able to run a script it needs to read it (which doesn't count as execution), but to launch the script with fexecve() the descriptor needs to be executable. For fexecve() to be usable with scripts **at all** and the default mount option a single file descriptor has to have both read and execute capability. For now I accepted the mostly theoretical race condition and use execve(2) instead of fexecve(2). Still the fexecve(2) system call should support running scripts just like execve(2). If not this limitation must be clearly documented to safe future would be users from wasting time debugging this problem again. -- You are receiving this mail because: You are the assignee for the bug.home | help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-294780-227-AB1ps8L575>
