delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2014/09/12/15:33:40

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; q=dns; s=default; b=RQ9sGh
LBVn2U4bi0cfPQ0r8W5YEhBLNUKzJqFzjNl82IgcEtFSDtrhkODqZpoTu3HWZaUC
m0+5IIwM19diE+nxmgUkRQc/0mOYinC4/HUacjHu+aK//R/hmnxeOFhYYVvMbh+Z
7RIZqwhhrJwHqug4c/iTeLI0hf7UR6Rhzy9WQ=
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; s=default; bh=jv6x/Qv+B7WV
YEHaSYOFEKnGbRY=; b=Pv5vV5FidwMSSt9quMv5eh7Ux9CEGj/sXbHsf3BEGk8R
VaJdl/YeFYTdvHSO5z7NQh/2SAXQO/TGr1WdGOFYTDhUE4KOUjcZbAA/fQB52vtP
p7qpG69Fa2R7SpjucGlruOH1uzLiFUhxhKcMh4z8s6lTyLmZmnfw02MXJ5a3FiE=
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=-3.1 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.2
X-HELO: mx1.redhat.com
Message-ID: <54134A83.80107@redhat.com>
Date: Fri, 12 Sep 2014 13:33:23 -0600
From: Eric Blake <eblake AT redhat DOT com>
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.7.0
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>
In-Reply-To: <5413271B.1010109@t-online.de>
OpenPGP: url=http://people.redhat.com/eblake/eblake.gpg
X-IsSubscribed: yes

--bNJ8sNK0HaA0F7voNXqHMOW8WPbVR45n1
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

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.
>=20
> 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)
>=20
> Testcase:
>=20
> $ cat nopath.cc
> #include <stdio.h>
> #include <stdlib.h>
> #include <unistd.h>
> // #include <windows.h>
>=20
> 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."

> 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.

--=20
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


--bNJ8sNK0HaA0F7voNXqHMOW8WPbVR45n1
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: OpenPGP digital signature
Content-Disposition: attachment; filename="signature.asc"

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1
Comment: Public key at http://people.redhat.com/eblake/eblake.gpg

iQEcBAEBCAAGBQJUE0qDAAoJEKeha0olJ0Nq8WkH/RXaiIH7mdxts0d2X2U/wkNA
+eTuklyfRMDSgVxcqPNJhi4UyrUB7djKBKXDbWFuU+7x88MN5LyspC2Ov526gWlT
MJB/UnGUuyQT8SgTm1Ji/p2uMuaKnfB4rq6nwBvDYLii0DxLsZjj4d5lWNbQQo8n
fvm1RR8NnMhMzPozy3xQoRlr9meV+WJgsvnTneO1BgI0cbQ8AdM8thgGefytL2ss
VcGsh/bpp8RgZOkwQ9afbzQQ/gB4HvYV500VmM4CGYyWCZAtuD8dbh9xEigwKWNC
a/iKIcM0pjbsBf9cRRctb8DCKZEGww1OQ2OneW6L/IEaVQjLRofSUKqAL9RNVVI=
=ga8E
-----END PGP SIGNATURE-----

--bNJ8sNK0HaA0F7voNXqHMOW8WPbVR45n1--

- Raw text -


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