This is the mail archive of the
mailing list for the Cygwin project.
Re: Cannot exec() program outside of /bin if PATH is unset
- From: David Boyce <dsb at boyski dot com>
- To: cygwin at cygwin dot com
- Date: Fri, 12 Sep 2014 23:21:06 -0400
- Subject: Re: Cannot exec() program outside of /bin if PATH is unset
- Authentication-results: sourceware.org; auth=none
- References: <5413271B dot 1010109 at t-online dot de> <54134A83 dot 80107 at redhat dot com> <54135451 dot 3060902 at t-online dot de> <54137295 dot 4070304 at redhat dot com>
On Fri, Sep 12, 2014 at 6:24 PM, Eric Blake <email@example.com> wrote:
> On 09/12/2014 02:15 PM, Christian Franke wrote:
>>> This is undefined behavior, per POSIX. POSIX recommends that you always
>>> leave PATH defined to at least a bare minimum of the results of
>>> confstr(_CS_PATH, ...); it also states that implementations are free to
>>> do what they want (in this case, crash) if you don't follow the
>>> "If PATH is unset or is set to null, the path search is
>> There is no POSIX PATH search needed in my testcase:
>> execl("/usr/sbin/alternatives", ...)
> PATH may not be needed for execl() to find the binary it will be
> executing, but it IS required to be set in the environment to the bare
> minimum of confstr(_CS_PATH) for that binary to have a chance of
> executing in a well-defined setup.
I think your interpretation is wrong. The line you quote from POSIX
refers to a "path search" but there is no path search happening here.
The concept of path search is implicitly defined by the first line in
"PATH: This variable shall represent the sequence of path prefixes
that certain functions and utilities apply in searching for an
executable file known only by a filename."
Notice the way this sentence ends. The argument to execl() is a full
path, not "only a filename", thus no PATH search is involved. I agree
that unsetting PATH is not ideal practice but I think it's perfectly
well defined by POSIX.
Problem reports: http://cygwin.com/problems.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple