diff --git a/msys2-runtime/0031-CI-give-the-cygwin-sync-job-explicit-write-permissio.patch b/msys2-runtime/0031-CI-give-the-cygwin-sync-job-explicit-write-permissio.patch new file mode 100644 index 00000000..9f6b9653 --- /dev/null +++ b/msys2-runtime/0031-CI-give-the-cygwin-sync-job-explicit-write-permissio.patch @@ -0,0 +1,32 @@ +From 42ddcfff2eb94055b35bc68d84ec5faafa982faf Mon Sep 17 00:00:00 2001 +From: Christoph Reiter +Date: Fri, 23 Apr 2021 19:24:33 +0200 +Subject: [PATCH 31/N] CI: give the cygwin sync job explicit write permissions + +So we can change the default repo permissions to read-only +--- + .github/workflows/sync-with-cygwin.yml | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/.github/workflows/sync-with-cygwin.yml b/.github/workflows/sync-with-cygwin.yml +index defcdf8..57bd30e 100644 +--- a/.github/workflows/sync-with-cygwin.yml ++++ b/.github/workflows/sync-with-cygwin.yml +@@ -3,11 +3,14 @@ name: sync-with-cygwin + # File: .github/workflows/repo-sync.yml + + on: ++ workflow_dispatch: + schedule: + - cron: "42 * * * *" + jobs: + repo-sync: + runs-on: ubuntu-latest ++ permissions: ++ contents: write + steps: + - name: Fetch Cygwin's latest master and tags + run: | +-- +2.31.1 + diff --git a/msys2-runtime/0032-Cygwin-path_conv-Try-to-handle-native-symlinks-more-.patch b/msys2-runtime/0032-Cygwin-path_conv-Try-to-handle-native-symlinks-more-.patch new file mode 100644 index 00000000..f5de35de --- /dev/null +++ b/msys2-runtime/0032-Cygwin-path_conv-Try-to-handle-native-symlinks-more-.patch @@ -0,0 +1,119 @@ +From 517744ea36a28d8e1166f8e12b0d88ea9cd9aadc Mon Sep 17 00:00:00 2001 +From: Corinna Vinschen +Date: Mon, 19 Apr 2021 14:49:14 +0200 +Subject: [PATCH 32/N] Cygwin: path_conv: Try to handle native symlinks more + sanely + +For local paths, add a check if the inner path components contain native +symlinks or junctions. Compare the incoming path with the path returned +by NtQueryInformationFile(FileNameInformation). If they differ, there +must be at least one native symlink or junction in the path. If so, +treat the currently evaluated file as non-existant. This forces +path_conv::check to backtrack inner path components until we eliminated +all native symlinks or junctions and have a normalized path. + +Signed-off-by: Corinna Vinschen +(cherry picked from commits 456c3a46386f38887407603b2c64b7f63a4871c5 and +13fd26ecf5ca8417146d57b45aed0133435c3497) +--- + winsup/cygwin/dcrt0.cc | 6 +++++ + winsup/cygwin/globals.cc | 2 ++ + winsup/cygwin/path.cc | 52 ++++++++++++++++++++++++++++++++++++++++ + 3 files changed, 60 insertions(+) + +diff --git a/winsup/cygwin/dcrt0.cc b/winsup/cygwin/dcrt0.cc +index 4683972..579158a 100644 +--- a/winsup/cygwin/dcrt0.cc ++++ b/winsup/cygwin/dcrt0.cc +@@ -742,6 +742,12 @@ init_windows_system_directory () + system_wow64_directory[system_wow64_directory_length++] = L'\\'; + system_wow64_directory[system_wow64_directory_length] = L'\0'; + } ++ /* We need the Windows dir in path.cc. */ ++ wcscpy (windows_directory, windows_system_directory); ++ windows_directory_length = windows_system_directory_length - 1; ++ windows_directory[windows_directory_length] = L'\0'; ++ while (windows_directory[windows_directory_length - 1] != L'\\') ++ windows_directory[--windows_directory_length] = L'\0'; + #endif /* __i386__ */ + } + } +diff --git a/winsup/cygwin/globals.cc b/winsup/cygwin/globals.cc +index 67103f4..a729e70 100644 +--- a/winsup/cygwin/globals.cc ++++ b/winsup/cygwin/globals.cc +@@ -26,6 +26,8 @@ UINT windows_system_directory_length; + #ifdef __i386__ + WCHAR system_wow64_directory[MAX_PATH]; + UINT system_wow64_directory_length; ++WCHAR windows_directory[MAX_PATH]; ++UINT windows_directory_length; + #endif /* __i386__ */ + WCHAR global_progname[NT_MAX_PATH]; + +diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc +index 561d1ac..4121628 100644 +--- a/winsup/cygwin/path.cc ++++ b/winsup/cygwin/path.cc +@@ -3341,6 +3341,58 @@ restart: + status = conv_hdl.get_finfo (h, fs.is_nfs ()); + if (NT_SUCCESS (status)) + fileattr = conv_hdl.get_dosattr (fs.is_nfs ()); ++ ++ /* For local paths, check if the inner path components contain ++ native symlinks or junctions. Compare incoming path with ++ path returned by NtQueryInformationFile(FileNameInformation). ++ If they differ, bail out as if the file doesn't exist. This ++ forces path_conv::check to backtrack inner path components. */ ++ if (!fs.is_remote_drive ()) ++ { ++#ifdef __i386__ ++ /* On WOW64, ignore any potential problems if the path is inside ++ the Windows dir to avoid false positives for stuff under ++ File System Redirector control. */ ++ if (wincap.is_wow64 ()) ++ { ++ static UNICODE_STRING wpath; ++ UNICODE_STRING udpath; ++ ++ /* Create UNICODE_STRING for Windows dir. */ ++ RtlInitCountedUnicodeString (&wpath, windows_directory, ++ windows_directory_length * sizeof (WCHAR)); ++ /* Create a UNICODE_STRING from incoming path, splitting ++ off the leading "\\??\\" */ ++ RtlInitCountedUnicodeString (&udpath, upath.Buffer + 4, ++ upath.Length - 4 * sizeof (WCHAR)); ++ /* Are we below Windows dir? Skip the check for inner ++ symlinks. */ ++ if (RtlEqualUnicodePathPrefix (&udpath, &wpath, TRUE)) ++ goto skip_inner_syml_check; ++ } ++#endif /* __i386__ */ ++ PFILE_NAME_INFORMATION pfni; ++ ++ pfni = (PFILE_NAME_INFORMATION) tp.c_get (); ++ if (NT_SUCCESS (NtQueryInformationFile (h, &io, pfni, NT_MAX_PATH, ++ FileNameInformation))) ++ { ++ UNICODE_STRING npath; ++ ++ RtlInitCountedUnicodeString (&npath, pfni->FileName, ++ pfni->FileNameLength); ++ if (!RtlEqualUnicodePathSuffix (&upath, &npath, !!ci_flag)) ++ { ++ fileattr = INVALID_FILE_ATTRIBUTES; ++ set_error (ENOENT); ++ break; ++ } ++ } ++#ifdef __i386__ ++ skip_inner_syml_check: ++ ; ++#endif /* __i386__ */ ++ } + } + if (!NT_SUCCESS (status)) + { +-- +2.31.1 + diff --git a/msys2-runtime/PKGBUILD b/msys2-runtime/PKGBUILD index 46c32d41..8ec8f401 100644 --- a/msys2-runtime/PKGBUILD +++ b/msys2-runtime/PKGBUILD @@ -4,7 +4,7 @@ pkgbase=msys2-runtime pkgname=('msys2-runtime' 'msys2-runtime-devel') pkgver=3.2.0 -pkgrel=3 +pkgrel=4 pkgdesc="Cygwin POSIX emulation engine" arch=('i686' 'x86_64') url="https://www.cygwin.com/" @@ -52,7 +52,9 @@ source=('msys2-runtime'::git://sourceware.org/git/newlib-cygwin.git#tag=cygwin-$ 0027-Expose-full-command-lines-to-other-Win32-processes-b.patch 0028-Disable-the-cygwin-GitHub-workflow.patch 0029-Do-not-show-Error-dialogs-by-default.patch - 0030-uname-limit-sysname-to-MSYS-or-MINGW.patch) + 0030-uname-limit-sysname-to-MSYS-or-MINGW.patch + 0031-CI-give-the-cygwin-sync-job-explicit-write-permissio.patch + 0032-Cygwin-path_conv-Try-to-handle-native-symlinks-more-.patch) sha256sums=('SKIP' '605f3f31dcca983fad2659f2d8f3531217e3f133757b40b0977e6a17c406c147' '5d120d24ce55ef08bf459781610e32c4a8e5e0eac73971a60e80590c6432d940' @@ -83,7 +85,9 @@ sha256sums=('SKIP' '6a2dffa890ea1694a76333388bfcdb5bcc67d3a431e70064342002662909d366' 'd18402a2c75e099a9cafd0ce7eba01476728c825812d4516ebc240e3c494fe4e' '969ace2675ebec747d0ccfe2540210ebac9974973b8b93325aecb53351514b76' - '301422428472f693ad3a659b1279c969d5457eaab77be4dc0a389b2f5c5b6a55') + '301422428472f693ad3a659b1279c969d5457eaab77be4dc0a389b2f5c5b6a55' + 'acbf8e7fea8089d474a63d8e12fd68e13f33967911eb785895183619c4307092' + 'ab78d325691fa6af631a73c3292537263b58a53eb0ab35c65d431a8536e8e12c') # Helper macros to help make tasks easier # apply_patch_with_msg() { @@ -150,7 +154,9 @@ prepare() { 0027-Expose-full-command-lines-to-other-Win32-processes-b.patch \ 0028-Disable-the-cygwin-GitHub-workflow.patch \ 0029-Do-not-show-Error-dialogs-by-default.patch \ - 0030-uname-limit-sysname-to-MSYS-or-MINGW.patch + 0030-uname-limit-sysname-to-MSYS-or-MINGW.patch \ + 0031-CI-give-the-cygwin-sync-job-explicit-write-permissio.patch \ + 0032-Cygwin-path_conv-Try-to-handle-native-symlinks-more-.patch } build() {