mirror of
https://github.com/webmin/webmin.git
synced 2026-09-20 04:20:39 +01:00
chroot options for shell module
This commit is contained in:
@@ -8,6 +8,9 @@ sub acl_security_form
|
||||
print &ui_table_row($text{'acl_user'},
|
||||
&ui_opt_textbox("user", $_[0]->{'user'}, 20, $text{'acl_user_def'})." ".
|
||||
&user_chooser_button("user"));
|
||||
|
||||
print &ui_table_row($text{'acl_chroot'},
|
||||
&ui_filebox("chroot", $_[0]->{'chroot'}, 30, 0, 0, undef, 1));
|
||||
}
|
||||
|
||||
# acl_security_save(&options)
|
||||
@@ -15,5 +18,6 @@ print &ui_table_row($text{'acl_user'},
|
||||
sub acl_security_save
|
||||
{
|
||||
$_[0]->{'user'} = $in{'user_def'} ? undef : $in{'user'};
|
||||
$_[0]->{'chroot'} = $in{'chroot'};
|
||||
}
|
||||
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
user=root
|
||||
chroot=/
|
||||
|
||||
@@ -43,19 +43,21 @@ if (!$in{'clear'}) {
|
||||
$history = &un_urlize($in{'history'});
|
||||
if ($cmd) {
|
||||
# Execute the latest command
|
||||
$chroot = $access{'chroot'} eq '/' ? '' : $access{'chroot'};
|
||||
$fullcmd = $cmd;
|
||||
$ok = chdir($pwd);
|
||||
$ok = chdir($chroot.$pwd);
|
||||
$history .= "<b>> ".&html_escape($cmd, 1)."</b>\n";
|
||||
if ($cmd =~ /^cd\s+"([^"]+)"\s*(;?\s*(.*))$/ ||
|
||||
$cmd =~ /^cd\s+'([^']+)'\s*(;?\s*(.*))$/ ||
|
||||
$cmd =~ /^cd\s+([^; ]*)\s*(;?\s*(.*))$/) {
|
||||
$cmd = undef;
|
||||
if (!chdir($1)) {
|
||||
if (!chdir($chroot.$1)) {
|
||||
$history .= &html_escape("$1: $!\n", 1);
|
||||
}
|
||||
else {
|
||||
$cmd = $3 if ($2);
|
||||
$pwd = &get_current_dir();
|
||||
$pwd =~ s/^\Q$chroot\E//g;
|
||||
}
|
||||
}
|
||||
if ($cmd) {
|
||||
@@ -70,6 +72,10 @@ if (!$in{'clear'}) {
|
||||
else {
|
||||
$cmd = "($cmd)";
|
||||
}
|
||||
if ($chroot) {
|
||||
$cmd = "chroot ".quotemeta($access{'chroot'}).
|
||||
"sh -c ".quotemeta($cmd);
|
||||
}
|
||||
$pid = &open_execute_command(OUTPUT, $cmd, 2, 0);
|
||||
$out = "";
|
||||
$trunc = 0;
|
||||
|
||||
Reference in New Issue
Block a user