| www.delorie.com/archives/browse.cgi | search |
| 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 | |
| :references:in-reply-to:content-type:content-transfer-encoding; | |
| q=dns; s=default; b=RkwvR+VIHxEnX3AJcBDr84N9bzACTM9ZykAtSq0qOqd | |
| gTJEe0W4LtQYfu38ykrFh/w2cnFK3CjLGJuYP3mz9r4XCmYyf8sSY0TwCvyL9ZBe | |
| JaB3TF6Fg/WoV8Q5HPp3iwIU+778tUbR5CcTJyH9OMQaWFdSwUI2H85EiFQc16U0 | |
| = | |
| 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 | |
| :references:in-reply-to:content-type:content-transfer-encoding; | |
| s=default; bh=WCLYC01R8yC4Mf3VeKdNljdPhEY=; b=MYf+mCKkFx/AXJHT+ | |
| j4ibGiJBkNGhSXKKMNTmEWy8UVQZh5bbFusUe3GGkQRFLvZppXYTgv4Eq5BpTxZn | |
| laVxdmJ3Q62bDHCy2XTI3IQtWzvd6rp19BSQBqjyr1/phddUHyPvxVquMoCG5Zxy | |
| UjGy3JXjEV8XZ8ultgwIBuUBzQ= | |
| 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=-2.7 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_NONE,RP_MATCHES_RCVD autolearn=ham version=3.3.2 |
| X-HELO: | mailout09.t-online.de |
| Message-ID: | <54135451.3060902@t-online.de> |
| Date: | Fri, 12 Sep 2014 22:15:13 +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: | Re: Cannot exec() program outside of /bin if PATH is unset |
| References: | <5413271B DOT 1010109 AT t-online DOT de> <54134A83 DOT 80107 AT redhat DOT com> |
| In-Reply-To: | <54134A83.80107@redhat.com> |
| X-IsSubscribed: | yes |
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
>> 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");
> 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
> recommendation:
>
> http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap08.html
> "If PATH is unset or is set to null, the path search is
> implementation-defined."
There is no POSIX PATH search needed in my testcase:
execl("/usr/sbin/alternatives", ...)
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.
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
| webmaster | delorie software privacy |
| Copyright © 2019 by DJ Delorie | Updated Jul 2019 |