mirror of
https://github.com/webmin/webmin.git
synced 2026-03-20 16:50:24 +00:00
Fix IPv6 support with TCP Wrappers module
https://sourceforge.net/p/webadmin/bugs/5506/ https://sourceforge.net/p/webadmin/bugs/5521/
This commit is contained in:
@@ -23,8 +23,10 @@ if ($in{'delete'}) {
|
||||
&error($text{'save_eservice'}) if ($in{'service_custom'} && $in{'service_custom'} !~ /^[\w\d\s\-\/\.,]+$/);
|
||||
&error($text{'save_eservice'}) if ($in{'service_except_custom'} && $in{'service_except_custom'} !~ /^[\w\d\s\-\/\.,]+$/);
|
||||
|
||||
&error($text{'save_ehost'}) if ($in{'host_text_def'} == 0 && $in{'host_text'} !~ /^[\w\d\s\-\/\@\.,]+$/);
|
||||
&error($text{'save_ehost'}) if ($in{'host_except'} && $in{'host_except'} !~ /^[\w\d\s\-\/\@\.,]+$/);
|
||||
&error($text{'save_ehost'})
|
||||
if ($in{'host_text_def'} == 0 && $in{'host_text'} !~ /^[\w\d\s\-\/\@\.,]+$/ && $in{'host_text'} !~ /^\[[:\d]+\]/);
|
||||
&error($text{'save_ehost'})
|
||||
if ($in{'host_except'} && $in{'host_except'} !~ /^[\w\d\s\-\/\@\.,]+$/ && $in{'host_except'} !~ /^\[[:\d]+\]/);
|
||||
|
||||
for (my $i = 0; $i <= $in{'cmd_count'}; $i++) {
|
||||
&error($text{'save_ecmd'}) if ($in{'cmd_'.$i} && $in{'cmd_'.$i} !~ /^[\w\d\s\-\/\@\%\|\(\)\'\"\&\.,]+$/);
|
||||
@@ -58,10 +60,12 @@ for (my $i = 0; $i <= $in{'cmd_count'}; $i++) {
|
||||
$cmd .= $in{'cmd_'.$i};
|
||||
}
|
||||
|
||||
|
||||
my %newrule = ( 'service' => $service,
|
||||
'host' => $host,
|
||||
'cmd' => $cmd
|
||||
);
|
||||
webmin_debug_var_dump(\%newrule, 'save_rule');
|
||||
|
||||
# Save to file
|
||||
if ($in{'new'}) {
|
||||
|
||||
@@ -38,11 +38,20 @@ sub list_rules {
|
||||
} else {
|
||||
my @cmtlines = split(/\n/, $cmt);
|
||||
$cmt = undef;
|
||||
$line =~ s/\\:/\0/g;
|
||||
my ($service, $host, $cmd) = split /:/, $line, 3;
|
||||
$host =~ s/\0/:/g;
|
||||
|
||||
# Fix further splitting on : to work with ipv6
|
||||
my $ipv6;
|
||||
my $ipv6_enc;
|
||||
|
||||
# Match ipv6 with or without range
|
||||
if ($line =~ /(?|(\[[:\d]+\]\/\d+)|(\[[:\d]+\]))/) {
|
||||
$ipv6 = $1;
|
||||
$ipv6_enc = &encode_base64($ipv6);
|
||||
$line =~ s/\Q$ipv6\E/$ipv6_enc/;
|
||||
}
|
||||
my ($service, $host, $cmd) = split /:/, $line, 3;
|
||||
$service =~ s/^\s*//; $service =~ s/\s*$//;
|
||||
$host =~ s/^\s*//; $host =~ s/\s*$//;
|
||||
$host =~ s/^\s*\Q$ipv6_enc\E/$ipv6/; $host =~ s/\s*$//;
|
||||
|
||||
push @ret, { 'id' => $id++,
|
||||
'service' => $service,
|
||||
@@ -100,9 +109,7 @@ sub create_rule {
|
||||
my ($file, $rule) = @_;
|
||||
|
||||
my $lref = &read_file_lines($file);
|
||||
my $host = $rule->{'host'};
|
||||
$host =~ s/:/\\:/g;
|
||||
my $newline = $rule->{'service'}.' : '.$host.($rule->{'cmd'} ? ' : '.$rule->{'cmd'} : '');
|
||||
my $newline = $rule->{'service'}.' : '.$rule->{'host'}.($rule->{'cmd'} ? ' : '.$rule->{'cmd'} : '');
|
||||
push(@$lref, $newline);
|
||||
&flush_file_lines($file);
|
||||
}
|
||||
@@ -112,9 +119,7 @@ sub create_rule {
|
||||
sub modify_rule {
|
||||
my ($filename, $oldrule, $newrule) = @_;
|
||||
|
||||
my $host = $newrule->{'host'};
|
||||
$host =~ s/:/\\:/g;
|
||||
my @newline = ($newrule->{'service'}.' : '.$host.($newrule->{'cmd'} ? ' : '.$newrule->{'cmd'} : ''));
|
||||
my @newline = ($newrule->{'service'}.' : '.$newrule->{'host'}.($newrule->{'cmd'} ? ' : '.$newrule->{'cmd'} : ''));
|
||||
|
||||
my $lref = &read_file_lines($filename);
|
||||
my $len = $oldrule->{'eline'} - $oldrule->{'line'} + 1;
|
||||
|
||||
Reference in New Issue
Block a user