Date: Wed, 4 Jul 2012 22:43:54 +0200 (CEST) From: Peter Wullinger <bsd@dhke.de> To: FreeBSD-gnats-submit@FreeBSD.org Subject: kern/169651: fexecve() and hashbang-scripts Message-ID: <20120704204354.7F33CA3@kaliope.home> Resent-Message-ID: <201207042050.q64Ko4FY012693@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 169651 >Category: kern >Synopsis: fexecve() and hashbang-scripts >Confidential: no >Severity: non-critical >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Wed Jul 04 20:50:04 UTC 2012 >Closed-Date: >Last-Modified: >Originator: Peter Wullinger >Release: FreeBSD 9.0-STABLE amd64 >Organization: >Environment: System: FreeBSD kaliope 9.0-STABLE FreeBSD 9.0-STABLE #13 r237164: Sat Jun 16 18:31:08 CEST 2012 src@kaliope:/usr/obj/usr/src/sys/KALIOPE_MONO amd64 >Description: The fexecve() does not seem to work as described. I was able identify to cases 1) opening the file descriptor passwd to fexecve() with O_EXEC does not work. (see test case 1), below. 2) passing a readonly file descriptor to fexecve() with the target file being an interpreted script with a #! marker causes error message cannot open /dev/fd/n: No such file or directory to be raised from the target interpreter. >How-To-Repeat: Test case 1) extern char **environ; int main(int argc, char *argv[]) { int fd = open("/bin/ls" , O_EXEC); fexecve(fd, argv, environ); perror("fexecve"); } Yields fexecve: Bad file descriptor Changing O_EXEC to O_RDONLY works. Test case 2) extern char **environ; int main(int argc, char *argv[]) { int fd = open("/usr/bin/man" , O_RDONLY); fexecve(fd, argv, environ); perror("fexecve"); } Yields: cannot open /dev/fd/3: No such file or directory (/usr/bin/man is a shell script) >Fix: no fix known yet. >Release-Note: >Audit-Trail: >Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20120704204354.7F33CA3>