public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* Cannot exec() program outside of /bin if PATH is unset
@ 2014-09-12 18:02 Christian Franke
  2014-09-12 19:39 ` Eric Blake
  0 siblings, 1 reply; 33+ messages in thread
From: Christian Franke @ 2014-09-12 18:02 UTC (permalink / raw)
  To: cygwin

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

^ permalink raw reply	[flat|nested] 33+ messages in thread

end of thread, other threads:[~2014-10-17 20:36 UTC | newest]

Thread overview: 33+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-09-12 18:02 Cannot exec() program outside of /bin if PATH is unset Christian Franke
2014-09-12 19:39 ` Eric Blake
2014-09-12 21:14   ` Christian Franke
2014-09-12 21:56     ` Andrey Repin
2014-09-12 23:04       ` Christian Franke
2014-09-12 23:06         ` Eric Blake
2014-09-12 23:13           ` Eric Blake
2014-09-13 16:17             ` Christian Franke
2014-09-15  7:47               ` Peter Rosin
2014-09-15  9:28                 ` Peter Rosin
2014-09-15 17:16                 ` Christian Franke
2014-10-08 13:41                   ` Corinna Vinschen
2014-10-08 17:16                     ` Christian Franke
2014-10-09 10:03                       ` Corinna Vinschen
2014-10-09 14:25                         ` Eric Blake
2014-10-09 16:29                           ` Corinna Vinschen
2014-10-09 16:34                             ` tednolan
2014-10-10 10:34                               ` Corinna Vinschen
2014-10-10 11:24                                 ` Jan Nijtmans
2014-10-10 11:32                                   ` Arjen Markus
2014-10-10 12:10                                     ` tednolan
2014-10-10 12:13                                       ` Arjen Markus
2014-10-10 15:39                                         ` Corinna Vinschen
2014-10-14 19:30                                           ` Corinna Vinschen
2014-10-16 21:51                                             ` Christian Franke
2014-10-17  9:10                                               ` Corinna Vinschen
2014-10-17 14:51                                                 ` Corinna Vinschen
2014-10-17 17:56                                                   ` Christian Franke
2014-10-17 18:20                                                     ` Corinna Vinschen
2014-10-17 20:36                                                       ` Csaba Raduly
2014-09-12 22:50     ` Eric Blake
2014-09-13  5:24       ` David Boyce
2014-09-14  9:40   ` Csaba Raduly

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).