Cannot exec() program outside of /bin if PATH is unset
Christian Franke
Christian.Franke@t-online.de
Fri Sep 12 18:02:00 GMT 2014
If PATH variable is unset or does not contain /bin or /usr/bin,
exec("/not_bin/program", ...) fails because cygwin DLLs could not be loaded.
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
ITP)
Testcase:
$ cat nopath.cc
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
// #include <windows.h>
int main()
{
unsetenv("PATH");
// SetDllDirectory("c:\\cygwin\\bin");
execl("/usr/sbin/alternatives", "alternatives", (const char*)0);
perror("execl");
return 1;
}
$ make nopath
...
$ ./nopath
/usr/sbin/alternatives.exe: error while loading shared libraries: ?:
cannot open shared object file: No such file or directory
Enabling the SetDllDirectory() Win32 call fixes the problem.
Would possibly make sense to add this call to cygwin1.dll.
Christian
--
Problem reports: http://cygwin.com/problems.html
FAQ: http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
More information about the Cygwin
mailing list