Skip to content

Commit

Permalink
Fix to test if delete, rename, paste and save is allowed webmin/webmi…
Browse files Browse the repository at this point in the history
  • Loading branch information
iliajie committed Nov 28, 2024
1 parent 53425a3 commit dec6ee0
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 7 deletions.
14 changes: 12 additions & 2 deletions extensions/file-manager/delete.cgi
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ foreach my $name (@entries_list) {
$name = simplify_path($name);
if ($in{'etrash'}) {
my $tdir = "$cwd/$tdirname/";
if (!can_write($tdir)) {
$errors{$name_} = lc($text{'error_delete'} . lc(" - $text{'error_write'}"));
next;
}
if (!&unlink_file($tdir)) {
$errors{$name_} = lc($text{'error_delete'} . lc(" - $!"));
} else {
Expand Down Expand Up @@ -65,7 +69,10 @@ foreach my $name (@entries_list) {
if (&is_under_directory("$cwd/$name", $tfile || "$tdir/$name")) {
# If .Trash the only one in list, delete it
if (scalar(@entries_list) == 1) {
if (!&unlink_file("$cwd/$name")) {
if (!can_write("$cwd/$name")) {
$errors{$name_} = lc($text{'error_delete'} . lc(" - $text{'error_write'}"));
}
elsif (!&unlink_file("$cwd/$name")) {
$errors{$name_} = lc($text{'error_delete'} . lc(" - $!"));
} else {
$etrashed = 1;
Expand All @@ -79,7 +86,10 @@ foreach my $name (@entries_list) {
push(@deleted_entries, $name);
}
} else {
if (!&unlink_file($cwd . '/' . $name)) {
if (!can_write($cwd . '/' . $name)) {
$errors{$name_} = lc($text{'error_delete'} . lc(" - $text{'error_write'}"));
}
elsif (!&unlink_file($cwd . '/' . $name)) {
$errors{$name_} = lc($text{'error_delete'} . lc(" - $!"));
} else {
push(@deleted_entries, $name);
Expand Down
6 changes: 5 additions & 1 deletion extensions/file-manager/paste.cgi
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#
use strict;

our (%in, %request_uri, $cwd, $base, $path);
our (%in, %text, %request_uri, $cwd, $base, $path);

do($ENV{'THEME_ROOT'} . "/extensions/file-manager/file-manager-lib.pl");

Expand Down Expand Up @@ -50,6 +50,10 @@ if (!$dr) {
for (my $i = 2; $i <= scalar(@arr) - 1; $i++) {
chomp($arr[$i]);
$arr[$i] = simplify_path($arr[$i]);
if (!can_move("$from/$arr[$i]", $cwd, $from)) {
$errors{"$arr[$i]"} = "$text{'error_move'}";
next;
}
my $err = paster("$cwd", "$arr[$i]", "$from/$arr[$i]", "$cwd/$arr[$i]", $fo, $mv, $in{'fownergroup'});
if ($err) {
$errors{"$arr[$i]"} = $err;
Expand Down
5 changes: 3 additions & 2 deletions extensions/file-manager/rename.cgi
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,15 @@ if (-e "$cwd/$in{'name'}") {
my $to = $in{'name'};
my $fsid = $in{'fsid'};

if (rename_file($cwd . '/' . $from, $cwd . '/' . $to)) {
if (can_move($cwd . '/' . $from, $cwd) &&
rename_file($cwd . '/' . $from, $cwd . '/' . $to)) {
cache_search_rename($fsid, $from, $to) if ($fsid);
redirect_local('list.cgi?path=' . urlize($path) . '&module=filemin' . extra_query());
} else {
print_error(
(
text('filemanager_rename_denied',
html_escape($in{'name'}),
html_escape($to),
html_escape($path),
lc($text{ 'theme_xhred_global_' . $type . '' })
)
Expand Down
2 changes: 1 addition & 1 deletion theme.info
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ bootstrap=3
spa=1
nomodcall=xnavigation=1
version=21.30-beta1
mversion=07
mversion=08
bversion=00
webmin=1
usermin=1
Expand Down
2 changes: 1 addition & 1 deletion unauthenticated/js/bundle.min.js

Large diffs are not rendered by default.

Binary file modified unauthenticated/js/bundle.min.js.gz
Binary file not shown.

0 comments on commit dec6ee0

Please sign in to comment.