[Debconf-devel] Bug#929417: debconf: Readline frontend should check that stdin is a tty (to fix Docker build freezes)

Anders Kaseorg andersk at mit.edu
Thu May 23 04:36:43 BST 2019


Package: debconf
Version: 1.5.72
Tags: patch

When building a Debian- or Ubuntu-based Docker container, installing
perl (so that Term::Readline is available) and a package that asks a
Debconf question causes the build to freeze with an interactive readline
prompt that cannot be answered:

     $ cat Dockerfile
     FROM debian:sid-20190506-slim
     RUN apt-get update
     RUN apt-get -y --no-install-recommends install perl keyboard-configuration

     $ docker build .
     […]
     Setting up keyboard-configuration (1.191) ...
     debconf: unable to initialize frontend: Dialog
     debconf: (TERM is not set, so the dialog frontend is not usable.)
     debconf: falling back to frontend: Readline
     Configuring keyboard-configuration
     ----------------------------------

     Please select the layout matching the keyboard for this machine.

       1. English (US)
     […]
       21. Other
     Keyboard layout:

Docker builds are noninteractive, of course, and stdin is connected to 
/dev/null.  What seems to have happened here is that apt created a pty and 
connected stdout and stderr to it, but left stdin connected to /dev/null. 
The Readline frontend checked that there’s a controlling tty (there is), 
but failed to check that stdin is a tty (it’s not).  So it proceeded to 
wait for input from a tty that will never provide it.

(Obviously one can set DEBIAN_FRONTEND=noninteractive as a workaround, but 
that shouldn’t be necessary, and is in fact discouraged: 
https://docs.docker.com/engine/faq/#why-is-debian_frontendnoninteractive-discouraged-in-dockerfiles 
because it’s often set in ways that persist for longer than intended.)

I’ll let the maintainers decide whether it’s worth updating the translated 
error message to be more technically accurate.

--- a/Debconf/FrontEnd/Readline.pm
+++ b/Debconf/FrontEnd/Readline.pm
@@ -44,8 +44,7 @@ sub init {
  	$this->SUPER::init(@_);

  	# Yeah, you need a controlling tty. Make sure there is one.
-	open(TESTTY, "/dev/tty") || die gettext("This frontend requires a controlling tty.")."\n";
-	close TESTTY;
+	-t STDIN || die gettext("This frontend requires a controlling tty.")."\n";

  	$Term::ReadLine::termcap_nowarn = 1; # Turn off stupid termcap warning.
  	$this->readline(Term::ReadLine->new('debconf'));


More information about the Debconf-devel mailing list