From 54d27669609b7c55b6dd5d242f52187f82b37cbc Mon Sep 17 00:00:00 2001 From: Ilia Ross Date: Wed, 17 Apr 2024 20:39:43 +0300 Subject: [PATCH 01/21] Fix to correctly disable manual upgrades https://forum.virtualmin.com/t/should-this-warning-be-displayed/126011 --- makedebian.pl | 6 +++++- makerpm.pl | 5 +++++ usermin/usermin-lib.pl | 4 +++- web-lib-funcs.pl | 3 ++- webmin/webmin-lib.pl | 5 +---- 5 files changed, 16 insertions(+), 7 deletions(-) diff --git a/makedebian.pl b/makedebian.pl index e3279716f..d8975dacb 100755 --- a/makedebian.pl +++ b/makedebian.pl @@ -334,7 +334,11 @@ if [ "$product" = "webmin" ]; then fi fi rm -f /var/lock/subsys/$baseproduct - +if [ -d /etc/webmin/$product ]; then + if [ ! -f /etc/webmin/$product/defaultacl ]; then + echo 'disallow=upgrade' > /etc/webmin/$product/defaultacl 2>/dev/null + fi +fi if [ "\$inetd" != "1" ]; then productucf=Webmin if [ "$product" = "usermin" ]; then diff --git a/makerpm.pl b/makerpm.pl index 49017b70a..aec1f892e 100755 --- a/makerpm.pl +++ b/makerpm.pl @@ -230,6 +230,11 @@ export config_dir var_dir perl autoos port login crypt host ssl nochown autothir ./setup.sh >\$tempdir/webmin-setup.out 2>&1 chmod 600 \$tempdir/webmin-setup.out rm -f /var/lock/subsys/webmin +if [ -d /etc/webmin/webmin ]; then + if [ ! -f /etc/webmin/webmin/defaultacl ]; then + echo 'disallow=upgrade' > /etc/webmin/webmin/defaultacl 2>/dev/null + fi +fi cd /usr/libexec/webmin if [ "\$inetd" != "1" ]; then if [ "\$1" == 1 ]; then diff --git a/usermin/usermin-lib.pl b/usermin/usermin-lib.pl index 37d0b0558..3763c3dff 100755 --- a/usermin/usermin-lib.pl +++ b/usermin/usermin-lib.pl @@ -13,7 +13,9 @@ BEGIN { push(@INC, ".."); }; use WebminCore; &init_config(); %access = &get_module_acl(); -$access{'upgrade'} = 0 if (&is_readonly_mode()); # too hard to fake +$access{'upgrade'} = 0 + if (&is_readonly_mode() || + $access{'disallow'} =~ /upgrade/); # too hard to fake &foreign_require("webmin"); &foreign_require("acl"); %text = ( %webmin::text, %text ); diff --git a/web-lib-funcs.pl b/web-lib-funcs.pl index 54e78906a..3b1f8d675 100755 --- a/web-lib-funcs.pl +++ b/web-lib-funcs.pl @@ -4520,8 +4520,9 @@ $m ||= ""; my $mdir = &module_root_directory($m); my %rv; if (!$nodef) { - # Read default ACL first, to be overridden by per-user settings + # Read default ACLs first, to be overridden by per-user settings &read_file_cached("$mdir/defaultacl", \%rv); + &read_file_cached("$config_directory/$m/defaultacl", \%rv); # If this isn't a master admin user, apply the negative permissions # so that he doesn't un-expectedly gain access to new features diff --git a/webmin/webmin-lib.pl b/webmin/webmin-lib.pl index b5d9ee1eb..a0b9a38ec 100755 --- a/webmin/webmin-lib.pl +++ b/webmin/webmin-lib.pl @@ -1264,14 +1264,11 @@ if (&foreign_check("acl")) { } # New Webmin version is available, but only once per day -my %raccess = &get_module_acl('root'); -my %rdisallow = map { $_, 1 } split(/\s+/, $raccess{'disallow'} || ""); my %access = &get_module_acl(); my %disallow = map { $_, 1 } split(/\s+/, $access{'disallow'} || ""); my %allow = map { $_, 1 } split(/\s+/, $access{'allow'} || ""); if (&foreign_available($module_name) && !$gconfig{'nowebminup'} && - !$noupdates && ($allow{'upgrade'} || - (!$disallow{'upgrade'} && !$rdisallow{'upgrade'}))) { + !$noupdates && ($allow{'upgrade'} || !$disallow{'upgrade'})) { if (!$config{'last_version_check'} || $now - $config{'last_version_check'} > 24*60*60) { # Cached last version has expired .. re-fetch From ed7ac533d42d534073b5fd60e87790f3220f6d2d Mon Sep 17 00:00:00 2001 From: Ilia Ross Date: Thu, 18 Apr 2024 21:19:40 +0300 Subject: [PATCH 02/21] Fix to remove from build time --- makedebian.pl | 6 +----- makerpm.pl | 5 ----- 2 files changed, 1 insertion(+), 10 deletions(-) diff --git a/makedebian.pl b/makedebian.pl index d8975dacb..e3279716f 100755 --- a/makedebian.pl +++ b/makedebian.pl @@ -334,11 +334,7 @@ if [ "$product" = "webmin" ]; then fi fi rm -f /var/lock/subsys/$baseproduct -if [ -d /etc/webmin/$product ]; then - if [ ! -f /etc/webmin/$product/defaultacl ]; then - echo 'disallow=upgrade' > /etc/webmin/$product/defaultacl 2>/dev/null - fi -fi + if [ "\$inetd" != "1" ]; then productucf=Webmin if [ "$product" = "usermin" ]; then diff --git a/makerpm.pl b/makerpm.pl index aec1f892e..49017b70a 100755 --- a/makerpm.pl +++ b/makerpm.pl @@ -230,11 +230,6 @@ export config_dir var_dir perl autoos port login crypt host ssl nochown autothir ./setup.sh >\$tempdir/webmin-setup.out 2>&1 chmod 600 \$tempdir/webmin-setup.out rm -f /var/lock/subsys/webmin -if [ -d /etc/webmin/webmin ]; then - if [ ! -f /etc/webmin/webmin/defaultacl ]; then - echo 'disallow=upgrade' > /etc/webmin/webmin/defaultacl 2>/dev/null - fi -fi cd /usr/libexec/webmin if [ "\$inetd" != "1" ]; then if [ "\$1" == 1 ]; then From c72a24369c719ffa736570ee2221901ed1abf7aa Mon Sep 17 00:00:00 2001 From: Ilia Ross Date: Thu, 18 Apr 2024 22:57:31 +0300 Subject: [PATCH 03/21] Fix how self Webmin and Usermin upgrades are banned --- system-status/system_info.pl | 3 +++ usermin/usermin-lib.pl | 12 +++++++++--- web-lib-funcs.pl | 3 +-- webmin/change_startpage.cgi | 2 -- webmin/edit_startpage.cgi | 6 ------ webmin/index.cgi | 7 +++++++ webmin/webmin-lib.pl | 38 ++++++++++++++++++++++++++++++++++-- 7 files changed, 56 insertions(+), 15 deletions(-) diff --git a/system-status/system_info.pl b/system-status/system_info.pl index 572305e2f..a704e9699 100644 --- a/system-status/system_info.pl +++ b/system-status/system_info.pl @@ -328,6 +328,9 @@ if ($info->{'poss'} && &show_section('poss')) { push(@table, { 'desc' => $text{'right_updates'}, 'value' => $msg, 'wide' => 1 }); + # Check for repos + &foreign_require("webmin"); + &webmin::has_repos(1); } return @rv; diff --git a/usermin/usermin-lib.pl b/usermin/usermin-lib.pl index 3763c3dff..bd1a63792 100755 --- a/usermin/usermin-lib.pl +++ b/usermin/usermin-lib.pl @@ -13,13 +13,19 @@ BEGIN { push(@INC, ".."); }; use WebminCore; &init_config(); %access = &get_module_acl(); -$access{'upgrade'} = 0 - if (&is_readonly_mode() || - $access{'disallow'} =~ /upgrade/); # too hard to fake +$access{'upgrade'} = 0 if (&is_readonly_mode()); # too hard to fake &foreign_require("webmin"); &foreign_require("acl"); %text = ( %webmin::text, %text ); +if (!defined($gconfig{'noselfwebminup'})) { + $access{'upgrade'} = 0 + if (&webmin::has_repos()); + } +else { + $access{'upgrade'} = !$gconfig{'noselfwebminup'}; + } + $usermin_miniserv_config = "$config{'usermin_dir'}/miniserv.conf"; $usermin_config = "$config{'usermin_dir'}/config"; diff --git a/web-lib-funcs.pl b/web-lib-funcs.pl index 3b1f8d675..54e78906a 100755 --- a/web-lib-funcs.pl +++ b/web-lib-funcs.pl @@ -4520,9 +4520,8 @@ $m ||= ""; my $mdir = &module_root_directory($m); my %rv; if (!$nodef) { - # Read default ACLs first, to be overridden by per-user settings + # Read default ACL first, to be overridden by per-user settings &read_file_cached("$mdir/defaultacl", \%rv); - &read_file_cached("$config_directory/$m/defaultacl", \%rv); # If this isn't a master admin user, apply the negative permissions # so that he doesn't un-expectedly gain access to new features diff --git a/webmin/change_startpage.cgi b/webmin/change_startpage.cgi index 1ace61e8f..030b4d9e5 100755 --- a/webmin/change_startpage.cgi +++ b/webmin/change_startpage.cgi @@ -18,8 +18,6 @@ $gconfig{'gotoone'} = $in{'gotoone'}; $gconfig{'deftab'} = $in{'deftab'}; $gconfig{'nohostname'} = $in{'nohostname'}; $gconfig{'gotomodule'} = $in{'gotomodule'}; -$gconfig{'nowebminup'} = !$in{'webminup'}; -$gconfig{'nomoduleup'} = !$in{'moduleup'}; &write_file("$config_directory/config", \%gconfig); &unlock_file("$config_directory/config"); &webmin_log("startpage", undef, undef, \%in); diff --git a/webmin/edit_startpage.cgi b/webmin/edit_startpage.cgi index c964bec44..f17647bcc 100755 --- a/webmin/edit_startpage.cgi +++ b/webmin/edit_startpage.cgi @@ -38,12 +38,6 @@ print &ui_table_row($text{'startpage_gotomodule'}, sort { $a->{'desc'} cmp $b->{'desc'} } grep { !$_->{'hidden'} && !$_->{'webmin_hidden'} } @modules ])); -print &ui_table_row($text{'startpage_webminup'}, - &ui_yesno_radio("webminup", !$gconfig{'nowebminup'})); - -print &ui_table_row($text{'startpage_moduleup'}, - &ui_yesno_radio("moduleup", !$gconfig{'nomoduleup'})); - print &ui_table_end(); print &ui_form_end([ [ "", $text{'save'} ] ]); diff --git a/webmin/index.cgi b/webmin/index.cgi index f9f3414d8..cd849c5d6 100755 --- a/webmin/index.cgi +++ b/webmin/index.cgi @@ -61,6 +61,13 @@ push(@wlinks, "edit_ssl.cgi", "edit_ca.cgi"); push(@wtitles, $text{'ssl_title'}, $text{'ca_title'}); push(@wicons, "images/ssl.gif", "images/ca.gif"); +# Enfoce to disable Webmin updates +if ($gconfig{'noselfwebminup'}) { + $access{'disallow'} ||= ''; + $access{'disallow'} = join(' ', + split(/\s+/, $access{'disallow'}), 'upgrade'); + } + # Hide dis-allowed pages my %allow = map { $_, 1 } split(/\s+/, $access{'allow'}); my %disallow = map { $_, 1 } split(/\s+/, $access{'disallow'}); diff --git a/webmin/webmin-lib.pl b/webmin/webmin-lib.pl index a0b9a38ec..c56127594 100755 --- a/webmin/webmin-lib.pl +++ b/webmin/webmin-lib.pl @@ -108,6 +108,39 @@ our $realos_cache_file = "$module_var_directory/realos-cache"; our $password_change_mod = "passwd"; our $password_change_path = "/".$password_change_mod."/change_passwd.cgi"; +if (!defined($gconfig{'noselfwebminup'})) { + &has_repos(); + } + +=head2 has_repos + +Checks if package manager repositories are +available for Webmin and Usermin updates. + +=cut +sub has_repos +{ +my ($force) = @_; +my $has_repos = 0; +if (-d '/etc/apt' || -d '/etc/yum.repos.d') { + my $out = &backquote_command( + "grep -irE 'webmin\.com|webmin\.dev|virtualmin\.com|virtualmin\.dev' ". + "/etc/apt/sources.list /etc/apt/sources.list.d/ ". + "/etc/yum.repos.d/ 2>/dev/null"); + if ($out) { + $has_repos = 1; + } + } +if ($force || !defined($gconfig{'noselfwebminup'}) || + $gconfig{'noselfwebminup'} ne $has_repos) { + $gconfig{'noselfwebminup'} = $has_repos; + &lock_file("$config_directory/config"); + &write_file("$config_directory/config", \%gconfig); + &unlock_file("$config_directory/config"); + } +return $has_repos; +} + =head2 setup_ca Internal function to create all the configuration files needed for the Webmin @@ -1267,8 +1300,9 @@ if (&foreign_check("acl")) { my %access = &get_module_acl(); my %disallow = map { $_, 1 } split(/\s+/, $access{'disallow'} || ""); my %allow = map { $_, 1 } split(/\s+/, $access{'allow'} || ""); -if (&foreign_available($module_name) && !$gconfig{'nowebminup'} && - !$noupdates && ($allow{'upgrade'} || !$disallow{'upgrade'})) { +if (&foreign_available($module_name) && !$gconfig{'nowebminup'} && + !$gconfig{'noselfwebminup'} && !$noupdates && + ($allow{'upgrade'} || !$disallow{'upgrade'})) { if (!$config{'last_version_check'} || $now - $config{'last_version_check'} > 24*60*60) { # Cached last version has expired .. re-fetch From 575c1ca5a3c90049a48aacfe389994dc6305b96a Mon Sep 17 00:00:00 2001 From: Ilia Ross Date: Fri, 19 Apr 2024 20:33:24 +0300 Subject: [PATCH 04/21] Fix to use Perl to get repo files --- webmin/webmin-lib.pl | 43 ++++++++++++++++++++++++++++++++++++------- 1 file changed, 36 insertions(+), 7 deletions(-) diff --git a/webmin/webmin-lib.pl b/webmin/webmin-lib.pl index c56127594..fb51d6198 100755 --- a/webmin/webmin-lib.pl +++ b/webmin/webmin-lib.pl @@ -122,15 +122,44 @@ sub has_repos { my ($force) = @_; my $has_repos = 0; -if (-d '/etc/apt' || -d '/etc/yum.repos.d') { - my $out = &backquote_command( - "grep -irE 'webmin\.com|webmin\.dev|virtualmin\.com|virtualmin\.dev' ". - "/etc/apt/sources.list /etc/apt/sources.list.d/ ". - "/etc/yum.repos.d/ 2>/dev/null"); - if ($out) { - $has_repos = 1; +my @paths = ( + '/etc/apt/sources.list', + '/etc/apt/sources.list.d', + '/etc/yum.repos.d' +); +my $pattern = + qr/webmin\.com|webmin\.dev|virtualmin\.com|virtualmin\.dev/i; +my $process_file = sub { + my $file = shift; + return unless -f $file; + return unless $file =~ /\.list$|\.repo$/i; + open(my $fh, '<', $file) || return; + while (my $line = <$fh>) { + if ($line =~ /$pattern/) { + $has_repos = 1; + last; + } + } + close $fh; +}; +# Check given repos paths +foreach my $path (@paths) { + if (-d $path) { + # It's a directory, open and read each file + opendir(my $dh, $path) || next; + my @files = readdir($dh); + closedir($dh); + foreach my $file (@files) { + next if $file eq '.' or $file eq '..'; + $process_file->("$path/$file"); + } + } + elsif (-f $path) { + # It's a file + $process_file->($path); } } +# Store the result in the config if ($force || !defined($gconfig{'noselfwebminup'}) || $gconfig{'noselfwebminup'} ne $has_repos) { $gconfig{'noselfwebminup'} = $has_repos; From 690bae82fce8d8a07a122fd3903d47e76c91a897 Mon Sep 17 00:00:00 2001 From: Ilia Ross Date: Fri, 19 Apr 2024 20:51:03 +0300 Subject: [PATCH 05/21] Fix to use disable hash --- webmin/index.cgi | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/webmin/index.cgi b/webmin/index.cgi index cd849c5d6..4cea9cef0 100755 --- a/webmin/index.cgi +++ b/webmin/index.cgi @@ -61,16 +61,16 @@ push(@wlinks, "edit_ssl.cgi", "edit_ca.cgi"); push(@wtitles, $text{'ssl_title'}, $text{'ca_title'}); push(@wicons, "images/ssl.gif", "images/ca.gif"); -# Enfoce to disable Webmin updates -if ($gconfig{'noselfwebminup'}) { - $access{'disallow'} ||= ''; - $access{'disallow'} = join(' ', - split(/\s+/, $access{'disallow'}), 'upgrade'); - } - # Hide dis-allowed pages my %allow = map { $_, 1 } split(/\s+/, $access{'allow'}); my %disallow = map { $_, 1 } split(/\s+/, $access{'disallow'}); + +# Enfoce to disable Webmin self-upgrades +# if repos are enabled +if ($gconfig{'noselfwebminup'}) { + $disallow{'upgrade'} = 1; + } + for(my $i=0; $i<@wlinks; $i++) { $wlinks[$i] =~ /edit_(\S+)\.cgi/; if (%allow && !$allow{$1} || From 6eb674b45125659a7060e6d93d3cc367843141dc Mon Sep 17 00:00:00 2001 From: Ilia Ross Date: Sat, 20 Apr 2024 16:22:12 +0300 Subject: [PATCH 06/21] Fix to swap lines --- webmin/webmin-lib.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webmin/webmin-lib.pl b/webmin/webmin-lib.pl index fb51d6198..f01e9bd58 100755 --- a/webmin/webmin-lib.pl +++ b/webmin/webmin-lib.pl @@ -162,8 +162,8 @@ foreach my $path (@paths) { # Store the result in the config if ($force || !defined($gconfig{'noselfwebminup'}) || $gconfig{'noselfwebminup'} ne $has_repos) { - $gconfig{'noselfwebminup'} = $has_repos; &lock_file("$config_directory/config"); + $gconfig{'noselfwebminup'} = $has_repos; &write_file("$config_directory/config", \%gconfig); &unlock_file("$config_directory/config"); } From f252296471d0dd2d2f90bb05404aaf09139d90e8 Mon Sep 17 00:00:00 2001 From: Ilia Ross Date: Sun, 21 Apr 2024 13:56:11 +0300 Subject: [PATCH 07/21] Fix to preserve service state https://github.com/webmin/webmin/issues/2133 [build] --- init/updateboot.pl | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/init/updateboot.pl b/init/updateboot.pl index 866452d56..a023f1fb7 100755 --- a/init/updateboot.pl +++ b/init/updateboot.pl @@ -29,8 +29,26 @@ if ($product) { $l =~ s/(WEBMIN_[A-Z]+)/$ENV{$1}/g; } &flush_file_lines($temp); + + my $status = &backquote_logged("systemctl is-enabled ". + quotemeta($product).".service 2>&1"); + $status = &trim($status); + copy_source_dest($temp, "$systemd_root/$product.service"); system("systemctl daemon-reload >/dev/null 2>&1"); + + if ($status eq "disabled") { + system("systemctl disable ". + quotemeta($product).".service >/dev/null 2>&1"); + } + elsif ($status eq "masked") { + system("systemctl mask ". + quotemeta($product).".service >/dev/null 2>&1"); + } + else { + system("systemctl enable ". + quotemeta($product).".service >/dev/null 2>&1"); + } } elsif (-d "/etc/init.d") { copy_source_dest("$root_directory/webmin-init", "/etc/init.d/$product"); From 975ae7b497426f21f09288c9d2fcd70f0ae6eb32 Mon Sep 17 00:00:00 2001 From: Ilia Ross Date: Sun, 21 Apr 2024 14:53:03 +0300 Subject: [PATCH 08/21] Fix to wait for systemd to update configuration [build] --- init/updateboot.pl | 1 + 1 file changed, 1 insertion(+) diff --git a/init/updateboot.pl b/init/updateboot.pl index a023f1fb7..12b43d0dd 100755 --- a/init/updateboot.pl +++ b/init/updateboot.pl @@ -36,6 +36,7 @@ if ($product) { copy_source_dest($temp, "$systemd_root/$product.service"); system("systemctl daemon-reload >/dev/null 2>&1"); + sleep(3); # Wait for systemd to update configuration if ($status eq "disabled") { system("systemctl disable ". From 1f2a7902c6460b28d685658b91596e415121b7fa Mon Sep 17 00:00:00 2001 From: Ilia Ross Date: Sun, 21 Apr 2024 14:59:12 +0300 Subject: [PATCH 09/21] Fix to save status of service correctly [build] --- init/updateboot.pl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/init/updateboot.pl b/init/updateboot.pl index 12b43d0dd..482212d7c 100755 --- a/init/updateboot.pl +++ b/init/updateboot.pl @@ -11,6 +11,10 @@ $< == 0 || die "updateboot.pl must be run as root"; # Update boot script if ($product) { if ($init_mode eq "systemd") { + # Save status of service + my $status = &backquote_logged("systemctl is-enabled ". + quotemeta($product).".service 2>&1"); + $status = &trim($status) if ($status); # Delete all possible service files my $systemd_root = &get_systemd_root(); foreach my $p ( @@ -30,10 +34,6 @@ if ($product) { } &flush_file_lines($temp); - my $status = &backquote_logged("systemctl is-enabled ". - quotemeta($product).".service 2>&1"); - $status = &trim($status); - copy_source_dest($temp, "$systemd_root/$product.service"); system("systemctl daemon-reload >/dev/null 2>&1"); sleep(3); # Wait for systemd to update configuration From cd46f97288c78c79e6c44a3f0d85ceb0c9d6b044 Mon Sep 17 00:00:00 2001 From: Ilia Ross Date: Sun, 21 Apr 2024 15:38:39 +0300 Subject: [PATCH 10/21] Fix to use latest version [build] --- .github/workflows/webmin.dev-deploy-webmin-package.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/webmin.dev-deploy-webmin-package.yml b/.github/workflows/webmin.dev-deploy-webmin-package.yml index f0763a1a1..4f4234cd8 100644 --- a/.github/workflows/webmin.dev-deploy-webmin-package.yml +++ b/.github/workflows/webmin.dev-deploy-webmin-package.yml @@ -15,7 +15,7 @@ jobs: with: packages: git tar gzip openssl curl openssh-client rpm perl libjson-pp-perl libdigest-sha-perl liblist-moreutils-perl libencode-detect-perl version: 1.0 - - uses: szenius/set-timezone@v1.2 + - uses: szenius/set-timezone@v2 with: timezoneLinux: "Europe/Nicosia" - name: Build and upload packages From b57d57b729c67f7fcc41ea3b76dccc8382bc8ee8 Mon Sep 17 00:00:00 2001 From: Ilia Ross Date: Sun, 21 Apr 2024 15:48:09 +0300 Subject: [PATCH 11/21] Fix to check for status only if it was running in the first place https://sourceforge.net/p/webadmin/bugs/5646/ [build] --- makedebian.pl | 6 +++--- makerpm.pl | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/makedebian.pl b/makedebian.pl index e3279716f..dba39789c 100755 --- a/makedebian.pl +++ b/makedebian.pl @@ -359,11 +359,11 @@ if [ "\$inetd" != "1" ]; then else if [ "\$productrunning" = "1" ]; then /etc/$baseproduct/restart >/dev/null 2>&1 /dev/null 2>&1 /dev/null 2>&1 /dev/null 2>&1 Date: Sun, 21 Apr 2024 15:54:33 +0300 Subject: [PATCH 12/21] Revert "Fix to use latest version [build]" This reverts commit cd46f97288c78c79e6c44a3f0d85ceb0c9d6b044. --- .github/workflows/webmin.dev-deploy-webmin-package.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/webmin.dev-deploy-webmin-package.yml b/.github/workflows/webmin.dev-deploy-webmin-package.yml index 4f4234cd8..f0763a1a1 100644 --- a/.github/workflows/webmin.dev-deploy-webmin-package.yml +++ b/.github/workflows/webmin.dev-deploy-webmin-package.yml @@ -15,7 +15,7 @@ jobs: with: packages: git tar gzip openssl curl openssh-client rpm perl libjson-pp-perl libdigest-sha-perl liblist-moreutils-perl libencode-detect-perl version: 1.0 - - uses: szenius/set-timezone@v2 + - uses: szenius/set-timezone@v1.2 with: timezoneLinux: "Europe/Nicosia" - name: Build and upload packages From bac62e03c74350e53049cf19160904029ed4cddc Mon Sep 17 00:00:00 2001 From: Ilia Ross Date: Sun, 21 Apr 2024 16:18:10 +0300 Subject: [PATCH 13/21] Add debug [build] --- init/updateboot.pl | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/init/updateboot.pl b/init/updateboot.pl index 482212d7c..7ee0eaf0d 100755 --- a/init/updateboot.pl +++ b/init/updateboot.pl @@ -13,8 +13,9 @@ if ($product) { if ($init_mode eq "systemd") { # Save status of service my $status = &backquote_logged("systemctl is-enabled ". - quotemeta($product).".service 2>&1"); + quotemeta($product)." 2>&1"); $status = &trim($status) if ($status); + print "Current Status is $status\n"; # Delete all possible service files my $systemd_root = &get_systemd_root(); foreach my $p ( @@ -40,15 +41,21 @@ if ($product) { if ($status eq "disabled") { system("systemctl disable ". - quotemeta($product).".service >/dev/null 2>&1"); + quotemeta($product)." >/dev/null 2>&1"); + print "Disabled $product\n"; + print "Disabled run ". "systemctl disable ". quotemeta($product)." >/dev/null 2>&1"; } elsif ($status eq "masked") { system("systemctl mask ". - quotemeta($product).".service >/dev/null 2>&1"); + quotemeta($product)." >/dev/null 2>&1"); + print "Masked $product\n"; + print "Masked run ". "systemctl mask ". quotemeta($product)." >/dev/null 2>&1"; } else { system("systemctl enable ". - quotemeta($product).".service >/dev/null 2>&1"); + quotemeta($product)." >/dev/null 2>&1"); + print "Enabled $product\n"; + print "Enabled run ". "systemctl enable ". quotemeta($product)." >/dev/null 2>&1"; } } elsif (-d "/etc/init.d") { From 1e94a328ba8332c6c1a6fef185a836336633581c Mon Sep 17 00:00:00 2001 From: Ilia Ross Date: Sun, 21 Apr 2024 16:29:05 +0300 Subject: [PATCH 14/21] Dev: Add more debug [build] --- init/updateboot.pl | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/init/updateboot.pl b/init/updateboot.pl index 7ee0eaf0d..9987f0045 100755 --- a/init/updateboot.pl +++ b/init/updateboot.pl @@ -16,6 +16,9 @@ if ($product) { quotemeta($product)." 2>&1"); $status = &trim($status) if ($status); print "Current Status is $status\n"; + my $status2 = &backquote_logged("systemctl is-enabled ". + quotemeta($product).".xxxx 2>&1"); + print "Current Status2 is $status2\n"; # Delete all possible service files my $systemd_root = &get_systemd_root(); foreach my $p ( @@ -36,26 +39,27 @@ if ($product) { &flush_file_lines($temp); copy_source_dest($temp, "$systemd_root/$product.service"); - system("systemctl daemon-reload >/dev/null 2>&1"); + system("systemctl daemon-reload"); + print "pre-test ....\n"; + system("systemctl daemon-reloads"); + print "pre-sleep ....\n"; sleep(3); # Wait for systemd to update configuration + print "psot-sleep ....\n"; if ($status eq "disabled") { - system("systemctl disable ". - quotemeta($product)." >/dev/null 2>&1"); + system("systemctl disable ".quotemeta($product)); print "Disabled $product\n"; - print "Disabled run ". "systemctl disable ". quotemeta($product)." >/dev/null 2>&1"; + print "Disabled run ". "systemctl disable ". quotemeta($product); } elsif ($status eq "masked") { - system("systemctl mask ". - quotemeta($product)." >/dev/null 2>&1"); + system("systemctl mask ".quotemeta($product)); print "Masked $product\n"; - print "Masked run ". "systemctl mask ". quotemeta($product)." >/dev/null 2>&1"; + print "Masked run ". "systemctl mask ". quotemeta($product); } else { - system("systemctl enable ". - quotemeta($product)." >/dev/null 2>&1"); + system("systemctl enable ".quotemeta($product)); print "Enabled $product\n"; - print "Enabled run ". "systemctl enable ". quotemeta($product)." >/dev/null 2>&1"; + print "Enabled run ". "systemctl enable ". quotemeta($product); } } elsif (-d "/etc/init.d") { From 0b1e5f87e13b085acc7a71af1a99e2919f532eff Mon Sep 17 00:00:00 2001 From: Ilia Ross Date: Sun, 21 Apr 2024 16:41:25 +0300 Subject: [PATCH 15/21] Dev: Remove debug info --- init/updateboot.pl | 33 +++++++++++++-------------------- 1 file changed, 13 insertions(+), 20 deletions(-) diff --git a/init/updateboot.pl b/init/updateboot.pl index 9987f0045..a56ed62ca 100755 --- a/init/updateboot.pl +++ b/init/updateboot.pl @@ -11,14 +11,14 @@ $< == 0 || die "updateboot.pl must be run as root"; # Update boot script if ($product) { if ($init_mode eq "systemd") { + my $reload_daemon = sub { + system("systemctl daemon-reload >/dev/null 2>&1"); + sleep(2); + }; # Save status of service my $status = &backquote_logged("systemctl is-enabled ". - quotemeta($product)." 2>&1"); + quotemeta($product).".service 2>&1"); $status = &trim($status) if ($status); - print "Current Status is $status\n"; - my $status2 = &backquote_logged("systemctl is-enabled ". - quotemeta($product).".xxxx 2>&1"); - print "Current Status2 is $status2\n"; # Delete all possible service files my $systemd_root = &get_systemd_root(); foreach my $p ( @@ -28,6 +28,7 @@ if ($product) { unlink("$p/$product.service"); unlink("$p/$product"); } + $reload_daemon->(); my $temp = &transname(); my $killcmd = &has_command('kill'); $ENV{'WEBMIN_KILLCMD'} = $killcmd; @@ -39,27 +40,19 @@ if ($product) { &flush_file_lines($temp); copy_source_dest($temp, "$systemd_root/$product.service"); - system("systemctl daemon-reload"); - print "pre-test ....\n"; - system("systemctl daemon-reloads"); - print "pre-sleep ....\n"; - sleep(3); # Wait for systemd to update configuration - print "psot-sleep ....\n"; + $reload_daemon->(); if ($status eq "disabled") { - system("systemctl disable ".quotemeta($product)); - print "Disabled $product\n"; - print "Disabled run ". "systemctl disable ". quotemeta($product); + system("systemctl disable ". + quotemeta($product).".service >/dev/null 2>&1"); } elsif ($status eq "masked") { - system("systemctl mask ".quotemeta($product)); - print "Masked $product\n"; - print "Masked run ". "systemctl mask ". quotemeta($product); + system("systemctl mask ". + quotemeta($product).".service >/dev/null 2>&1"); } else { - system("systemctl enable ".quotemeta($product)); - print "Enabled $product\n"; - print "Enabled run ". "systemctl enable ". quotemeta($product); + system("systemctl enable ". + quotemeta($product).".service >/dev/null 2>&1"); } } elsif (-d "/etc/init.d") { From f1804201e6fd2ff517f887402852d7daaf12e057 Mon Sep 17 00:00:00 2001 From: Ilia Ross Date: Sun, 21 Apr 2024 16:43:47 +0300 Subject: [PATCH 16/21] Fix indent [build] --- init/updateboot.pl | 1 + 1 file changed, 1 insertion(+) diff --git a/init/updateboot.pl b/init/updateboot.pl index a56ed62ca..ce16f2499 100755 --- a/init/updateboot.pl +++ b/init/updateboot.pl @@ -29,6 +29,7 @@ if ($product) { unlink("$p/$product"); } $reload_daemon->(); + my $temp = &transname(); my $killcmd = &has_command('kill'); $ENV{'WEBMIN_KILLCMD'} = $killcmd; From 985129bb709371c11d46e87b4d820313ca966df6 Mon Sep 17 00:00:00 2001 From: Ilia Ross Date: Sun, 21 Apr 2024 17:45:10 +0300 Subject: [PATCH 17/21] Fix to call update boot script after adding boot #2133 [build] --- setup.pl | 13 ++++--------- setup.sh | 7 ++++--- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/setup.pl b/setup.pl index d96ea934c..075e7594c 100755 --- a/setup.pl +++ b/setup.pl @@ -765,15 +765,6 @@ else { chmod(0755, "$config_directory/reload"); chmod(0755, "$config_directory/.pre-install"); chmod(0755, "$config_directory/.post-install"); - - # Fix existing systemd webmin.service file to update start and stop commands - chdir("$wadir/init"); - system("$perl "."e_path("$wadir/init/updateboot.pl")." $bootscript"); - } - else { - # Try to install init script to init.d - chdir("$wadir/init"); - system("$perl "."e_path("$wadir/init/updateboot.pl")." $bootscript"); } } print ".. done\n"; @@ -837,6 +828,7 @@ if ($theme && -d "$wadir/$theme") { # Set the product field in the global config $gconfig{'product'} ||= "webmin"; +# Add boot script if needed if ($makeboot) { print "Configuring Webmin to start at boot time ..\n"; chdir("$wadir/init"); @@ -845,6 +837,9 @@ if ($makeboot) { print "\n"; } +# Update boot script if needed +chdir("$wadir/init"); +system("$perl "."e_path("$wadir/init/updateboot.pl")." $bootscript"); # If password delays are not specifically disabled, enable them if (!defined($miniserv{'passdelay'}) && $os_type ne 'windows') { diff --git a/setup.sh b/setup.sh index 4eba45aad..2c12b9615 100755 --- a/setup.sh +++ b/setup.sh @@ -791,9 +791,6 @@ if [ -x "$systemctlcmd" ]; then chmod 755 $config_dir/stop $config_dir/start $config_dir/restart $config_dir/restart-by-force-kill $config_dir/reload $config_dir/.pre-install $config_dir/.post-install fi -# Fix existing systemd webmin.service file to update start and stop commands -(cd "$wadir/init" ; WEBMIN_CONFIG=$config_dir WEBMIN_VAR=$var_dir "$wadir/init/updateboot.pl" "$bootscript") - if [ "$upgrading" = 1 -a "$inetd" != "1" -a "$nostop" = "" ]; then # Stop old version, with updated stop script $config_dir/.pre-install >/dev/null 2>&1 @@ -898,6 +895,7 @@ if [ "$?" != "0" ]; then echo product=webmin >> $config_dir/config fi +# Add boot script if needed if [ "$makeboot" = "1" ]; then echo "Configuring Webmin to start at boot time .." (cd "$wadir/init" ; WEBMIN_CONFIG=$config_dir WEBMIN_VAR=$var_dir "$wadir/init/atboot.pl" $bootscript) @@ -905,6 +903,9 @@ if [ "$makeboot" = "1" ]; then echo "" fi +# Update boot script if needed +(cd "$wadir/init" ; WEBMIN_CONFIG=$config_dir WEBMIN_VAR=$var_dir "$wadir/init/updateboot.pl" "$bootscript") + # If password delays are not specifically disabled, enable them grep passdelay= $config_dir/miniserv.conf >/dev/null if [ "$?" != "0" ]; then From 9b496bf4132553ebc3c3da923f1b007c42090836 Mon Sep 17 00:00:00 2001 From: Ilia Ross Date: Sun, 21 Apr 2024 17:53:03 +0300 Subject: [PATCH 18/21] Fix to drop installing `systemd` service at boot script [build] https://github.com/webmin/webmin/issues/2133 --- init/atboot.pl | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) diff --git a/init/atboot.pl b/init/atboot.pl index 9f0d4df46..1587e496c 100755 --- a/init/atboot.pl +++ b/init/atboot.pl @@ -122,24 +122,7 @@ elsif ($init_mode eq "win32") { } elsif ($init_mode eq "systemd") { # Create systemd - &enable_at_boot( - $product, - "$ucproduct server daemon", - "$root_directory/miniserv.pl $config_directory/miniserv.conf", - "$kill \$MAINPID", - undef, - { 'pidfile' => "$var_directory/miniserv.pid", - 'opts' => { - 'env' => '"PERLLIB=' . $root_directory . '"', - 'stop' => "$kill \$MAINPID", - 'reload' => "$kill -HUP \$MAINPID", - 'type' => 'forking', - 'restart' => 'always', - 'restartsec' => '2s', - 'timeout' => '15s', - 'timeoutstopsec' => '300s', - }}, - ); + # See updateboot.pl } elsif ($init_mode eq "rc" || $init_mode eq "upstart") { # Create RC or upstart script From 8de5c83ca831697a1560e9f7b9c00cf55345e641 Mon Sep 17 00:00:00 2001 From: Ilia Ross Date: Fri, 26 Apr 2024 13:34:20 +0300 Subject: [PATCH 19/21] Add ctrl help #2134 --- time/index.cgi | 3 +++ time/lang/en | 1 + 2 files changed, 4 insertions(+) diff --git a/time/index.cgi b/time/index.cgi index fa0da10a0..70d087093 100755 --- a/time/index.cgi +++ b/time/index.cgi @@ -231,6 +231,9 @@ if ( ( !$access{ 'sysdate' } && &has_command( "date" ) || !$access{ 'hwdate' } & print &ui_table_row(undef, &webmincron::show_times_input($job), 2); + # Show ctrl help + print &ui_table_row(undef, $text{'index_ctrl'}, 2); + print &ui_table_end(); print &ui_form_end([ [ "action", $text{'index_sync'} ] ]); print &ui_tabs_end_tab(); diff --git a/time/lang/en b/time/lang/en index 7fcad73a6..9e1534764 100644 --- a/time/lang/en +++ b/time/lang/en @@ -19,6 +19,7 @@ index_tabsync2=Run system $1 service for synchronization index_desctime=This form is for changing the system's current time, which is used by all running processes. On operating systems that have a separate hardware clock, it can be used to set that too. index_desczone=This form allows you to set the system's default time zone, which is used to convert the system time to a human-readable format and offset. index_descsync=This form is for configuring the system to automatically synchronize the time with a remote server. Synchronization will be done using the Unix time protocol or NTP, depending on which commands are installed and what the remote system supports. +index_ctrl=Note: Ctrl-click (or command-click on the Mac) to select and de-select minutes, hours, days and months. action_save=Save action_apply=Apply From 4db36071b36a3626dfa7c2e9e57bf9dc1fd35a60 Mon Sep 17 00:00:00 2001 From: Ilia Ross Date: Fri, 26 Apr 2024 16:02:24 +0300 Subject: [PATCH 20/21] Fix `$rawtime` scope #2136 [build] --- time/time-lib.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/time/time-lib.pl b/time/time-lib.pl index 7d101faf3..55ac80dea 100755 --- a/time/time-lib.pl +++ b/time/time-lib.pl @@ -13,6 +13,7 @@ our ($timezones_file, $currentzone_link, $currentzone_file, $timezones_dir, $sysclock_file); our ($get_hardware_time_error); our $cron_cmd = "$module_config_directory/sync.pl"; +our $rawtime; if ($config{'zone_style'}) { do "$config{'zone_style'}-lib.pl"; } @@ -76,7 +77,6 @@ if ($? && $config{'ntp_only'}) { elsif ($?) { # error using ntp. use timeservice my ($err, $serv); - my $rawtime; foreach $serv (@servs) { $err = undef; my $fh = "SOCK"; From 4e5da791e2e3536deae1aba379dc1d0cc0e839aa Mon Sep 17 00:00:00 2001 From: Ilia Ross Date: Fri, 26 Apr 2024 18:39:46 +0300 Subject: [PATCH 21/21] Fix to limit input to 4 numbers https://github.com/webmin/webmin/issues/2138#issuecomment-2079609477 [build] --- filemin/unauthenticated/templates/dialogs.html | 2 +- filemin/unauthenticated/templates/legacy_dialogs.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/filemin/unauthenticated/templates/dialogs.html b/filemin/unauthenticated/templates/dialogs.html index e7fe0cb24..c08a25081 100644 --- a/filemin/unauthenticated/templates/dialogs.html +++ b/filemin/unauthenticated/templates/dialogs.html @@ -306,7 +306,7 @@
- +
diff --git a/filemin/unauthenticated/templates/legacy_dialogs.html b/filemin/unauthenticated/templates/legacy_dialogs.html index 9ddc00bc0..13f20004e 100644 --- a/filemin/unauthenticated/templates/legacy_dialogs.html +++ b/filemin/unauthenticated/templates/legacy_dialogs.html @@ -173,7 +173,7 @@

- +