Merge branch 'master' of github.com:webmin/webmin

This commit is contained in:
Jamie Cameron
2024-04-28 09:07:40 -07:00
17 changed files with 130 additions and 53 deletions

View File

@@ -306,7 +306,7 @@
<form name="chmod" id="chmodForm">
<div class="form-group">
<label for="t_total">$text{'permissions'}:&nbsp; </label>
<input id="perms" type="text" name="t_total" value="0644" size="4" onKeyUp="octalchange()" class="form-group-item">
<input id="perms" type="text" oninput="if(this.value.length>4)this.value=this.value.slice(0,4)" name="t_total" value="0644" size="4" onKeyUp="octalchange()" class="form-group-item">
<input type="text" name="sym_total" value="" size="12" readonly="true" class="form-group-item">
</div>
<table class="table">

View File

@@ -173,7 +173,7 @@
<form name="chmod" id="chmodForm">
<div class="form-group">
<label for="t_total">$text{'permissions'}:&nbsp; </label><br>
<input id="perms" type="text" name="t_total" value="0644" size="4" onKeyUp="octalchange()" class="form-group-item">
<input id="perms" type="text" oninput="if(this.value.length>4)this.value=this.value.slice(0,4)" name="t_total" value="0644" size="4" onKeyUp="octalchange()" class="form-group-item">
<input type="text" name="sym_total" value="" size="12" readonly="true" class="form-group-item">
</div>
<table class="table">

View File

@@ -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

View File

@@ -11,6 +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).".service 2>&1");
$status = &trim($status) if ($status);
# Delete all possible service files
my $systemd_root = &get_systemd_root();
foreach my $p (
@@ -20,6 +28,8 @@ if ($product) {
unlink("$p/$product.service");
unlink("$p/$product");
}
$reload_daemon->();
my $temp = &transname();
my $killcmd = &has_command('kill');
$ENV{'WEBMIN_KILLCMD'} = $killcmd;
@@ -29,8 +39,22 @@ if ($product) {
$l =~ s/(WEBMIN_[A-Z]+)/$ENV{$1}/g;
}
&flush_file_lines($temp);
copy_source_dest($temp, "$systemd_root/$product.service");
system("systemctl daemon-reload >/dev/null 2>&1");
$reload_daemon->();
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");

View File

@@ -359,11 +359,11 @@ if [ "\$inetd" != "1" ]; then
else
if [ "\$productrunning" = "1" ]; then
/etc/$baseproduct/restart >/dev/null 2>&1 </dev/null
if [ "\$?" != "0" ]; then
echo "W: \${productucf} server cannot be restarted. It is advised to restart it manually by\n running \\"/etc/$baseproduct/restart-by-force-kill\\" command when upgrade process is finished"
fi
fi
fi
if [ "\$?" != "0" ]; then
echo "W: \${productucf} server cannot be restarted. It is advised to restart it manually by\n running \\"/etc/$baseproduct/restart-by-force-kill\\" command when upgrade process is finished"
fi
fi
fi

View File

@@ -242,14 +242,14 @@ if [ "\$inetd" != "1" ]; then
/etc/webmin/.post-install >/dev/null 2>&1 </dev/null
else
/etc/webmin/.reload-init >/dev/null 2>&1 </dev/null
if [ "\$?" != "0" ]; then
echo "warning: Webmin server cannot be restarted. It is advised to restart it manually by\n running \\"/etc/webmin/restart-by-force-kill\\" when upgrade process is finished"
fi
if [ -f /etc/webmin/.reload-init-systemd ]; then
/etc/webmin/.reload-init-systemd >/dev/null 2>&1 </dev/null
rm -f /etc/webmin/.reload-init-systemd
fi
fi
if [ "\$?" != "0" ]; then
echo "warning: Webmin server cannot be restarted. It is advised to restart it manually by\n running \\"/etc/webmin/restart-by-force-kill\\" when upgrade process is finished"
fi
fi
fi

View File

@@ -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 ".&quote_path("$wadir/init/updateboot.pl")." $bootscript");
}
else {
# Try to install init script to init.d
chdir("$wadir/init");
system("$perl ".&quote_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 ".&quote_path("$wadir/init/updateboot.pl")." $bootscript");
# If password delays are not specifically disabled, enable them
if (!defined($miniserv{'passdelay'}) && $os_type ne 'windows') {

View File

@@ -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

View File

@@ -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;

View File

@@ -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();

View File

@@ -19,6 +19,7 @@ index_tabsync2=Run system <tt>$1</tt> 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 <tt>time</tt> 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

View File

@@ -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";

View File

@@ -18,6 +18,14 @@ $access{'upgrade'} = 0 if (&is_readonly_mode()); # too hard to fake
&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";

View File

@@ -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);

View File

@@ -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'} ] ]);

View File

@@ -64,6 +64,13 @@ push(@wicons, "images/ssl.gif", "images/ca.gif");
# 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} ||

View File

@@ -108,6 +108,68 @@ 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;
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) {
&lock_file("$config_directory/config");
$gconfig{'noselfwebminup'} = $has_repos;
&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
@@ -1264,14 +1326,12 @@ 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'}))) {
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