chroot options for shell module

This commit is contained in:
Jamie Cameron
2017-04-19 13:54:16 -07:00
parent 2c194271fc
commit eaf63ebc48
3 changed files with 13 additions and 2 deletions

View File

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

View File

@@ -1 +1,2 @@
user=root
chroot=/

View File

@@ -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>&gt; ".&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;