From 3e8418eed23f391782a56b4aace228e8f491218f Mon Sep 17 00:00:00 2001 From: Ilia Rostovtsev Date: Fri, 6 Nov 2020 18:54:27 +0300 Subject: [PATCH] Fix to update OS version properly --- system-status/system-status-lib.pl | 6 ++---- webmin/webmin-lib.pl | 29 ++++++++++++----------------- 2 files changed, 14 insertions(+), 21 deletions(-) diff --git a/system-status/system-status-lib.pl b/system-status/system-status-lib.pl index d3f6a3630..5a50fb206 100755 --- a/system-status/system-status-lib.pl +++ b/system-status/system-status-lib.pl @@ -88,13 +88,11 @@ if (defined(&proc::get_cpu_io_usage)) { } } -# Remove and regenerate OS cache +# Regenerate OS cache if ($manual) { if (&foreign_available('webmin')) { - &unlink_file("$var_directory/modules/webmin/oscache"); &foreign_require("webmin"); - my %osinfo = &webmin::detect_operating_system(); - &webmin::apply_new_os_version(\%osinfo); + &webmin::detect_operating_system(); } } diff --git a/webmin/webmin-lib.pl b/webmin/webmin-lib.pl index 2fd4633af..94e503fb0 100755 --- a/webmin/webmin-lib.pl +++ b/webmin/webmin-lib.pl @@ -1079,10 +1079,13 @@ if ($cache) { # Check the cache file, and only re-check the OS if older than # 1 day, or if we have rebooted recently my %cache; + my $uptime = &get_system_uptime(); + my $lastreboot = $uptime ? time()-$uptime : undef; if (&read_file($detect_operating_system_cache, \%cache) && $cache{'os_type'} && $cache{'os_version'} && $cache{'real_os_type'} && $cache{'real_os_version'}) { - if ($cache{'time'} > time()-24*60*60) { + if ($cache{'time'} > time()-24*60*60 && + $cache{'time'} > $lastreboot) { return %cache; } } @@ -1134,22 +1137,14 @@ if (($realos{'os_version'} ne $gconfig{'os_version'} || $realos{'os_type'} ne $gconfig{'os_type'}) && $realos{'os_version'} && $realos{'os_type'} && &foreign_available("webmin")) { - my ($realminor) = split(/\./, $realos{'os_version'}); - my ($minor) = split(/\./, $gconfig{'os_version'}); - if ($realos{'os_type'} eq $gconfig{'os_type'} && - $realminor == $minor) { - # Only the minor version number changed - just apply silently - &apply_new_os_version(\%realos); - } - else { - # Large enough change to tell the user - push(@notifs, - &ui_form_start("$gconfig{'webprefix'}/webmin/fix_os.cgi"). - &text('os_incorrect', $realos{'real_os_type'}, - $realos{'real_os_version'})."

\n". - &ui_form_end([ [ undef, $text{'os_fix'} ] ]) - ); - } + + # Tell the user that OS version was updated + push(@notifs, + &ui_form_start("$gconfig{'webprefix'}/webmin/fix_os.cgi"). + &text('os_incorrect', $realos{'real_os_type'}, + $realos{'real_os_version'})."

\n". + &ui_form_end([ [ undef, $text{'os_fix'} ] ]) + ); } # Password close to expiry