public inbox for cygwin-cvs@sourceware.org
help / color / mirror / Atom feed
From: Corinna Vinschen <corinna@sourceware.org>
To: cygwin-cvs@sourceware.org, newlib-cvs@sourceware.org
Subject: [newlib-cygwin] posix_spawn: fix get/set uid/gid calls for 32 bit Cygwin
Date: Wed, 12 Jan 2022 11:04:04 +0000 (GMT)	[thread overview]
Message-ID: <20220112110404.9095538A9415@sourceware.org> (raw)

https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=935c33877d5b17c1335d91f20252333b0e54bf5f

commit 935c33877d5b17c1335d91f20252333b0e54bf5f
Author: Corinna Vinschen <corinna@vinschen.de>
Date:   Wed Jan 12 11:57:35 2022 +0100

    posix_spawn: fix get/set uid/gid calls for 32 bit Cygwin
    
    32 bit Cygwin still exports function calls to support old applications.
    E. g., when switching from 16 to 32 bit uid/gid values, new function
    like getuid32 have been added and the old getuid function still only
    provides 16 bit values.  Newly built applications using getuid are
    actually calling getuid32.
    
    However, this link magic isn't performed inside Cygwin itself, so if
    newlib functions call getuid, they actually call the old getuid, not
    the new getuid32.  This leads to truncated uid/gid values.
    
    https://cygwin.com/pipermail/cygwin/2022-January/250453.html reports
    how this leads to problems in posix_spawn.
    
    Fix this temporarily. i686 support will go away soon in Cygwin and the
    fix can be dropped.
    
    Signed-off-by: Corinna Vinschen <corinna@vinschen.de>

Diff:
---
 newlib/libc/posix/posix_spawn.c | 11 +++++++++++
 winsup/cygwin/release/3.3.4     |  3 +++
 2 files changed, 14 insertions(+)

diff --git a/newlib/libc/posix/posix_spawn.c b/newlib/libc/posix/posix_spawn.c
index 85bfa6477..fe912a8b7 100644
--- a/newlib/libc/posix/posix_spawn.c
+++ b/newlib/libc/posix/posix_spawn.c
@@ -146,6 +146,17 @@ typedef struct __posix_spawn_file_actions_entry {
  * Spawn routines
  */
 
+#if defined (__CYGWIN__) && defined (__i386__)
+extern int getgid32 (void);
+extern int getuid32 (void);
+extern int setegid32 (gid_t egid);
+extern int seteuid32 (uid_t euid);
+#define setegid setegid32
+#define seteuid seteuid32
+#define getgid getgid32
+#define getuid getuid32
+#endif
+
 static int
 process_spawnattr(const posix_spawnattr_t sa)
 {
diff --git a/winsup/cygwin/release/3.3.4 b/winsup/cygwin/release/3.3.4
index 1982df0cf..7c37a575c 100644
--- a/winsup/cygwin/release/3.3.4
+++ b/winsup/cygwin/release/3.3.4
@@ -20,3 +20,6 @@ Bug Fixes
 
 - Ignore INHERIT ACEs when reading the DACL of non-directory files.
   Addresses: https://cygwin.com/pipermail/cygwin/2022-January/250363.html
+
+- Fix an "Invalid argument" problem in posix_spawn on i686.
+  Addresses: https://cygwin.com/pipermail/cygwin/2022-January/250453.html


                 reply	other threads:[~2022-01-12 11:04 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220112110404.9095538A9415@sourceware.org \
    --to=corinna@sourceware.org \
    --cc=cygwin-cvs@sourceware.org \
    --cc=newlib-cvs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).