diff --git a/webmin/fix_repo.cgi b/webmin/fix_repo.cgi new file mode 100644 index 000000000..581d6cc91 --- /dev/null +++ b/webmin/fix_repo.cgi @@ -0,0 +1,31 @@ +#!/usr/local/bin/perl +# Fix the Webmin repository URL and key + +require './webmin-lib.pl'; +&ReadParse(); + +if (-r $webmin_yum_repo_file) { + # Fix up YUM repo + &lock_file($webmin_yum_repo_file); + my $lref = &read_file_lines($webmin_yum_repo_file); + foreach my $l (@$lref) { + if ($l =~ /^\s*baseurl\s*=\s*(\S+)/) { + $l = "baseurl=".$webmin_yum_repo_url; + } + elsif ($l =~ /^\s*mirrorlist\s*=\s*(\S+)/) { + $l = "mirrorlist=".$webmin_yum_repo_mirrorlist; + } + elsif ($l =~ /^\s*gpgkey\s*=\s*file:\/\/(\S+)/) { + ©_source_dest( + "$module_root_directory/developers-key.asc", + $webmin_yum_repo_key) + if (!-r $webmin_yum_repo_key); + $l = "gpgkey=file://".$webmin_yum_repo_key; + } + } + &flush_file_lines($webmin_yum_repo_file); + &unlock_file($webmin_yum_repo_file); + } + +&webmin_log("fixrepo"); +&redirect(get_referer_relative()); diff --git a/webmin/lang/en b/webmin/lang/en index a06b613c1..560bb49b7 100644 --- a/webmin/lang/en +++ b/webmin/lang/en @@ -695,6 +695,7 @@ log_tinstall=Installed theme $1 log_clone=Cloned module $1 to $2 log_delete=Deleted module $1 log_os=Changed operating system +log_fixrepo=Fixed Webmin repository log_lang=Changed global language log_startpage=Changed index page options log_upgrade=Upgraded Webmin to version $1 @@ -1011,6 +1012,8 @@ notify_updatedesc=Fixes problem notif_updateok=Install Updates Now notif_reboot=Recent package updates (such as a new kernel version) require a reboot to be fully applied. notif_rebootok=Reboot Now +notify_yumrepo=Your system is using the old Webmin YUM repository. Click the button below to switch to the new repository URL $1 in order to use our latest signing key and ensure access to updated Webmin versions. +notif_fixreponow=Update Webmin Repository status_title=Background Status Collection status_header=Status collection job settings diff --git a/webmin/webmin-lib.pl b/webmin/webmin-lib.pl index 01054647b..726654817 100755 --- a/webmin/webmin-lib.pl +++ b/webmin/webmin-lib.pl @@ -61,6 +61,11 @@ our $third_ssl = 0; our $default_key_size = "2048"; +our $webmin_yum_repo_file = "/etc/yum.repos.d/webmin.repo"; +our $webmin_yum_repo_url = "https://download.webmin.com/download/newkey/yum"; +our $webmin_yum_repo_mirrorlist = $webmin_yum_repo_url."/mirrorlist"; +our $webmin_yum_repo_key = "/etc/pki/rpm-gpg/RPM-GPG-KEY-webmin-developers"; + # Obsolete, but still defined so it can be deleted our $cron_cmd = "$module_config_directory/update.pl"; @@ -1307,6 +1312,26 @@ if (&foreign_available($module_name) && !$gconfig{'nowebminup'} && } } +# Check for use of the old YUM or APT repos +my $repoerr; +if (-r $webmin_yum_repo_file) { + my $lref = &read_file_lines($webmin_yum_repo_file, 1); + foreach my $l (@$lref) { + if ($l =~ /^\s*baseurl\s*=\s*(\S+)/ && + $1 ne $webmin_yum_repo_url) { + $repoerr = &text('notify_yumrepo', + $webmin_yum_repo_url); + last; + } + } + } +if ($repoerr && &foreign_available("webmin")) { + push(@notifs, + &ui_form_start("@{[&get_webprefix()]}/webmin/fix_repo.cgi"). + $repoerr."
\n". + &ui_form_end([ [ undef, $text{'notif_fixreponow'} ] ])); + } + # Reboot needed if (&foreign_check("package-updates") && &foreign_available("init")) { &foreign_require("package-updates");