[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#730490: apt: invoking dpkg no longer respects APT::Keep-Fds



Package: apt
Version: 0.9.13
Severity: grave
Justification: breaks d-i
Tags: patch
User: ubuntu-devel@lists.ubuntu.com
Usertags: origin-ubuntu ubuntu-patch trusty

This bug originated as:

  https://bugs.launchpad.net/bugs/1254696

The ExecFork refactoring in 0.9.13~exp1 broke d-i, because APT::Keep-Fds
is no longer respected when invoking dpkg.  Here's a patch, although
perhaps you want this laid out in some way that duplicates less code;
however I couldn't readily see how to do that without just undoing the
refactoring.

I spent a couple of hours trying to write an integration test that
exercises the whole debconf-apt-progress path.  I failed because that
requires actually executing the postinst in a test package, which
requires chrooting because we use dpkg --root, and I couldn't get
fakechroot to do the right thing.  Suggestions gratefully appreciated if
you think this is important.

  * Fix two subprocess calls to continue to honour APT::Keep-Fds
    (LP: #1254696).

diff -Nru apt-0.9.13~exp1ubuntu1/apt-pkg/deb/dpkgpm.cc apt-0.9.13~exp1ubuntu2/apt-pkg/deb/dpkgpm.cc
--- apt-0.9.13~exp1ubuntu1/apt-pkg/deb/dpkgpm.cc	2013-11-23 08:18:03.000000000 +0000
+++ apt-0.9.13~exp1ubuntu2/apt-pkg/deb/dpkgpm.cc	2013-11-25 13:18:34.000000000 +0000
@@ -416,6 +416,18 @@
       
       // Create the pipes
       std::set<int> KeepFDs;
+      Configuration::Item const *KeepFDsOpts = _config->Tree("APT::Keep-Fds");
+      if (KeepFDsOpts != 0 && KeepFDsOpts->Child != 0)
+      {
+	 KeepFDsOpts = KeepFDsOpts->Child;
+	 for (; KeepFDsOpts != 0; KeepFDsOpts = KeepFDsOpts->Next)
+	 {
+	    if (KeepFDsOpts->Value.empty() == true)
+	       continue;
+	    int fd = atoi(KeepFDsOpts->Value.c_str());
+	    KeepFDs.insert(fd);
+	 }
+      }
       int Pipes[2];
       if (pipe(Pipes) != 0)
 	 return _error->Errno("pipe","Failed to create IPC pipe to subprocess");
@@ -1378,6 +1390,18 @@
       // now run dpkg
       d->progress->StartDpkg();
       std::set<int> KeepFDs;
+      Configuration::Item const *KeepFDsOpts = _config->Tree("APT::Keep-Fds");
+      if (KeepFDsOpts != 0 && KeepFDsOpts->Child != 0)
+      {
+	 KeepFDsOpts = KeepFDsOpts->Child;
+	 for (; KeepFDsOpts != 0; KeepFDsOpts = KeepFDsOpts->Next)
+	 {
+	    if (KeepFDsOpts->Value.empty() == true)
+	       continue;
+	    int fd = atoi(KeepFDsOpts->Value.c_str());
+	    KeepFDs.insert(fd);
+	 }
+      }
       KeepFDs.insert(fd[1]);
       pid_t Child = ExecFork(KeepFDs);
       if (Child == 0)

Thanks,

-- 
Colin Watson                                       [cjwatson@ubuntu.com]


Reply to: