From df041a065637b258db7a373c6ea295378e53249546f28eeb4e35a82323d95f1a Mon Sep 17 00:00:00 2001 From: Reinhard Max Date: Mon, 10 May 2021 14:07:34 +0000 Subject: [PATCH] - bsc#1183904, expect-errorfd.patch: errorfd file descriptors should be closed when forking OBS-URL: https://build.opensuse.org/package/show/devel:languages:tcl/expect?expand=0&rev=29 --- expect-errorfd.patch | 44 ++++++++++++++++++++++++++++++++++++++++++++ expect.changes | 6 ++++++ expect.spec | 2 ++ 3 files changed, 52 insertions(+) create mode 100644 expect-errorfd.patch diff --git a/expect-errorfd.patch b/expect-errorfd.patch new file mode 100644 index 0000000..b72842f --- /dev/null +++ b/expect-errorfd.patch @@ -0,0 +1,44 @@ +Index: exp_clib.c +================================================================== +--- exp_clib.c ++++ exp_clib.c +@@ -2043,11 +2043,16 @@ + + #endif /* SYSV3 */ + #endif /* DO_SETSID */ + + /* save error fd while we're setting up new one */ ++#ifdef F_DUPFD_CLOEXEC ++ errorfd = fcntl(2,F_DUPFD_CLOEXEC,3); ++#else + errorfd = fcntl(2,F_DUPFD,3); ++ fcntl(errorfd, F_SETFD, FD_CLOEXEC); ++#endif /* F_DUPFD_CLOXEC */ + /* and here is the macro to restore it */ + #define restore_error_fd {close(2);fcntl(errorfd,F_DUPFD,2);} + + if (exp_autoallocpty) { + + +Index: exp_command.c +================================================================== +--- exp_command.c ++++ exp_command.c +@@ -1159,11 +1159,16 @@ + + /* save stderr elsewhere to avoid BSD4.4 bogosity that warns */ + /* if stty finds dev(stderr) != dev(stdout) */ + + /* save error fd while we're setting up new one */ ++#ifdef F_DUPFD_CLOEXEC ++ errorfd = fcntl(2,F_DUPFD_CLOEXEC,3); ++#else + errorfd = fcntl(2,F_DUPFD,3); ++ fcntl(errorfd, F_SETFD, FD_CLOEXEC); ++#endif /* F_DUPFD_CLOXEC */ + /* and here is the macro to restore it */ + #define restore_error_fd {close(2);fcntl(errorfd,F_DUPFD,2);} + + close(0); + close(1); + diff --git a/expect.changes b/expect.changes index 85bb4fa..51fccf5 100644 --- a/expect.changes +++ b/expect.changes @@ -1,3 +1,9 @@ +------------------------------------------------------------------- +Mon May 10 13:44:24 UTC 2021 - Reinhard Max + +- bsc#1183904, expect-errorfd.patch: + errorfd file descriptors should be closed when forking + ------------------------------------------------------------------- Tue May 4 11:02:42 UTC 2021 - Matthias Gerstner diff --git a/expect.spec b/expect.spec index 4f7c274..d8533a2 100644 --- a/expect.spec +++ b/expect.spec @@ -29,6 +29,7 @@ Patch1: expect.patch Patch2: expect-fixes.patch Patch3: expect-log.patch Patch4: config-guess-sub-update.patch +Patch5: expect-errorfd.patch BuildRequires: autoconf BuildRequires: tcl-devel @@ -57,6 +58,7 @@ expect package loaded. %patch2 %patch3 %patch4 +%patch5 %build export CFLAGS="%{optflags} -fPIC -pie"