Menu

#5280 Centos6 and webmin 1.920 constantly reports that the server requires a reboot

1.920
closed-fixed
nobody
None
5
2019-07-15
2019-07-08
No

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:

check_reboot_required(after-flag)

Returns 1 if the package system thinks a reboot is needed

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.

Discussion

  • Rick Pearson

    Rick Pearson - 2019-07-08

    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 ~]#

     
  • Rick Pearson

    Rick Pearson - 2019-07-08

    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.

     
  • andrel2

    andrel2 - 2019-07-09

    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

     
  • Ilia

    Ilia - 2019-07-12

    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
  • Ilia

    Ilia - 2019-07-12
    • status: open --> closed-fixed
     
  • andrel2

    andrel2 - 2019-07-13

    Tested on CentOS Linux 6.10.
    Fixed.
    Thanks

     
  • Rick Pearson

    Rick Pearson - 2019-07-15

    Thanks Ilia. I have tested on Centos6.10 and Centos7 - works fine. Can it be packaged up to V1.921?

     
  • Jamie Cameron

    Jamie Cameron - 2019-07-15

    Yes, this will be included in the 1.921 release.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.