ash,hush: fix "saved" redirected fds still visible in children

Based on a patch by Mark Marshall <mark.marshall@omicronenergy.com>

function                                             old     new   delta
dup_CLOEXEC                                            -      49     +49
fcntl_F_DUPFD                                         46       -     -46

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
Denys Vlasenko
2018-03-28 18:35:07 +02:00
parent e4defe826b
commit 9acd63c92c
14 changed files with 92 additions and 13 deletions

View File

@ -0,0 +1,5 @@
/proc/self/fd
/proc/self/fd/0
/proc/self/fd/1
/proc/self/fd/2
/proc/self/fd/3

View File

@ -0,0 +1,6 @@
# The "find" should not see "saved" (duplicated) fd #1
# Explicitly use bbox find, since other implementations of "find"
# may open other descriptors as well.
busybox find /proc/self/fd >tmp_$$.out
cat tmp_$$.out
rm -f tmp_$$.out

View File

@ -0,0 +1,5 @@
/proc/self/fd
/proc/self/fd/0
/proc/self/fd/1
/proc/self/fd/2
/proc/self/fd/3

View File

@ -0,0 +1,6 @@
# The "find" should not see "saved" (duplicated) fd #1
# Explicitly use bbox find, since other implementations of "find"
# may open other descriptors as well.
{ busybox find /proc/self/fd; } >tmp_$$.out
cat tmp_$$.out
rm -f tmp_$$.out

View File

@ -0,0 +1,5 @@
/proc/self/fd
/proc/self/fd/0
/proc/self/fd/1
/proc/self/fd/2
/proc/self/fd/3

View File

@ -0,0 +1,6 @@
# The "find" should not see "saved" (duplicated) fd #1
# Explicitly use bbox find, since other implementations of "find"
# may open other descriptors as well.
{ busybox find /proc/self/fd; true; } >tmp_$$.out
cat tmp_$$.out
rm -f tmp_$$.out