Subject: Re: [Debconf-devel] Bug#439763: debconf: hangs on puppet installs on preseed install

From: John Morrissey <[email-masked]>
Date: Thu, 23 Aug 2012 10:33:02 -0700

On Thu, Aug 23, 2012 at 11:42:44AM +0200, Juan Carlos Moreno [ackstorm] wrote:
> Oppsss, sorry! I have made a lot of changes...
> 
> Redirecting puppet logdest is not the solution but setting
> 'DEBCONF_REDIR' to empty, it works!
> 
> This is how I call puppet, and it works for me (now):
> 
> [..]
> env = environ.copy()
> env['DEBCONF_DEBUG']='developer'
> env['DEBCONF_REDIR']=''
> p = Popen(['puppet', 'apply', '--detailed-exitcodes',
>            '--debug','--apply', data_pson],
>             cwd=cwd, stdin=None, env=env)
> stdout, stderr = p.communicate()
> [..]

Thanks for the info, Juan.

At least for me with d-i wheezy beta1, if I only unset DEBCONF_REDIR,
scripts in the chroot still try to communicate with the d-i debconf frontend
(outside the chroot), and block because something seems amiss with the file
descriptor manipulation. I suspect this is because DEBCONF_HAS_FRONTEND is
still set, so confmodule doesn't spawn a different frontend.

As a result, man-db.postinst's call to db_version emits the debconf command
to stdout, where it gets caught by log-output (if I chroot my script with
in-target, the same blocked postinst happens if I simply chroot my script):

    Aug 23 16:55:01 log-output: VERSION 2.0

And the postinst blocks on reading the unchrooted debconf frontend's
response, since the frontend never got the request:

root     12444  0.1  5.2  62140 26556 tty1     S+   16:54   0:00
   \_ apt-get -y install php5-cli
root     12461  0.0  2.1  29580 10760 tty1     S+   16:55   0:00
     \_ /usr/bin/dpkg --status-fd 22 --unpack --auto-deconfigure /var/cache/apt/archives/php5-common_5.4.4-4_amd64.deb /var/cache/apt/archives/php5-cli_5.4.4-4_amd64.deb
root     12483  0.0  0.1   4164   628 tty1     S+   16:55   0:00
       \_ /bin/sh -e /var/lib/dpkg/info/man-db.postinst triggered /usr/share/man

root@debian:/# strace -p 12483
Process 12483 attached - interrupt to quit
read(0, ^C <unfinished ...>
root@debian:/# lsof -p 12483 | grep 0[rwu]
man-db.po 12483 root    0r  FIFO    0,8      0t0   3215 pipe

root       235  1.1  3.9  50268 20180 tty1     S+   16:39   0:14 debconf -o d-i /usr/bin/main-menu

root@debian:/# lsof -p 235 | grep 3125
debconf 235 root    4w  FIFO                0,8      0t0 3215 pipe

I also tried unsetting DEBIAN_HAS_FRONTEND, so a separate debconf frontend
gets spawned in the chroot. Unfortunately, the chrooted frontend apparently
can't interact with the console, since its 0 and 1 FDs are still pipes to
the unchrooted debconf frontend.

If I unset DEBCONF_REDIR and DEBIAN_HAS_FRONTEND, then use 'debconf-disconnect
chroot /target myscript', Puppet package installations still get EBADF when
trying to interact with file descriptor 3.

john
-- 
John Morrissey          _o            /\         ----  __o
[email-masked]        _-< \_          /  \       ----  <  \,
www.horde.net/    __(_)/_(_)________/    \_______(_) /_(_)__