Merge pull request #3195 from dscho/msys2-runtime-enable-pcon-and-empty-environment-variable-values

msys2-runtime: enable pseudo consoles and empty values of env variables
This commit is contained in:
Christoph Reiter 2022-09-20 22:12:47 +02:00 committed by GitHub
commit b4d50afa58
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
41 changed files with 260 additions and 75 deletions

View File

@ -2709,5 +2709,5 @@ index eb2a870..3bf9d9f 100755
lt_cv_dlopen_libs=
;;
--
2.37.2
2.37.3

View File

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

View File

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

View File

@ -1094,5 +1094,5 @@ index e3a65f8..1aeec8d 100644
{
for (int i = calloced; i < argc; i++)
--
2.37.2
2.37.3

View File

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

View File

@ -397,5 +397,5 @@ index 6aae33c..5736ffb 100644
free (gecos);
if (home)
--
2.37.2
2.37.3

View File

@ -233,5 +233,5 @@ index a430d98..17646a8 100644
buf = tp.t_get ();
cp = stpcpy (buf, SYMLINK_COOKIE);
--
2.37.2
2.37.3

View File

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

View File

@ -29,5 +29,5 @@ index 283041a..49cd941 100644
{
set_errno (E2BIG);
--
2.37.2
2.37.3

View File

@ -54,5 +54,5 @@ index 17646a8..77480aa 100644
}
--
2.37.2
2.37.3

View File

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

View File

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

View File

@ -68,5 +68,5 @@ index de4abc4..3dbce3b 100644
NULL, /* Security */
NULL, /* thread */
--
2.37.2
2.37.3

View File

@ -21,5 +21,5 @@ index f75ba5f..4dc8be8 100644
while (*cmd)
{
--
2.37.2
2.37.3

View File

@ -20,5 +20,5 @@ index 3dbce3b..4e5d24c 100644
SetConsoleCtrlHandler (NULL, 0);
/* Commit message for this code was:
--
2.37.2
2.37.3

View File

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

View File

@ -21,5 +21,5 @@ index 8359f12..4f28335 100644
if (buf.isdir ())
--
2.37.2
2.37.3

View File

@ -22,5 +22,5 @@ index e254397..2a03ac1 100644
LoadDLLfunc (VirtualAlloc2, 28, KernelBase)
--
2.37.2
2.37.3

View File

@ -36,5 +36,5 @@ index 4e5d24c..a4713a2 100644
SetConsoleCtrlHandler (NULL, 0);
/* Commit message for this code was:
--
2.37.2
2.37.3

View File

@ -50,5 +50,5 @@ index 1b8d8e2..29ca896 100644
bool NO_COPY in_forkee;
--
2.37.2
2.37.3

View File

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

View File

@ -30,5 +30,5 @@ index 0890390..f6ffb1c 100644
/* Reinstate the close-on-exec state */
--
2.37.2
2.37.3

View File

@ -51,5 +51,5 @@ index 0000000..4e1d498
+ name: install
+ path: _dest/
--
2.37.2
2.37.3

View File

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

View File

@ -52,5 +52,5 @@ index 649084d..28056e6 100644
<listitem>
--
2.37.2
2.37.3

View File

@ -31,5 +31,5 @@ index f9a9a7a..4b541a8 100644
jobs:
fedora-build:
--
2.37.2
2.37.3

View File

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

View File

@ -381,5 +381,5 @@ index 0000000..25814c7
+ return 0;
+}
--
2.37.2
2.37.3

View File

@ -505,5 +505,5 @@ index 0000000..0486a0c
+
+#endif
--
2.37.2
2.37.3

View File

@ -50,5 +50,5 @@ index d0fb547..ad718c3 100644
}
--
2.37.2
2.37.3

View File

@ -51,5 +51,5 @@ index 9edd949..9a3ad7a 100644
PWCHAR fpbuf = tp.w_get ();
DWORD ret;
--
2.37.2
2.37.3

View File

@ -45,5 +45,5 @@ index 534d674..d448ede 100644
uninstall-extra-man:
for i in *.1 ; do \
--
2.37.2
2.37.3

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -0,0 +1,37 @@
From 97c2d7fa8bb424012aad77b8d86f3262a35fab0a Mon Sep 17 00:00:00 2001
From: Johannes Schindelin <johannes.schindelin@gmx.de>
Date: Tue, 6 Sep 2022 12:18:18 +0200
Subject: [PATCH 40/N] build_env(): respect the `MSYS` environment variable
With this commit, you can call
MSYS=noemptyenvvalues my-command
and it does what is expected: to pass no empty-valued environment
variables to `my-command`.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
winsup/cygwin/environ.cc | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/winsup/cygwin/environ.cc b/winsup/cygwin/environ.cc
index 128f34d..b431d3c 100644
--- a/winsup/cygwin/environ.cc
+++ b/winsup/cygwin/environ.cc
@@ -1217,7 +1217,11 @@ build_env (const char * const *envp, PWCHAR &envblock, int &envc,
{
bool calc_tl = !no_envblock;
#ifdef __MSYS__
- if (!keep_posix)
+ if (ascii_strncasematch(*srcp, "MSYS=", 5))
+ {
+ parse_options (*srcp + 5);
+ }
+ else if (!keep_posix)
{
/* Don't pass timezone environment to non-msys applications */
if (ascii_strncasematch(*srcp, "TZ=", 3))
--
2.37.3

View File

@ -4,7 +4,7 @@
pkgbase=msys2-runtime
pkgname=('msys2-runtime' 'msys2-runtime-devel')
pkgver=3.3.6
pkgrel=1
pkgrel=2
pkgdesc="Cygwin POSIX emulation engine"
arch=('i686' 'x86_64')
url="https://www.cygwin.com/"
@ -60,44 +60,52 @@ source=('msys2-runtime'::git://sourceware.org/git/newlib-cygwin.git#tag=cygwin-$
0033-install-libs-depend-on-the-toollibs.patch
0034-POSIX-ify-the-SHELL-variable.patch
0035-Handle-ORIGINAL_PATH-just-like-PATH.patch
0036-uname-allow-setting-the-system-name-to-CYGWIN.patch)
0036-uname-allow-setting-the-system-name-to-CYGWIN.patch
0037-fixup-Revert-Default-to-disable_pcon.patch
0038-Pass-environment-variables-with-empty-values.patch
0039-Optionally-disallow-empty-environment-values-again.patch
0040-build_env-respect-the-MSYS-environment-variable.patch)
sha256sums=('SKIP'
'b14865a15e636777f42d8dbb15f53958e0ce107c173a93ded0a6179129c88593'
'ff1fd15319481bd30aa02d649a48ac85bc38336521651310d3844b28ae7a11a2'
'bd824e732658781e8c6e13d9fefd29d8c7a8b3a86c51674345319873fee00669'
'fe00bb630da51379dd8c1616daa3bc31ef2dd17c6163aa6ac850bceb17589206'
'81d2ac6e31f3f7864adbeb40a6f2a8328e185258718888c7adc4e83589881dcf'
'4a8da1952202dd03ea487e81c23731c7eb889ba1c66d776b85f1d81d81017f8d'
'567c3cb2ff35b50836623ac1f60b5b3357d6664f58dc7a95f6ee84a8d7d7e5bc'
'649685260b22d2b812653887bde1e38b3a61a1b3f04e362e79784d03c073b250'
'64dd11dfb6be339fff473b7b9695b9655862e15f0d77ff61a50f64d96ba8e7c7'
'3fc02c70e8610743fef7256bc851b2c095f123a957c54b93d37f944810fa69c4'
'b98b183a1685c17b07f78b37ae210305b1bf845be7bb8876735df7664f5121a4'
'3d19fd6c37f56ac7399734d77091a64af3ef368668c81e449b8d6c4688cb72c2'
'937ccfcd22a4edfcc2c631c29fb2580823b842a3070627a08050b596c044c77a'
'ff9e16c0d44d40479184b1eb9c39c0b74453a362e05f9f59b493ab2b69882fd6'
'6e4212ff3838ff8d724e51194c7971eaae9d4e80e2d4ee86701e61f4db1d8410'
'596c03df58fc7c34d3a4eab5537f155966a852918fc47301154eef181afd55ef'
'41c99b4a7d7d34902092c1aac842827c8fdce13113b6acd07660bf99fd93e94c'
'cae6a52b79ad8d38c267b75d0f050178c76e4ca1ec203f4eb61eacc74c6bc5bd'
'ecbd43e0d3c23a5d13eb93368a53366de935742c274f313a3a9b52bf6554e9f5'
'7c9a68e32cc9576598b12868b5a0b7d02799bc154a4d210d48df0793528e6dde'
'66eb6e750a6257207801712256d94e92cda003d8f1a01d04b7aa0bee29657b83'
'536f2cb2b60cd405c15fe3a5fb1f637d4b041f912c29980248b6b0b872afff39'
'4b3e8e44e2c0367708cc00982ed81483b6e4ec0d83344d6131052612a46b47c1'
'2fc51a29bac814b93d5f430e57167366027f6d44bc586932e0c0c9b59403c21f'
'b8d11bda24bea40ec2f0acacb55257799972a66ad2250e534662acb0648e0707'
'2cf096a37d247fefbc08201b36c824d643d6bd17062296d40650813406c15d26'
'91cc47baebd02d9d580c786e64efe763dd4da8e396e544c0dc5c23582050d59d'
'78e8acd88eb23ca09aed27ad08009bca8472735471c8d3144804484e6dba379b'
'f41f87dc7df81655877cfa4928f6988ee65093c73e6a9dced9074b691083d590'
'a57c21fcd6dd5f53f2989f936c69970ddf72d09a56018b5e610a8dda1c09741b'
'2056e328fee4be7768f6e0b9a42f138d2246c6484aab8c97c4a5a4e082df9ca2'
'10cf07b133c48e13fe44adaab56727f4dd7baf4872408cbf563dcb4ecc917396'
'da9c76dac9b67db9ceaa9d6e44ab2d0c3046a355755ea1b010e8f36c3369b909'
'4c81116196554f8d57ff34cdb3ebf9acc28b3ba7007d28722e8a5b5cd41db584'
'85108c25aba80456ae160e946cbe495d650e706373c7a80b0c318096fb13a6a3'
'acc88ef9eea5e8e0d818adf2ad440c6aa5f3862e8cd35ea3b98b0a51b7840d3e')
'8e26c673b763366a085eada2250bfcaf182d1f357eb23a62c57a20fe8a0346f3'
'c4cc134ab6fa1c17b5ee428c8604861f1a4580ac14aef25740da8597de84800e'
'f30d275031db52430c7ddef7ed1e54eb8d934251b11c812725d32d1ba380a3e9'
'09effb95abc166cde9c3a3d7f9aa1bd53c1161c3706c6c5e85c29802dfe7fe63'
'7208bf2dffe1c27f9a8ff63e24ee3b4f9e7448aef8a5bd6f014b50b63bb49bae'
'c0c833ee0f038fcb29d56a49df62278d0e489ca85e6e4ca8b7ae6600c7bc69a3'
'99e2e82848a9c4e56f75bec6d016f8d38869373f9c809029ed2179eef5efe033'
'bd6174a58ebe88c29421f23ccfaee157e4fa18a4b497e2d391875b2507875a63'
'2d36efb8c2355c8d6eb4652cea2abcf7b5cec1e8931dc33d90dc7ee0ca69e1df'
'92e8553378e380b8db643d7ca3604b84b13a0dba38263d6aca33169bcf62214c'
'a6cd762892edd38bf8c62b513fe3be1c8bdcfdabe5596814185dbf37c40cdec3'
'1b0bd86c9d9d489d00396ab259f0a5fd6489aef24c47ba51c1ba85b0d23e0765'
'337674665b7bfd58a80766d5d7d91390796ac2f4426db9cc071e00e3914e29d5'
'779949b0f9143b68733ec7fe0f01f2eaea8e589df5fd1dd2fe4fc9046ff73b18'
'15236a2889c68d6f97dde91059fb725c855c3085f89ca8735d82a5727c8e05c1'
'1bf0f0f554c57e3d75fd936eb6e1a0dbffe192e91164ffe16ba0e95da6298326'
'd0d704e9c8163c8bd731aab8785396d64262a16580e219426052895f63929187'
'35948eb27c4eec64f986eea4689963af547dba4c8722d2c97607a2164a9bb78c'
'324e313839c4d78e1a2bb8e37eee143f9ba3bf8f8e6c97c09f20fc945503734b'
'ddcb985482a8409227252e95e790ce3de3c256d18af29fa8bb3e1887fbeee585'
'535dbc7eae11e9cc5307b7023e967824ce187ab981e31663af289107cfc9757e'
'a35032b628032deadad31fde7c7dd04c3a28f15095fb10a31f26e0f489f35d69'
'3f43a8ae895f0100399b198ad66897ae59d74da7c2e8ceba0fc6d82582d4ba34'
'5680983a9ac7943800aec6b1504cd0c7300d9590d3e0321a9fd2091005595aa7'
'd33334697d2b345e9cd54e8a879aef497d5f699ed194072123fed7268a7155a7'
'a0b5a0d39b7585885b52d8df3522ab7bf9a4b831f7e64a4ce4842135b363124b'
'52e924fe006400dbe2def51ac04a09173a6e0fabaa6417b43f5114bc35e28ca1'
'fc0605ba52e4091081063a98f7757110d2f353027d2e146960531299d2c3b3bc'
'3dc45ac3b3bf2b32bb7e17639e3dd8ed599bad636c9883aa0fa77dfa79471432'
'4c340f2b767833a11b0b57d33780f6150bba231946f2cece334dbb46475499a6'
'835ac7031ff00e4a70bb2b7e5a4e4c75dc8c449b4d8095fc59dada42068fb380'
'd19dee1e9255789387a4d79d1f6f469adb8d0cb3424c6469049c917df589b0a6'
'4631a6186534f7b9abbd5685f858cffc40634df540cb7db5f3102bf7e6f6dfc6'
'ba34f8b5bc39e273a5e594ba3f893367359fb72ed5fe8f9ed80d03a7702041c9'
'8ebe2924fd3bfcc5fe51e731ddb29b800f0f49c7776ce2af084300888cb966c2'
'90f482551aa593215c0eb574863f5d6f492b0cca63469a8c80eaae72b82dee74'
'f4641a5c4c9571362ef7dc855d3340cb9bf7fe512a2042e92e6b8e3f93a5293f'
'57d4380abbd5536dacb9efea24749756af31c6926473f78a62681d65b431b3a9'
'c4d5ad6a5960b735ddd900445dc2c3428c1d1cea1454150a8b8b77ff09c42dc9'
'd12ae4e081ef49e5f00579baf45d9c3e245ed1c3542ea988f81ac38b5f00c71d')
# Helper macros to help make tasks easier #
apply_patch_with_msg() {
@ -170,7 +178,11 @@ prepare() {
0033-install-libs-depend-on-the-toollibs.patch \
0034-POSIX-ify-the-SHELL-variable.patch \
0035-Handle-ORIGINAL_PATH-just-like-PATH.patch \
0036-uname-allow-setting-the-system-name-to-CYGWIN.patch
0036-uname-allow-setting-the-system-name-to-CYGWIN.patch \
0037-fixup-Revert-Default-to-disable_pcon.patch \
0038-Pass-environment-variables-with-empty-values.patch \
0039-Optionally-disallow-empty-environment-values-again.patch \
0040-build_env-respect-the-MSYS-environment-variable.patch
}
build() {