mirror of
https://github.com/webmin/webmin.git
synced 2026-03-20 16:50:24 +00:00
Fix not to depend on Cron
This commit is contained in:
@@ -19,8 +19,7 @@ use WebminCore;
|
||||
$env_support = $config{'vixie_cron'};
|
||||
if ($module_info{'usermin'}) {
|
||||
$single_user = $remote_user;
|
||||
&switch_to_remote_user()
|
||||
if (!getvar('cron_no_switch_to_remote_user'));
|
||||
&switch_to_remote_user();
|
||||
&create_user_config_dirs();
|
||||
$range_cmd = "$user_module_config_directory/range.pl";
|
||||
$hourly_only = 0;
|
||||
|
||||
@@ -184,12 +184,9 @@ my @uinfo = getpwnam($user);
|
||||
my $dir = $in{'dir'};
|
||||
|
||||
# Launch the shell server on the allocated port
|
||||
setvar('cron_no_switch_to_remote_user', 1)
|
||||
if (&get_product_name() eq 'usermin');
|
||||
&foreign_require("cron");
|
||||
my $shellserver_cmd = "$module_config_directory/shellserver.pl";
|
||||
if (!-r $shellserver_cmd) {
|
||||
&cron::create_wrapper($shellserver_cmd, $module_name, "shellserver.pl");
|
||||
&create_wrapper_local($shellserver_cmd, $module_name, "shellserver.pl");
|
||||
}
|
||||
my $tmpdir = &tempname_dir();
|
||||
$ENV{'SESSION_ID'} = $main::session_id;
|
||||
|
||||
@@ -97,4 +97,47 @@ if (@clean) {
|
||||
&unlock_file(&get_miniserv_config_file());
|
||||
}
|
||||
|
||||
# create_wrapper_local(wrapper-path, module, script)
|
||||
# Export from Cron module to create a wrapper script
|
||||
sub create_wrapper_local
|
||||
{
|
||||
local $perl_path = &get_perl_path();
|
||||
&open_tempfile(CMD, ">$_[0]");
|
||||
&print_tempfile(CMD, <<EOF
|
||||
#!$perl_path
|
||||
open(CONF, "<$config_directory/miniserv.conf") || die "Failed to open $config_directory/miniserv.conf : \$!";
|
||||
while(<CONF>) {
|
||||
\$root = \$1 if (/^root=(.*)/);
|
||||
}
|
||||
close(CONF);
|
||||
\$root || die "No root= line found in $config_directory/miniserv.conf";
|
||||
\$ENV{'PERLLIB'} = "\$root";
|
||||
\$ENV{'WEBMIN_CONFIG'} = "$ENV{'WEBMIN_CONFIG'}";
|
||||
\$ENV{'WEBMIN_VAR'} = "$ENV{'WEBMIN_VAR'}";
|
||||
delete(\$ENV{'MINISERV_CONFIG'});
|
||||
EOF
|
||||
);
|
||||
if ($gconfig{'os_type'} eq 'windows') {
|
||||
# On windows, we need to chdir to the drive first, and use system
|
||||
&print_tempfile(CMD, "if (\$root =~ /^([a-z]:)/i) {\n");
|
||||
&print_tempfile(CMD, " chdir(\"\$1\");\n");
|
||||
&print_tempfile(CMD, " }\n");
|
||||
&print_tempfile(CMD, "chdir(\"\$root/$_[1]\");\n");
|
||||
&print_tempfile(CMD, "exit(system(\"\$root/$_[1]/$_[2]\", \@ARGV));\n");
|
||||
}
|
||||
else {
|
||||
# Can use exec on Unix systems
|
||||
if ($_[1]) {
|
||||
&print_tempfile(CMD, "chdir(\"\$root/$_[1]\");\n");
|
||||
&print_tempfile(CMD, "exec(\"\$root/$_[1]/$_[2]\", \@ARGV) || die \"Failed to run \$root/$_[1]/$_[2] : \$!\";\n");
|
||||
}
|
||||
else {
|
||||
&print_tempfile(CMD, "chdir(\"\$root\");\n");
|
||||
&print_tempfile(CMD, "exec(\"\$root/$_[2]\", \@ARGV) || die \"Failed to run \$root/$_[2] : \$!\";\n");
|
||||
}
|
||||
}
|
||||
&close_tempfile(CMD);
|
||||
chmod(0755, $_[0]);
|
||||
}
|
||||
|
||||
1;
|
||||
Reference in New Issue
Block a user