X-Recipient: archive-cygwin@delorie.com
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C14733857703
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com;
	s=default; t=1681809927;
	bh=q7Abfpxjm7he94+AED41bJ1ifHq/6snUig4ehMUiyjg=;
	h=Date:To:Subject:References:In-Reply-To:List-Id:List-Unsubscribe:
	 List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:
	 From;
	b=XBLqMqy6PBWn9sdyuZfSXdfg27dxPUKxlgLLKSXkjxySEZqWT8VS8o8OgNuNBwMKK
	 s2I5DGGHefvycl8GRhjJu42c24zlCmPaNRvLzrTfmkSALVegR5nvLIiIO8nWhY2yGI
	 oS86Z2zE758DLDie1zK4ZRX0AlVfaxbb+Byv+ZGU=
X-Original-To: cygwin@cygwin.com
Delivered-To: cygwin@cygwin.com
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DFF163858D1E
Date: Tue, 18 Apr 2023 11:25:11 +0200
To: Bruno Haible <bruno@clisp.org>
Subject: Re: posix_spawn facility
Message-ID: <ZD5h973pS0tVenD0@calimero.vinschen.de>
Mail-Followup-To: Bruno Haible <bruno@clisp.org>, cygwin@cygwin.com
References: <1752276.7aRn1RRit1@nimes> <ZD0O442kk5d7VKrx@calimero.vinschen.de>
 <5022555.upeRZZJTqa@nimes>
MIME-Version: 1.0
Content-Disposition: inline
In-Reply-To: <5022555.upeRZZJTqa@nimes>
X-BeenThere: cygwin@cygwin.com
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: General Cygwin discussions and problem reports <cygwin.cygwin.com>
List-Unsubscribe: <https://cygwin.com/mailman/options/cygwin>,
 <mailto:cygwin-request@cygwin.com?subject=unsubscribe>
List-Archive: <https://cygwin.com/pipermail/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-request@cygwin.com?subject=help>
List-Subscribe: <https://cygwin.com/mailman/listinfo/cygwin>,
 <mailto:cygwin-request@cygwin.com?subject=subscribe>
From: Corinna Vinschen via Cygwin <cygwin@cygwin.com>
Reply-To: cygwin@cygwin.com
Cc: Corinna Vinschen <corinna-cygwin@cygwin.com>, cygwin@cygwin.com
Content-Type: text/plain; charset="utf-8"
Errors-To: cygwin-bounces+archive-cygwin=delorie.com@cygwin.com
Sender: "Cygwin" <cygwin-bounces+archive-cygwin=delorie.com@cygwin.com>
Content-Transfer-Encoding: 8bit
X-MIME-Autoconverted: from base64 to 8bit by delorie.com id 33I9Ppo7003066

Hi Bruno,

On Apr 17 20:44, Bruno Haible via Cygwin wrote:
> Hi Corinna,
> 
> > > Would it be possible to change Cygwin's posix_spawnp implementation,
> > > so that both tests succeed?
> > 
> > Basically, yes, but...
> 
> Thanks!
> 
> > > Disclaimer: I have done my tests with Cygwin 2.9.0; so, if things have
> >                                         ^^^^^^^^^^^^
> > 					2017-09-07
> > 
> > I'm a bit puzzled. You quote that only Cygwin 3.1.7 has the fixed
> > posix_spawn, but then you test this with a version three years older?
> 
> I have now verified that the findings with Cygwin 3.4.6 are the same as
> with Cygwin 2.9.0. I had expected that, based on browsing through the
> Cygwin git history; I confirm it now.

Thanks a lot!  The patch is actually simple.

But I'm not *that* happy with the change yet, for two reasons.

First, the security risk outlined in
https://sourceware.org/bugzilla/show_bug.cgi?id=13134#c0 doesn't
actually exist on Cygwin, because we don't implement setuid/setgid
executables.  You can set the mode bits, but they are not acted upon.

Second, the rational section in POSIX explains posix_spawn and
posix_spawnp, but it does *not* actually provide an example
implementation of posix_spawnp, only of posix_spawn.

From the above bugzilla entry I take it that on glibc, both
functions tried to run the shell if the executable isn't recognized
(up to commits d96de9634a33 / 13adfa34aff).

However, on Cygwin, only posix_spawnp does that,but not posix_spawn.

In fact, I read the POSIX descriptions in terms of these functions quite
thoroughly, and at no point I see it mentioned that posix_spawnp shall
*not* work like exevlp/execvp.  The crucial difference between posix_spawn
and posixc_spawnp is described in an interestingly vague way:

  posix_spawnp() interprets the second parameter more elaborately than
  posix_spawn().

If I missed the point in the POSIX docs, please tell me.

So, again, the patch is simple.  But it's kind of a pity that the change
in glibc has been made without a bigger discussion.  Right now, it looks
like the glibc change to posix_spawn was correct, but the change to
posix_spawnp was arbitrary.

Has anybody attempted to ask the Austin group to define this behaviour
in posix_spawnp more concise?  Is there a protocel from the Austin
group?  If not, wouldn't it be time to ask the Austin group?

> Btw, there are two more functions in the posix_spawn family meanwhile:
>   * posix_spawn_file_actions_addchdir_np
>     implemented by glibc [1], musl libc, macOS, FreeBSD [2], Solaris ≥ 11.3
>     used by a few packages (Firefox, Chromium, Rust)
>   * posix_spawn_file_actions_addfchdir_np
>     implemented in glibc, musl libc
>     but not used by any package so far [3].
> 
> The next POSIX will contain these functions (without the _np suffix).[4]

Thanks for the pointers.  I'm not sure I'll have the time to implement
them soon, but I put them on my list for 3.5.0.  Patches welcome!


Thanks,
Corinna

-- 
Problem reports:      https://cygwin.com/problems.html
FAQ:                  https://cygwin.com/faq/
Documentation:        https://cygwin.com/docs.html
Unsubscribe info:     https://cygwin.com/ml/#unsubscribe-simple

