Fix the interpreter path if procfs is not mounted

This commit is contained in:
Petr Písař 2019-01-15 10:24:40 +01:00
parent 4b2f0d2c0d
commit 67cee652e7
2 changed files with 84 additions and 0 deletions

View File

@ -0,0 +1,77 @@
From 03b94aa47e981af3c7b0118bfb11facda2b95251 Mon Sep 17 00:00:00 2001
From: Aaron Crane <arc@cpan.org>
Date: Tue, 9 Oct 2018 14:41:10 +0100
Subject: [PATCH] RT#133573: $^X fallback when platform-specific technique
fails
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Petr Písař <ppisar@redhat.com>
---
caretx.c | 28 ++++++++++++++++------------
1 file changed, 16 insertions(+), 12 deletions(-)
diff --git a/caretx.c b/caretx.c
index d758f730de..247708de8c 100644
--- a/caretx.c
+++ b/caretx.c
@@ -56,7 +56,19 @@ Perl_set_caret_X(pTHX) {
SV *const caret_x = GvSV(tmpgv);
#if defined(OS2)
sv_setpv(caret_x, os2_execname(aTHX));
-#elif defined(USE_KERN_PROC_PATHNAME)
+ return;
+#elif defined(WIN32)
+ char *ansi;
+ WCHAR widename[MAX_PATH];
+ GetModuleFileNameW(NULL, widename, sizeof(widename)/sizeof(WCHAR));
+ ansi = win32_ansipath(widename);
+ sv_setpv(caret_x, ansi);
+ win32_free(ansi);
+ return;
+#else
+ /* We can try a platform-specific one if possible; if it fails, or we
+ * aren't running on a suitable platform, we'll fall back to argv[0]. */
+# ifdef USE_KERN_PROC_PATHNAME
size_t size = 0;
int mib[4];
mib[0] = CTL_KERN;
@@ -76,7 +88,7 @@ Perl_set_caret_X(pTHX) {
return;
}
}
-#elif defined(USE_NSGETEXECUTABLEPATH)
+# elif defined(USE_NSGETEXECUTABLEPATH)
char buf[1];
uint32_t size = sizeof(buf);
@@ -95,7 +107,7 @@ Perl_set_caret_X(pTHX) {
return;
}
}
-#elif defined(HAS_PROCSELFEXE)
+# elif defined(HAS_PROCSELFEXE)
char buf[MAXPATHLEN];
SSize_t len = readlink(PROCSELFEXE_PATH, buf, sizeof(buf) - 1);
/* NOTE: if the length returned by readlink() is sizeof(buf) - 1,
@@ -125,15 +137,7 @@ Perl_set_caret_X(pTHX) {
sv_setpvn(caret_x, buf, len);
return;
}
-#elif defined(WIN32)
- char *ansi;
- WCHAR widename[MAX_PATH];
- GetModuleFileNameW(NULL, widename, sizeof(widename)/sizeof(WCHAR));
- ansi = win32_ansipath(widename);
- sv_setpv(caret_x, ansi);
- win32_free(ansi);
- return;
-#else
+# endif
/* Fallback to this: */
sv_setpv(caret_x, PL_origargv[0]);
#endif
--
2.17.2

View File

@ -247,6 +247,10 @@ Patch49: perl-5.29.6-perl-133575-prevent-set-longjmp-clobbering-locals-in
# ligatures, RT#133756, in upstream after 5.29.6
Patch50: perl-5.29.6-PATCH-perl-133756-Failure-to-match-properly.patch
# Fix the interpreter path if procfs is not mounted, RT#133573,
# in upstream after 5.29.3
Patch51: perl-5.29.3-RT-133573-X-fallback-when-platform-specific-techniqu.patch
# Link XS modules to libperl.so with EU::CBuilder on Linux, bug #960048
Patch200: perl-5.16.3-Link-XS-modules-to-libperl.so-with-EU-CBuilder-on-Li.patch
@ -2851,6 +2855,7 @@ Perl extension for Version Objects
%patch48 -p1
%patch49 -p1
%patch50 -p1
%patch51 -p1
%patch200 -p1
%patch201 -p1
@ -2895,6 +2900,7 @@ perl -x patchlevel.h \
'Fedora Patch48: Fix un undefined C behavior in NULL pointer arithmetics (RT#133223)' \
'Fedora Patch49: Prevent long jumps from clobbering local variables (RT#133575)' \
'Fedora Patch50: Fix a mismatch with a case-insesitive regular expression on a text with ligatures (RT#133756)' \
'Fedora Patch51: Fix the interpreter path if procfs is not mounted (RT#133573)' \
'Fedora Patch200: Link XS modules to libperl.so with EU::CBuilder on Linux' \
'Fedora Patch201: Link XS modules to libperl.so with EU::MM on Linux' \
%{nil}
@ -5193,6 +5199,7 @@ popd
- Prevent long jumps from clobbering local variables (RT#133575)
- Fix a mismatch with a case-insesitive regular expression on a text with ligatures
(RT#133756)
- Fix the interpreter path if procfs is not mounted (RT#133573)
* Mon Jan 14 2019 Björn Esser <besser82@fedoraproject.org> - 4:5.28.1-429
- Rebuilt for libcrypt.so.2 (#1666033)