allow port 0 to use default value

This commit is contained in:
Dietmar Maurer 2012-01-13 09:13:41 +01:00
parent a0492cd61b
commit af4a8a8522
2 changed files with 17 additions and 7 deletions

View File

@ -94,9 +94,9 @@ __PACKAGE__->register_method ({
optional => 1, optional => 1,
}, },
port => { port => {
description => "Server port", description => "Server port. Use '0' if you want to use default settings'",
type => 'integer', type => 'integer',
minimum => 1, minimum => 0,
maximum => 65535, maximum => 65535,
optional => 1, optional => 1,
}, },
@ -137,7 +137,7 @@ __PACKAGE__->register_method ({
if (defined($param->{secure})) { if (defined($param->{secure})) {
$cfg->{$realm}->{secure} = $param->{secure} ? 1 : 0; $cfg->{$realm}->{secure} = $param->{secure} ? 1 : 0;
} }
if ($param->{default}) { if ($param->{default}) {
foreach my $r (keys %$cfg) { foreach my $r (keys %$cfg) {
delete $cfg->{$r}->{default}; delete $cfg->{$r}->{default};
@ -149,6 +149,11 @@ __PACKAGE__->register_method ({
$cfg->{$realm}->{$p} = $param->{$p}; $cfg->{$realm}->{$p} = $param->{$p};
} }
# port 0 ==> use default
if (defined($param->{port}) && !$param->{port}) {
delete $cfg->{$realm}->{port};
}
cfs_write_file($domainconfigfile, $cfg); cfs_write_file($domainconfigfile, $cfg);
}, "add auth server failed"); }, "add auth server failed");
@ -190,9 +195,9 @@ __PACKAGE__->register_method ({
optional => 1, optional => 1,
}, },
port => { port => {
description => "Server port", description => "Server port. Use '0' if you want to use default settings'",
type => 'integer', type => 'integer',
minimum => 1, minimum => 0,
maximum => 65535, maximum => 65535,
optional => 1, optional => 1,
}, },
@ -245,6 +250,11 @@ __PACKAGE__->register_method ({
$cfg->{$realm}->{$p} = $param->{$p}; $cfg->{$realm}->{$p} = $param->{$p};
} }
# port 0 ==> use default
if (defined($param->{port}) && !$param->{port}) {
delete $cfg->{$realm}->{port};
}
cfs_write_file($domainconfigfile, $cfg); cfs_write_file($domainconfigfile, $cfg);
}, "update auth server failed"); }, "update auth server failed");

View File

@ -552,7 +552,7 @@ my $valid_attributes = {
server1 => '[\w\d]+(.[\w\d]+)*', server1 => '[\w\d]+(.[\w\d]+)*',
server2 => '[\w\d]+(.[\w\d]+)*', server2 => '[\w\d]+(.[\w\d]+)*',
domain => '\S+', domain => '\S+',
port => '\d*', port => '\d+',
secure => '', secure => '',
comment => '.*', comment => '.*',
}, },
@ -562,7 +562,7 @@ my $valid_attributes = {
base_dn => '\w+=[\w\s]+(,\s*\w+=[\w\s]+)*', base_dn => '\w+=[\w\s]+(,\s*\w+=[\w\s]+)*',
user_attr => '\S{2,}', user_attr => '\S{2,}',
secure => '', secure => '',
port => '\d*', port => '\d+',
comment => '.*', comment => '.*',
} }
}; };