Fix the Webmin repo if the old URL is being used

This commit is contained in:
Jamie Cameron
2023-05-29 18:33:29 -07:00
parent 48abceeebd
commit 21f4a9b368
3 changed files with 59 additions and 0 deletions

31
webmin/fix_repo.cgi Normal file
View File

@@ -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+)/) {
&copy_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());

View File

@@ -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 <tt>$1</tt> 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

View File

@@ -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."<p>\n".
&ui_form_end([ [ undef, $text{'notif_fixreponow'} ] ]));
}
# Reboot needed
if (&foreign_check("package-updates") && &foreign_available("init")) {
&foreign_require("package-updates");