kern/169651: fexecve() and hashbang-scripts
Peter Wullinger
bsd at dhke.de
Wed Jul 4 20:50:04 UTC 2012
>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 at 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:
More information about the freebsd-bugs
mailing list