summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYoufu Zhang <zhangyoufu@gmail.com>2021-01-22 17:41:22 +0800
committerYoufu Zhang <zhangyoufu@gmail.com>2021-01-22 23:41:12 +0800
commitacbe227d50178657d98a609221b1caa5b128d7bb (patch)
tree242cba23ecf330190ea1e522e010bdb37d0c535a
parentcef9e97fec59c5e09ec37646168cfd1cf57fd24b (diff)
dpkg: fix passing readonly /dev/null fd as stdout/stderr
The read-only /dev/null was duplicated to stdout and stderr, causing writes to those descriptors to fail: [pid 260] openat(AT_FDCWD, "/dev/null", O_RDONLY) = 7 [pid 260] dup2(7, 0) = 0 [pid 260] close(5) = 0 [pid 260] dup2(6, 1) = 1 [pid 260] dup2(7, 2) = 2 [pid 260] write(2, "Chrooting into ", 15) = -1 EBADF (Bad file descriptor) [pid 260] chroot("/chroot/") = 0
-rw-r--r--apt-pkg/deb/debsystem.cc2
1 files changed, 1 insertions, 1 deletions
diff --git a/apt-pkg/deb/debsystem.cc b/apt-pkg/deb/debsystem.cc
index eac43c3b7..a0200305d 100644
--- a/apt-pkg/deb/debsystem.cc
+++ b/apt-pkg/deb/debsystem.cc
@@ -420,7 +420,7 @@ pid_t debSystem::ExecDpkg(std::vector<std::string> const &sArgs, int * const inp
pid_t const dpkg = ExecFork();
if (dpkg == 0) {
- int const nullfd = open("/dev/null", O_RDONLY);
+ int const nullfd = open("/dev/null", O_RDWR);
if (inputFd == nullptr)
dup2(nullfd, STDIN_FILENO);
else