tags 1061480 + patch
thanks

I've written a draft patch for this, at
https://salsa.debian.org/pkg-debconf/debconf/-/merge_requests/18 . I've
also attached it here.

I'm happy to try other approaches for this, as well; this was the
simplest.
>From f8614d612b3474fa68d5747417ff5f62204daa81 Mon Sep 17 00:00:00 2001
Message-ID: <f8614d612b3474fa68d5747417ff5f62204daa81.1727732536.git.j...@joshtriplett.org>
From: Josh Triplett <[email protected]>
Date: Mon, 30 Sep 2024 14:35:23 -0700
Subject: [PATCH] Make the Teletype frontend fail if no user input is available

Other text-based frontends can fail if they don't have a TTY, but the
Teletype frontend always assumes it can work, even if input is hooked up
to `/dev/null`. This means Debconf can never fall back to the
Noninteractive frontend. This causes problems within noninteractive
environments such as CI or similar, if users don't know (or forget) to
set `DEBIAN_FRONTEND=noninteractive`.

Add a prompt to ensure that user input is available. This way, if input
is attached to `/dev/null` and no terminal is available on `/dev/tty`,
Debconf will by default fall back from Dialog (fails if no TTY) to
Readline (fails if no TTY) to Teletype (fails if no user input
available) all the way to Noninteractive.

Closes: #1061480
---
 Debconf/FrontEnd/Teletype.pm | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/Debconf/FrontEnd/Teletype.pm b/Debconf/FrontEnd/Teletype.pm
index 9c1ad5b8..bce908ae 100644
--- a/Debconf/FrontEnd/Teletype.pm
+++ b/Debconf/FrontEnd/Teletype.pm
@@ -38,6 +38,10 @@ How many lines have been displayed since the last pause.
 sub init {
 	my $this=shift;
 
+	local $|=1;
+	print gettext("Press Enter to use the teletype frontend.")."\n";
+	my $ret=<STDIN>;
+	defined $ret || die gettext("Got EOF; assuming no input possible.")."\n";
 	$this->SUPER::init(@_);
 	$this->interactive(1);
 	$this->linecount(0);
-- 
2.45.2

Reply via email to