This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Cannot exec() program outside of /bin if PATH is unset


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]