Skip to content

Commit

Permalink
msys2-runtime: enable pseudo consoles and empty values of env variables
Browse files Browse the repository at this point in the history
This integrates the patches from
msys2/msys2-runtime#102 and from
msys2/msys2-runtime#101

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
  • Loading branch information
dscho committed Sep 20, 2022
1 parent e2dd586 commit 3dad035
Show file tree
Hide file tree
Showing 41 changed files with 259 additions and 74 deletions.
2 changes: 1 addition & 1 deletion msys2-runtime/0001-Add-MSYS2-triplet.patch
Original file line number Diff line number Diff line change
Expand Up @@ -2709,5 +2709,5 @@ index eb2a870..3bf9d9f 100755
lt_cv_dlopen_libs=
;;
--
2.37.2
2.37.3

Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@ index b900960..617a9c2 100755
my ($file, $member, $symbol) = m%^([^:]*):([^:]*(?=:))?.* T (.*)%o;
next if !defined($symbol) || $symbol =~ $exclude_regex;
--
2.37.2
2.37.3

2 changes: 1 addition & 1 deletion msys2-runtime/0003-Rename-dll-from-cygwin-to-msys.patch
Original file line number Diff line number Diff line change
Expand Up @@ -1442,5 +1442,5 @@ index 4c98eef..ad35d23 100644
"The \"-b\" means 'skip the help pages'. You can omit this until you're\n"
"familiar with the report layout. The gprof documentation explains\n"
--
2.37.2
2.37.3

Original file line number Diff line number Diff line change
Expand Up @@ -1094,5 +1094,5 @@ index e3a65f8..1aeec8d 100644
{
for (int i = calloced; i < argc; i++)
--
2.37.2
2.37.3

Original file line number Diff line number Diff line change
Expand Up @@ -191,5 +191,5 @@ index 3502166..daed73f 100644
/* Add a hint to the sysname, that we're running under WOW64. This might
give an early clue if somebody encounters problems. */
--
2.37.2
2.37.3

Original file line number Diff line number Diff line change
Expand Up @@ -397,5 +397,5 @@ index 6aae33c..5736ffb 100644
free (gecos);
if (home)
--
2.37.2
2.37.3

Original file line number Diff line number Diff line change
Expand Up @@ -233,5 +233,5 @@ index a430d98..17646a8 100644
buf = tp.t_get ();
cp = stpcpy (buf, SYMLINK_COOKIE);
--
2.37.2
2.37.3

Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@ index 296c890..2e290a8 100644
else if (*newp == 'M' && strncmp (newp, "MSYS=", 5) == 0)
parse_options (newp + 5);
--
2.37.2
2.37.3

Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ index 283041a..49cd941 100644
{
set_errno (E2BIG);
--
2.37.2
2.37.3

Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,5 @@ index 17646a8..77480aa 100644
}

--
2.37.2
2.37.3

Original file line number Diff line number Diff line change
Expand Up @@ -76,5 +76,5 @@ index ee75d3b..d652b32 100644

/* Convert argv[0] to posix rules if it's currently blatantly
--
2.37.2
2.37.3

Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,5 @@ index d652b32..f75ba5f 100644
size_t cnt = isascii (*s) ? 1 : mbtowc (NULL, s, MB_CUR_MAX);
if (cnt <= 1 || cnt == (size_t)-1)
--
2.37.2
2.37.3

2 changes: 1 addition & 1 deletion msys2-runtime/0013-strace.cc-Don-t-set-MSYS-noglob.patch
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,5 @@ index de4abc4..3dbce3b 100644
NULL, /* Security */
NULL, /* thread */
--
2.37.2
2.37.3

2 changes: 1 addition & 1 deletion msys2-runtime/0014-Add-debugging-for-build_argv.patch
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ index f75ba5f..4dc8be8 100644
while (*cmd)
{
--
2.37.2
2.37.3

Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ index 3dbce3b..4e5d24c 100644
SetConsoleCtrlHandler (NULL, 0);
/* Commit message for this code was:
--
2.37.2
2.37.3

Original file line number Diff line number Diff line change
Expand Up @@ -172,5 +172,5 @@ index 49cd941..8359f12 100644

/* Check if we have been called from exec{lv}p or spawn{lv}p and mask
--
2.37.2
2.37.3

Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ index 8359f12..4f28335 100644

if (buf.isdir ())
--
2.37.2
2.37.3

Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ index e254397..2a03ac1 100644
LoadDLLfunc (VirtualAlloc2, 28, KernelBase)

--
2.37.2
2.37.3

2 changes: 1 addition & 1 deletion msys2-runtime/0019-strace-quiet-be-really-quiet.patch
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,5 @@ index 4e5d24c..a4713a2 100644
SetConsoleCtrlHandler (NULL, 0);
/* Commit message for this code was:
--
2.37.2
2.37.3

2 changes: 1 addition & 1 deletion msys2-runtime/0020-Default-to-disable_pcon.patch
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,5 @@ index 1b8d8e2..29ca896 100644
bool NO_COPY in_forkee;

--
2.37.2
2.37.3

Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,5 @@ index 49631d6..daaa1ec 100644
*k->setting.x &= ~k->values[istrue].i;
if (istrue || (eq && strtol (eq, NULL, 0)))
--
2.37.2
2.37.3

Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@ index 0890390..f6ffb1c 100644

/* Reinstate the close-on-exec state */
--
2.37.2
2.37.3

Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,5 @@ index 0000000..4e1d498
+ name: install
+ path: _dest/
--
2.37.2
2.37.3

Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,5 @@ index 0000000..57bd30e
+ run: |
+ git push https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$GITHUB_REPOSITORY refs/heads/cygwin/master 'refs/tags/*:refs/tags/*'
--
2.37.2
2.37.3

Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,5 @@ index 649084d..28056e6 100644

<listitem>
--
2.37.2
2.37.3

Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@ index f9a9a7a..4b541a8 100644
jobs:
fedora-build:
--
2.37.2
2.37.3

Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,5 @@ index 4f28335..bc9dc5a 100644

/* We're adding the CREATE_BREAKAWAY_FROM_JOB flag here to workaround
--
2.37.2
2.37.3

Original file line number Diff line number Diff line change
Expand Up @@ -381,5 +381,5 @@ index 0000000..25814c7
+ return 0;
+}
--
2.37.2
2.37.3

Original file line number Diff line number Diff line change
Expand Up @@ -505,5 +505,5 @@ index 0000000..0486a0c
+
+#endif
--
2.37.2
2.37.3

Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,5 @@ index d0fb547..ad718c3 100644
}

--
2.37.2
2.37.3

Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,5 @@ index 9edd949..9a3ad7a 100644
PWCHAR fpbuf = tp.w_get ();
DWORD ret;
--
2.37.2
2.37.3

Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,5 @@ index 534d674..d448ede 100644
uninstall-extra-man:
for i in *.1 ; do \
--
2.37.2
2.37.3

Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@ index 23a3c23..f1fe01d 100644
$(INSTALL_PROGRAM) $(TEST_DLL_NAME) $(DESTDIR)$(bindir)/$(DLL_NAME)
@$(MKDIR_P) $(DESTDIR)$(toollibdir)
--
2.37.2
2.37.3

2 changes: 1 addition & 1 deletion msys2-runtime/0034-POSIX-ify-the-SHELL-variable.patch
Original file line number Diff line number Diff line change
Expand Up @@ -107,5 +107,5 @@ index 71c3f22..f33740d 100644
const char * get_native () const {return native ? native + namelen : NULL;}
const char * get_posix () const {return posix ? posix : NULL;}
--
2.37.2
2.37.3

Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,5 @@ index 5c197a6..5afac8d 100644
/* P Q R S T U V W */
WC, 0, 0, WC, WC, 0, 0, 0,
--
2.37.2
2.37.3

Original file line number Diff line number Diff line change
Expand Up @@ -81,5 +81,5 @@ index daed73f..f6a5f88 100644
/* Add a hint to the sysname, that we're running under WOW64. This might
give an early clue if somebody encounters problems. */
--
2.37.2
2.37.3

28 changes: 28 additions & 0 deletions msys2-runtime/0037-fixup-Revert-Default-to-disable_pcon.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
From f5d37650e7077d214ec5895b0175918863172086 Mon Sep 17 00:00:00 2001
From: Christoph Reiter <reiter.christoph@gmail.com>
Date: Tue, 13 Sep 2022 09:36:38 +0200
Subject: [PATCH 37/N] fixup! Revert "Default to `disable_pcon`"

This reverts commit 8e89fffcfb0884da1398dd55f0d0cc57294549ec.

We want to try enabling it by default again, see #98
---
winsup/cygwin/globals.cc | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/winsup/cygwin/globals.cc b/winsup/cygwin/globals.cc
index 6c15138..6a65dd6 100644
--- a/winsup/cygwin/globals.cc
+++ b/winsup/cygwin/globals.cc
@@ -74,7 +74,7 @@ bool pipe_byte;
bool reset_com;
bool wincmdln = true;
winsym_t allow_winsymlinks = WSYM_deepcopy;
-bool disable_pcon = true;
+bool disable_pcon;
bool winjitdebug = false;
bool nativeinnerlinks = true;

--
2.37.3

Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
From 5812c2fb3534a9203cc110cc052fdae730920a3e Mon Sep 17 00:00:00 2001
From: Johannes Schindelin <johannes.schindelin@gmx.de>
Date: Wed, 18 Feb 2015 12:32:17 +0000
Subject: [PATCH 38/N] Pass environment variables with empty values

There is a difference between an empty value and an unset environment
variable. We should not confuse both; If the user wants to unset an
environment variable, they can certainly do so (unsetenv(3), or in the
shell: 'unset ABC').

This fixes Git's t3301-notes.sh, which overrides environment variables
with empty values.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
winsup/cygwin/environ.cc | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/winsup/cygwin/environ.cc b/winsup/cygwin/environ.cc
index 5afac8d..522d7d5 100644
--- a/winsup/cygwin/environ.cc
+++ b/winsup/cygwin/environ.cc
@@ -1339,11 +1339,11 @@ build_env (const char * const *envp, PWCHAR &envblock, int &envc,
Note that this doesn't stop invalid strings without '=' in it
etc., but we're opting for speed here for now. Adding complete
checking would be pretty expensive. */
- if (len == 1 || !*rest)
+ if (len == 1)
continue;

/* See if this entry requires posix->win32 conversion. */
- conv = getwinenv (*srcp, rest, &temp);
+ conv = !*rest ? NULL : getwinenv (*srcp, rest, &temp);
if (conv)
{
p = conv->native; /* Use win32 path */
@@ -1357,7 +1357,7 @@ build_env (const char * const *envp, PWCHAR &envblock, int &envc,
}
}
#ifdef __MSYS__
- else if (!keep_posix) {
+ else if (!keep_posix && *rest) {
char *win_arg = arg_heuristic_with_exclusions
(*srcp, msys2_env_conv_excl_env, msys2_env_conv_excl_count);
debug_printf("WIN32_PATH is %s", win_arg);
--
2.37.3

Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
From 96283acb9d8fe69bb921ee84c584bc79b1eb262f Mon Sep 17 00:00:00 2001
From: Johannes Schindelin <johannes.schindelin@gmx.de>
Date: Tue, 6 Sep 2022 10:40:58 +0200
Subject: [PATCH 39/N] Optionally disallow empty environment values again

We just disabled the code that skips environment variables whose values
are empty.

However, this code was introduced a long time ago into Cygwin in
d6b1ac7faa (* environ.cc (build_env): Don't put an empty environment
variable into the environment. Optimize use of "len". * errno.cc
(ERROR_MORE_DATA): Translate to EMSGSIZE rather than EAGAIN.,
2006-09-07), seemingly without any complaints.

Meaning: There might very well be use cases out there where it makes
sense to skip empty-valued environment variables.

Therefore, it seems like a good idea to have a "knob" to turn it back
on. With this commit, we introduce such a knob: by setting
`noemptyenvvalues` the `MSYS` variable (or appending it if that variable
is already set), users can tell the MSYS2 runtime to behave just like in
the olden times.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
winsup/cygwin/environ.cc | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/winsup/cygwin/environ.cc b/winsup/cygwin/environ.cc
index 522d7d5..128f34d 100644
--- a/winsup/cygwin/environ.cc
+++ b/winsup/cygwin/environ.cc
@@ -36,6 +36,7 @@ static char **lastenviron;
/* Parse CYGWIN options */

static NO_COPY bool export_settings = false;
+static bool emptyenvvalues = true;

enum settings
{
@@ -130,6 +131,7 @@ static struct parse_thing
{"enable_pcon", {&disable_pcon}, setnegbool, NULL, {{true}, {false}}},
{"winjitdebug", {&winjitdebug}, setbool, NULL, {{false}, {true}}},
{"nativeinnerlinks", {&nativeinnerlinks}, setbool, NULL, {{false}, {true}}},
+ {"emptyenvvalues", {&emptyenvvalues}, setbool, NULL, {{false}, {true}}},
{NULL, {0}, setdword, 0, {{0}, {0}}}
};

@@ -1339,7 +1341,7 @@ build_env (const char * const *envp, PWCHAR &envblock, int &envc,
Note that this doesn't stop invalid strings without '=' in it
etc., but we're opting for speed here for now. Adding complete
checking would be pretty expensive. */
- if (len == 1)
+ if (len == 1 || (!emptyenvvalues && !*rest))
continue;

/* See if this entry requires posix->win32 conversion. */
--
2.37.3

0 comments on commit 3dad035

Please sign in to comment.