mirror of
https://github.com/webmin/webmin.git
synced 2026-03-11 05:12:03 +00:00
Fix qmail alias file write path and tempfile safety (#4)
This commit is contained in:
@@ -5,6 +5,11 @@
|
||||
require './qmail-lib.pl';
|
||||
&ReadParseMime();
|
||||
&error_setup($text{'ffile_err'});
|
||||
my %access = &get_module_acl();
|
||||
my $base = &simplify_path($access{'apath'} || $qmail_alias_dir);
|
||||
my $file = &simplify_path($in{'file'});
|
||||
&is_under_directory($base, $file) || &error(&text('ffile_efile', $in{'file'}));
|
||||
$in{'file'} = $file;
|
||||
|
||||
for($i=0; defined($in{"field_$i"}); $i++) {
|
||||
next if (!$in{"field_$i"});
|
||||
@@ -15,8 +20,8 @@ for($i=0; defined($in{"field_$i"}); $i++) {
|
||||
}
|
||||
push(@filter, "2 ".$in{'other'}."\n") if ($in{'other'});
|
||||
|
||||
open(FILE, ">$in{'file'}");
|
||||
print FILE @filter;
|
||||
close(FILE);
|
||||
&open_lock_tempfile(FILE, ">$in{'file'}");
|
||||
&print_tempfile(FILE, @filter);
|
||||
&close_tempfile(FILE);
|
||||
&redirect("edit_alias.cgi?name=$in{'name'}");
|
||||
|
||||
|
||||
@@ -4,6 +4,11 @@
|
||||
|
||||
require './qmail-lib.pl';
|
||||
&ReadParseMime();
|
||||
my %access = &get_module_acl();
|
||||
my $base = &simplify_path($access{'apath'} || $qmail_alias_dir);
|
||||
my $file = &simplify_path($in{'file'});
|
||||
&is_under_directory($base, $file) || &error(&text('rfile_efile', $in{'file'}));
|
||||
$in{'file'} = $file;
|
||||
|
||||
$in{'replies_def'} || $in{'replies'} =~ /^\/\S+/ ||
|
||||
&error($text{'rfile_ereplies'});
|
||||
@@ -11,14 +16,14 @@ $in{'period_def'} || $in{'period'} =~ /^\d+$/ ||
|
||||
&error($text{'rfile_eperiod'});
|
||||
|
||||
$in{'text'} =~ s/\r//g;
|
||||
open(FILE, ">$in{'file'}");
|
||||
&open_lock_tempfile(FILE, ">$in{'file'}");
|
||||
if (!$in{'replies_def'}) {
|
||||
print FILE "Reply-Tracking: $in{'replies'}\n";
|
||||
&print_tempfile(FILE, "Reply-Tracking: $in{'replies'}\n");
|
||||
}
|
||||
if (!$in{'period_def'}) {
|
||||
print FILE "Reply-Period: $in{'period'}\n";
|
||||
&print_tempfile(FILE, "Reply-Period: $in{'period'}\n");
|
||||
}
|
||||
print FILE $in{'text'};
|
||||
close(FILE);
|
||||
&print_tempfile(FILE, $in{'text'});
|
||||
&close_tempfile(FILE);
|
||||
&redirect("edit_alias.cgi?name=$in{'name'}");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user