Просмотр исходного кода

fix regression that APT::Keep-Fds is not honored (closes: #730490)

Michael Vogt лет назад: 12
Родитель
Сommit
96ae6de5d3
4 измененных файлов с 23 добавлено и 9 удалено
  1. 18 8
      apt-pkg/contrib/fileutl.cc
  2. 1 0
      apt-pkg/contrib/fileutl.h
  3. 2 0
      apt-pkg/deb/dpkgpm.cc
  4. 2 1
      debian/changelog

+ 18 - 8
apt-pkg/contrib/fileutl.cc

@@ -760,16 +760,13 @@ bool WaitFd(int Fd,bool write,unsigned long timeout)
    return true;
 }
 									/*}}}*/
-// ExecFork - Magical fork that sanitizes the context before execing	/*{{{*/
+// MergeKeepFdsFromConfiguration - Merge APT::Keep-Fds configuration	/*{{{*/
 // ---------------------------------------------------------------------
-/* This is used if you want to cleanse the environment for the forked 
-   child, it fixes up the important signals and nukes all of the fds,
-   otherwise acts like normal fork. */
-pid_t ExecFork()
+/* This is used to merge the APT::Keep-Fds with the provided KeepFDs
+ * set.
+ */
+void MergeKeepFdsFromConfiguration(std::set<int> &KeepFDs)
 {
-      set<int> KeepFDs;
-
-      // FIXME: remove looking at APT::Keep-Fds eventually, its a hack
       Configuration::Item const *Opts = _config->Tree("APT::Keep-Fds");
       if (Opts != 0 && Opts->Child != 0)
       {
@@ -782,6 +779,19 @@ pid_t ExecFork()
 	    KeepFDs.insert(fd);
 	 }
       }
+}
+									/*}}}*/
+// ExecFork - Magical fork that sanitizes the context before execing	/*{{{*/
+// ---------------------------------------------------------------------
+/* This is used if you want to cleanse the environment for the forked 
+   child, it fixes up the important signals and nukes all of the fds,
+   otherwise acts like normal fork. */
+pid_t ExecFork()
+{
+      set<int> KeepFDs;
+      // we need to merge the Keep-Fds as external tools like 
+      // debconf-apt-progress use it
+      MergeKeepFdsFromConfiguration(KeepFDs);
       return ExecFork(KeepFDs);
 }
 

+ 1 - 0
apt-pkg/contrib/fileutl.h

@@ -184,6 +184,7 @@ void SetNonBlock(int Fd,bool Block);
 bool WaitFd(int Fd,bool write = false,unsigned long timeout = 0);
 pid_t ExecFork();
 pid_t ExecFork(std::set<int> keep_fds);
+void MergeKeepFdsFromConfiguration(std::set<int> &keep_fds);
 bool ExecWait(pid_t Pid,const char *Name,bool Reap = false);
 
 // File string manipulators

+ 2 - 0
apt-pkg/deb/dpkgpm.cc

@@ -417,6 +417,7 @@ bool pkgDPkgPM::RunScriptsWithPkgs(const char *Cnf)
       
       // Create the pipes
       std::set<int> KeepFDs;
+      MergeKeepFdsFromConfiguration(KeepFDs);
       int Pipes[2];
       if (pipe(Pipes) != 0)
 	 return _error->Errno("pipe","Failed to create IPC pipe to subprocess");
@@ -1380,6 +1381,7 @@ bool pkgDPkgPM::GoNoABIBreak(APT::Progress::PackageManager *progress)
       d->progress->StartDpkg();
       std::set<int> KeepFDs;
       KeepFDs.insert(fd[1]);
+      MergeKeepFdsFromConfiguration(KeepFDs);
       pid_t Child = ExecFork(KeepFDs);
       if (Child == 0)
       {

+ 2 - 1
debian/changelog

@@ -2,8 +2,9 @@ apt (0.9.13.1) unstable; urgency=low
 
   [ Colin Watson ]
   * fix "apt-get  --purge build-dep" (closes: #720597)
+  * fix regression that APT::Keep-Fds is not honored (closes: #730490)
 
- -- Michael Vogt <michael.vogt@ubuntu.com>  Thu, 28 Nov 2013 16:49:31 +0100
+ -- Michael Vogt <mvo@debian.org>  Thu, 28 Nov 2013 16:49:31 +0100
 
 apt (0.9.13) unstable; urgency=low