apt-get does not correctly close its "progress monitoring" filedescriptor when invoking postinst scripts

Bug #136767 reported by AlainKnaff
2
Affects Status Importance Assigned to Milestone
apt (Ubuntu)
Fix Released
Undecided
Unassigned

Bug Description

Binary package hint: apt

(Observed in Kubuntu 7.04)

During initial install of a Kubuntu system, the installer is invoking apt-get through the progress monitoring script debconf-apt-progress. Communication between that script and apt-get apparently happens via a pipe to which apt-get writes its progress messages.

The problem is that apt-get inadvertedly passes its end of the pipe to its sub-processes (such as postinst scripts of the installed packages). If the package's postinst script start a daemon (as is being done by webmin), this daemon will inherit that filedescriptor as well.

However debconf-apt-progress waits for an EOF event on that filedescriptor before it considers the command to be done. If the pipe is held open by a long running daemon as described above, it will wait forever.

Fix: apt-get should set close-on-exec on that filedescriptor.

Related branches

Revision history for this message
Michael Vogt (mvo) wrote :

I commited a fix for this in my bzr repository for gutsy.

I would be interessted in a easy way to reproduce the error so that I can verify that the fix really works.

Thanks,
 Michael

Changed in apt:
status: New → Fix Committed
Revision history for this message
AlainKnaff (kubuntu-misc) wrote :

Thanks.

To reproduce the error, you need to set up a customized Kubuntu install CD which includes webmin 1.360 (webmin's .deb may be downloaded from http://webmin.com/) among the packages to be installed by default. With the error, the automatic install will hang just after installation of webmin (because the UI will wait for the pipe to close).

However, due to another bug in Webmin, webmin's doesn't correctly recognize gutsy as a Debian distro, and so will fail to correctly set up its /etc/init.d script. Due to this, the hang will probably *not* happen in any case (... because the daemon will not start at all). In order to properly reproduce the bug, you'd need a feisty distro. Or arrange for the distro version in /etc/issue to be numeric (7.10) rather than alphabetic (gutsy).

Ubuntu gutsy (development branch) \n \l => not ok
Ubuntu 7.04 \n \l => ok

Another remark: with one week more experience with the (K)ubuntu install process, I'm now wondering whether this "stray" open filedescriptor wasn't left open intentionally. Indeed, could it be that this is needed in case postinst scripts want to access the UI (for instance, in order to pop up dialog boxes with config questions?).
If yes, then the error would be really webmin's and not apt-get's, and you may disregard this bug report. In that case, sorry for the confusion.

Revision history for this message
Michael Vogt (mvo) wrote :

apt (0.7.6ubuntu9) gutsy; urgency=low

  * apt-pkg/deb/dpkgpm.cc:
    - fix progress reporting precent calculation (LP: #137798)
  * make apt build with g++ 4.3
  * fix missing SetExecClose() call when the status-fd is used
    (LP: #136767)
  * debian/apt.cron.daily:
    - move unattended-upgrade before apt-get autoclean
  * fix "purge" commandline argument, closes LP: #125733
    (thanks to Julien Danjou for the patch)
  * cmdline/apt-get.cc:
    - do not change the auto-installed information if a package
      is reinstalled (LP: #139448)

 -- Michael Vogt <email address hidden> Tue, 11 Sep 2007 20:55:00 +0200

Changed in apt:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.