Commit 63ed8f89 authored by Niko Tyni's avatar Niko Tyni

Apply upstream patches marking pipes in pipe-open inherit-on-exec

Closes: #916313
parents 36ac9567 6dd4a8a2
# see git-dpm(1) from git-dpm package
95b26439b0a3f04b67b6102515139febdeb704db
95b26439b0a3f04b67b6102515139febdeb704db
6dd4a8a26654a282da120b402eb53ed9ffa59cb1
6dd4a8a26654a282da120b402eb53ed9ffa59cb1
533cd3622b6a61a362e7538a26e25b244ca799f2
533cd3622b6a61a362e7538a26e25b244ca799f2
perl_5.28.1.orig.tar.xz
......
From 275485f8faa4e3b7af3c838ea40b237ae5ef4b35 Mon Sep 17 00:00:00 2001
From: Leon Timmermans <fawaka@gmail.com>
Date: Sat, 15 Dec 2018 19:08:41 +0100
Subject: Always mark pipe in pipe-open as inherit-on-exec
Since 2cdf406a a lot of file descriptors are opened close-on-exec,
including the pipe that is passed to the child process in a pipe-open.
This is usually fine because a dup2 follows to rename that handle to
stdin/stdout that will set the inherit-on-exec. However, if the pipe
descriptor already has the right value, for example because stdin was
closed, then no dup2 happens and hence it's still marked as
close-on-exec right when we want to perform an exec.
This patch explicitly marks such a handle as inherit-on-exec, to ensure
it will be open for the child process.
Origin: upstream, https://perl5.git.perl.org/perl.git/commit/c6fe5b981b942ddabb23ed4b7602067e906e6d88
Bug: https://rt.perl.org/Public/Bug/Display.html?id=133726
Bug-Debian: https://bugs.debian.org/916313
Patch-Name: fixes/pipe-inherit-on-exec/part1.diff
---
util.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/util.c b/util.c
index 842cc953e..17dfda9bc 100644
--- a/util.c
+++ b/util.c
@@ -2441,8 +2441,10 @@ Perl_my_popen(pTHX_ const char *cmd, const char *mode)
if (p[THAT] != (*mode == 'r')) /* if dup2() didn't close it */
PerlLIO_close(p[THAT]);
}
- else
+ else {
+ setfd_cloexec_or_inhexec_by_sysfdness(p[THIS]);
PerlLIO_close(p[THAT]);
+ }
#ifndef OS2
if (doexec) {
#if !defined(HAS_FCNTL) || !defined(F_SETFD)
From 6dd4a8a26654a282da120b402eb53ed9ffa59cb1 Mon Sep 17 00:00:00 2001
From: Leon Timmermans <fawaka@gmail.com>
Date: Sun, 16 Dec 2018 01:05:06 +0100
Subject: Always mark pipe in list pipe-open as inherit-on-exec
This is the my_popen_list counterpart of
c6fe5b981b942ddabb23ed4b7602067e906e6d88
Origin: upstream, https://perl5.git.perl.org/perl.git/commit/30c869b87739b56280daca3cd44b0588144747b7
Bug: https://rt.perl.org/Public/Bug/Display.html?id=133726
Bug-Debian: https://bugs.debian.org/916313
Patch-Name: fixes/pipe-inherit-on-exec/part2.diff
---
util.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/util.c b/util.c
index 17dfda9bc..25b5c6601 100644
--- a/util.c
+++ b/util.c
@@ -2302,8 +2302,10 @@ Perl_my_popen_list(pTHX_ const char *mode, int n, SV **args)
if (p[THAT] != (*mode == 'r')) /* if dup2() didn't close it */
PerlLIO_close(p[THAT]); /* close parent's end of _the_ pipe */
}
- else
+ else {
+ setfd_cloexec_or_inhexec_by_sysfdness(p[THIS]);
PerlLIO_close(p[THAT]); /* close parent's end of _the_ pipe */
+ }
#if !defined(HAS_FCNTL) || !defined(F_SETFD)
/* No automatic close - do it by hand */
# ifndef NOFILE
......@@ -55,3 +55,5 @@ fixes/fix-manifest-failures.diff
fixes/storable-probing/prereq1.diff
fixes/storable-probing/prereq2.diff
fixes/storable-probing/disable-probing.diff
fixes/pipe-inherit-on-exec/part1.diff
fixes/pipe-inherit-on-exec/part2.diff
......@@ -2302,8 +2302,10 @@ Perl_my_popen_list(pTHX_ const char *mode, int n, SV **args)
if (p[THAT] != (*mode == 'r')) /* if dup2() didn't close it */
PerlLIO_close(p[THAT]); /* close parent's end of _the_ pipe */
}
else
else {
setfd_cloexec_or_inhexec_by_sysfdness(p[THIS]);
PerlLIO_close(p[THAT]); /* close parent's end of _the_ pipe */
}
#if !defined(HAS_FCNTL) || !defined(F_SETFD)
/* No automatic close - do it by hand */
# ifndef NOFILE
......@@ -2441,8 +2443,10 @@ Perl_my_popen(pTHX_ const char *cmd, const char *mode)
if (p[THAT] != (*mode == 'r')) /* if dup2() didn't close it */
PerlLIO_close(p[THAT]);
}
else
else {
setfd_cloexec_or_inhexec_by_sysfdness(p[THIS]);
PerlLIO_close(p[THAT]);
}
#ifndef OS2
if (doexec) {
#if !defined(HAS_FCNTL) || !defined(F_SETFD)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment