Package: needrestart
Version: 2.11-3
Severity: important
Tags: upstream patch
Dear Maintainer,
the problem described in the archived bug #803249 still exists in 2.11-3
(Debian 9.1). When needrestart is run without a tty AND with
DEBIAN_FRONTEND=noninteractive, it still tries to work interactively rather
than fall back to "list only" mode. In some cases it causes unwanted restarts.
The easiest way to reproduce it is to run needrestart from cron, redirecting
the output to a file.
I attach a patch that may work, but I'm not sure, as I know Perl only a little
and don't know other implementation details. In my case it is working as
expected.
The problem is rather serious. I use Ansible for automation and once I run it
to install something on an OpenVZ host. After installation by apt-get,
needrestart started to restart VZ containers, including the one from which
Ansible was run. I ended up with all the containers stopped!
Regards,
Piotr
-- System Information:
Debian Release: 9.1
APT prefers stable-updates
APT policy: (500, 'stable-updates'), (500, 'stable')
Architecture: amd64 (x86_64)
Kernel: Linux 2.6.32.bsd54g54 (SMP w/24 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8),
LANGUAGE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: sysvinit (via /sbin/init)
Versions of packages needrestart depends on:
ii dpkg 1.18.24
ii gettext-base 0.19.8.1-2
ii libintl-perl 1.26-2
ii libmodule-find-perl 0.13-1
ii libmodule-scandeps-perl 1.23-1
ii libproc-processtable-perl 0.53-2
ii libsort-naturally-perl 1.03-1
ii libterm-readkey-perl 2.37-1
ii perl 5.24.1-3+deb9u1
ii xz-utils 5.2.2-1.2+b1
Versions of packages needrestart recommends:
ii sysvinit-core 2.88dsf-59.9
Versions of packages needrestart suggests:
pn needrestart-session | libnotify-bin <none>
-- no debconf information
--- needrestart-2.11.orig/needrestart
+++ needrestart-2.11/needrestart
@@ -181,7 +181,7 @@ $nrconf{ui} = qq(NeedRestart::UI::stdio)
die "Hook directory '$nrconf{hook_d}' is invalid!\n" unless(-d $nrconf{hook_d}
|| $opt_b);
$opt_r = $nrconf{restart} unless(defined($opt_r));
die "ERROR: Unknown restart option '$opt_r'!\n" unless($opt_r =~ /^(l|i|a)$/);
-$is_tty++ if($opt_r eq 'i' && exists($ENV{DEBIAN_FRONTEND}) &&
$ENV{DEBIAN_FRONTEND} eq 'noninteractive');
+$is_tty = 0 if($opt_r eq 'i' && exists($ENV{DEBIAN_FRONTEND}) &&
$ENV{DEBIAN_FRONTEND} eq 'noninteractive');
$opt_r = 'l' if(!$is_tty && $opt_r eq 'i');
$opt_m = $nrconf{ui_mode} unless(defined($opt_m));