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: Christian Franke <Christian dot Franke at t-online dot de>
- To: cygwin at cygwin dot com
- Date: Fri, 12 Sep 2014 22:15:13 +0200
- 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>
Eric Blake wrote:
On 09/12/2014 11:02 AM, Christian Franke wrote:
If PATH variable is unset or does not contain /bin or /usr/bin,
exec("/not_bin/program", ...) fails because cygwin DLLs could not be
This affects postfix which cleans the environment to the bare minimum
for security reasons.
(fortunately there is an easy workaround, so this does not block postfix
$ cat nopath.cc
// #include <windows.h>
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:
The alternatives.exe could be found. The required DLLs could not be loaded.
POSIX does not specify anything about the load path of shared libraries.
On Linux, LD_LIBRARY_PATH is completely separate from PATH.
On Windows, the DLL load path is connected to PATH.
Enabling the SetDllDirectory() Win32 call fixes the problem.
Would possibly make sense to add this call to cygwin1.dll.
That said, just because POSIX has already given us the
get-out-of-jail-free card doesn't mean that we can't be nice and improve
cygwin1.dll to try and help broken programs that unset PATH.
Hmm... is postfix actually broken?
Unsetting PATH is IMO sane (from the POSIX POV) if all exec() calls use
absolute path names.
Problem reports: http://cygwin.com/problems.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple