mirror of
https://github.com/webmin/webmin.git
synced 2026-03-20 16:50:24 +00:00
Merge pull request #1887 from webmin/dev/xterm-in-usermin
Add support for Terminal to work in Usermin
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -1211,63 +1211,6 @@ foreach $w (@wds) {
|
||||
$_[0]->{'weekdays'} = join(",", @wds);
|
||||
}
|
||||
|
||||
=head2 create_wrapper(wrapper-path, module, script)
|
||||
|
||||
Creates a wrapper script which calls a script in some module's directory
|
||||
with the proper webmin environment variables set. This should always be used
|
||||
when setting up a cron job, instead of attempting to run a command in the
|
||||
module directory directly.
|
||||
|
||||
The parameters are :
|
||||
|
||||
=item wrapper-path - Full path to the wrapper to create, like /etc/webmin/yourmodule/foo.pl
|
||||
|
||||
=item module - Module containing the real script to call.
|
||||
|
||||
=item script - Program within that module for the wrapper to run.
|
||||
|
||||
=cut
|
||||
sub create_wrapper
|
||||
{
|
||||
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]);
|
||||
}
|
||||
|
||||
=head2 cron_file(&job)
|
||||
|
||||
Returns the file that a cron job is in, or will be in when it is created
|
||||
@@ -1785,5 +1728,12 @@ foreach $r (split(/,/, $_[0])) {
|
||||
return sort { $a <=> $b } @rv;
|
||||
}
|
||||
|
||||
# create_wrapper(@_)
|
||||
# Deprecated and left for backward compatibility
|
||||
sub create_wrapper
|
||||
{
|
||||
&create_program_wrapper(@_);
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
|
||||
@@ -12951,4 +12951,62 @@ return $locale_def;
|
||||
|
||||
$done_web_lib_funcs = 1;
|
||||
|
||||
=head2 create_program_wrapper(wrapper-path, module, script)
|
||||
|
||||
Creates a wrapper script which calls a script in some module's directory
|
||||
with the proper webmin environment variables set. This should always be used
|
||||
when setting up a cron job, instead of attempting to run a command in the
|
||||
module directory directly.
|
||||
|
||||
The parameters are :
|
||||
|
||||
=item wrapper-path - Full path to the wrapper to create, like /etc/webmin/yourmodule/foo.pl
|
||||
|
||||
=item module - Module containing the real script to call.
|
||||
|
||||
=item script - Program within that module for the wrapper to run.
|
||||
|
||||
=cut
|
||||
|
||||
sub create_program_wrapper
|
||||
{
|
||||
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;
|
||||
|
||||
@@ -23,7 +23,12 @@ foreach my $modname (@modnames) {
|
||||
&text('index_suse', "<tt>$modname</tt>",
|
||||
'https://software.opensuse.org/download/package?package=perl-IO-Tty&project=devel%3Alanguages%3Aperl');
|
||||
}
|
||||
print $missinglink ."<p>\n";
|
||||
if (&get_product_name() eq 'usermin') {
|
||||
print &text('index_missing', $modname) ."<p>\n";
|
||||
}
|
||||
else {
|
||||
print $missinglink ."<p>\n";
|
||||
}
|
||||
&ui_print_footer("/", $text{'index'});
|
||||
exit;
|
||||
}
|
||||
@@ -179,10 +184,9 @@ my @uinfo = getpwnam($user);
|
||||
my $dir = $in{'dir'};
|
||||
|
||||
# Launch the shell server on the allocated port
|
||||
&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_program_wrapper($shellserver_cmd, $module_name, "shellserver.pl");
|
||||
}
|
||||
my $tmpdir = &tempname_dir();
|
||||
$ENV{'SESSION_ID'} = $main::session_id;
|
||||
|
||||
@@ -4,6 +4,7 @@ index_epel=It is recommended to have <a href='$1' target='_blank'>EPEL</a> repos
|
||||
index_suse=The Perl package <tt>perl-IO-Tty</tt> is missing, and should be manually installed first from <a href='$2' target='_blank'>devel:languages:perl</a> repository.
|
||||
index_euser=Error : User $1 cannot run the shell as it does not exist!
|
||||
index_connecting=Connecting ..
|
||||
index_missing=The Perl module <tt>$1</tt> is missing. You need to contact your administrator to resolve this issue.
|
||||
|
||||
acl_user=Run shell as Unix user
|
||||
acl_sameuser=Same as Webmin login
|
||||
|
||||
@@ -97,4 +97,4 @@ if (@clean) {
|
||||
&unlock_file(&get_miniserv_config_file());
|
||||
}
|
||||
|
||||
1;
|
||||
1;
|
||||
|
||||
Reference in New Issue
Block a user