mirror of
https://github.com/webmin/webmin.git
synced 2026-02-03 06:03:28 +00:00
Create new files with same ownership as parent (and add some missing escaping)
This commit is contained in:
@@ -5,17 +5,25 @@ require './filemin-lib.pl';
|
||||
|
||||
get_paths();
|
||||
|
||||
if(!$in{'name'}) {
|
||||
&redirect("index.cgi?path=$path");
|
||||
}
|
||||
if (!$in{'name'}) {
|
||||
&redirect("index.cgi?path=".&urlize($path));
|
||||
return;
|
||||
}
|
||||
|
||||
my $full = "$cwd/$in{'name'}";
|
||||
if (-e $full) {
|
||||
print_errors(&html_escape($in{'name'})." ".$text{'error_exists'});
|
||||
}
|
||||
else {
|
||||
my @st = stat($cwd);
|
||||
if (open(my $fh, ">$full")) {
|
||||
close($fh);
|
||||
&set_ownership_permissions($st[4], $st[5], undef, $full);
|
||||
&redirect("index.cgi?path=".&urlize($path));
|
||||
}
|
||||
else {
|
||||
print_errors($text{'error_create'}." ".
|
||||
&html_escape($in{'name'})." : ".$!);
|
||||
}
|
||||
}
|
||||
|
||||
if (-f "$cwd/$in{'name'}") {
|
||||
print_errors("$in{'name'} $text{'error_exists'}");
|
||||
} else {
|
||||
if (open my $fh, "> $cwd/$in{'name'}") {
|
||||
close($fh);
|
||||
&redirect("index.cgi?path=$path");
|
||||
} else {
|
||||
print_errors("$in{'name'} - $text{'error_create'} $!");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,19 +6,19 @@ require './filemin-lib.pl';
|
||||
get_paths();
|
||||
|
||||
if (!$in{'name'}) {
|
||||
&redirect("index.cgi?path=$path");
|
||||
&redirect("index.cgi?path=".&urlize($path));
|
||||
return;
|
||||
}
|
||||
|
||||
my $full = "$cwd/$in{'name'}";
|
||||
if (-d $full) {
|
||||
if (-e $full) {
|
||||
print_errors(&html_escape($in{'name'})." ".$text{'error_exists'});
|
||||
}
|
||||
else {
|
||||
my @st = stat($cwd);
|
||||
if (&make_dir($full, oct(755)) ) {
|
||||
&set_ownership_permissions($st[4], $st[5], undef, $full);
|
||||
&redirect("index.cgi?path=$path");
|
||||
&redirect("index.cgi?path=".&urlize($path));
|
||||
}
|
||||
else {
|
||||
print_errors($text{'error_create'}." ".
|
||||
|
||||
Reference in New Issue
Block a user