The code around whether the server requires a restart on Centos6 (only tested Centos relesase at this stage) is incorrect. The command "needs-restarting" deos NOT accept the "-r" parameter:
[root@centos6test webmin]# needs-restarting -r
Usage:
needs-restarting: Report a list of process ids of programs that started
running before they or some component they use were updated.
needs-restarting: error: no such option: -r
[root@centos6test webmin]#
The package-updates/package-updates-lib.pl @ sub check_reboot_required has the following code:
sub check_reboot_required
{
if ($gconfig{'os_type'} eq 'debian-linux') {
return -e "/var/run/reboot-required" ? 1 : 0;
}
elsif ($gconfig{'os_type'} eq 'redhat-linux' &&
&has_command("needs-restarting")) {
my $ex = &execute_command(
"needs-restarting -r", undef, undef, undef, 0, 1);
return $ex ? 1 : 0;
}
return 0;
}
and always returns 1 as the result of the error returns a status of 2.
This will mean that users with Centos6 servers will be unnecessarily restarting their servers.
Update: Centos7 is correct in that it has the "-r" option for needs-restarting:
[root@centos7test ~]# needs-restarting -h
Usage:
needs-restarting: Report a list of process ids of programs that started
running before they or some component they use were updated.
Options:
-h, --help show this help message and exit
-u, --useronly show processes for my userid only
-r, --reboothint only report whether a full reboot is required (returns 1)
or not (returns 0)
-s, --services list the affected systemd services only
[root@centos7test ~]#
I believe that the correct code should be:
elsif ($gconfig{'os_type'} eq 'redhat-linux' && $gconfig{'os_version'} >= 15 &&
&has_command("needs-restarting")) {
as Centos6 has os_version as 14 and Centos7 has os_version as 15.
On Centos 6 no -r option:
needs-restarting -h
Usage:
needs-restarting: Report a list of process ids of programs that started
running before they or some component they use were updated.
Options:
-h, --help show this help message and exit
-u, --useronly show processes for my userid only
Okay,
It's very sad that the old version of
needs-restarting
doesn't have explicit switch (-r
) to test if restart is needed, while later command version (on CentOS 7) has it. What is worse, that latest command version (on Fedora) again doesn't have-r
switch.Okay, to prevent false positive alerts and still to let this function work, I made a commit and a fix. Give it a try:
https://github.com/webmin/webmin/commit/cbe670e664b6b64f64642b58823460d298f18963
Last edit: Ilia 2019-07-12
Tested on CentOS Linux 6.10.
Fixed.
Thanks
Thanks Ilia. I have tested on Centos6.10 and Centos7 - works fine. Can it be packaged up to V1.921?
Yes, this will be included in the 1.921 release.