delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2014/09/12/13:02:44

X-Recipient: archive-cygwin AT delorie DOT com
DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:message-id:date:from:mime-version:to:subject
:content-type:content-transfer-encoding; q=dns; s=default; b=dl2
jpdABccYvP5kRPxbw81c8Qs7qFEVGUHfRnhSGC15A+QNrcBgWEIUgPwRW2JKMdSK
rmikhRBEBeDYR8nuygUd+Z9WQH4puxnFzkwugMVhJpNcIjBTjVnviqrMMbGAXPmX
F6D3GOJv3v1KvIJxmSZitmRUByI1vlDcoziUteAY=
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:message-id:date:from:mime-version:to:subject
:content-type:content-transfer-encoding; s=default; bh=WR9Joctin
KQC2THYITDQGayTm8g=; b=g/kTuMnsHjUx1qw33hX/ng7LQ9J2wgaJ2BOjxpjFg
P2bWwNdjDL9co9bV5QP2UHWrw4gY1yfqLuiwHVO1At8JhZUc+0a/7MAjm6DM/VSS
iFsemv5aQzGB6RFHEKDGzBoS6yMXzzcNSidUmxjcANs9HlJULzar7gvuEWxRHiqb
JQ=
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Authentication-Results: sourceware.org; auth=none
X-Virus-Found: No
X-Spam-SWARE-Status: No, score=-1.4 required=5.0 tests=AWL,BAYES_50,RCVD_IN_DNSWL_NONE,RP_MATCHES_RCVD autolearn=ham version=3.3.2
X-HELO: mailout05.t-online.de
Message-ID: <5413271B.1010109@t-online.de>
Date: Fri, 12 Sep 2014 19:02:19 +0200
From: Christian Franke <Christian DOT Franke AT t-online DOT de>
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:29.0) Gecko/20100101 Firefox/29.0 SeaMonkey/2.26.1
MIME-Version: 1.0
To: cygwin AT cygwin DOT com
Subject: Cannot exec() program outside of /bin if PATH is unset
X-IsSubscribed: yes

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

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019