From af4a8a8522118cfd15b0c58f81d748a9184a0ef8 Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Fri, 13 Jan 2012 09:13:41 +0100 Subject: [PATCH] allow port 0 to use default value --- PVE/API2/Domains.pm | 20 +++++++++++++++----- PVE/AccessControl.pm | 4 ++-- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/PVE/API2/Domains.pm b/PVE/API2/Domains.pm index f080c71..117ef3c 100644 --- a/PVE/API2/Domains.pm +++ b/PVE/API2/Domains.pm @@ -94,9 +94,9 @@ __PACKAGE__->register_method ({ optional => 1, }, port => { - description => "Server port", + description => "Server port. Use '0' if you want to use default settings'", type => 'integer', - minimum => 1, + minimum => 0, maximum => 65535, optional => 1, }, @@ -137,7 +137,7 @@ __PACKAGE__->register_method ({ if (defined($param->{secure})) { $cfg->{$realm}->{secure} = $param->{secure} ? 1 : 0; } - + if ($param->{default}) { foreach my $r (keys %$cfg) { delete $cfg->{$r}->{default}; @@ -149,6 +149,11 @@ __PACKAGE__->register_method ({ $cfg->{$realm}->{$p} = $param->{$p}; } + # port 0 ==> use default + if (defined($param->{port}) && !$param->{port}) { + delete $cfg->{$realm}->{port}; + } + cfs_write_file($domainconfigfile, $cfg); }, "add auth server failed"); @@ -190,9 +195,9 @@ __PACKAGE__->register_method ({ optional => 1, }, port => { - description => "Server port", + description => "Server port. Use '0' if you want to use default settings'", type => 'integer', - minimum => 1, + minimum => 0, maximum => 65535, optional => 1, }, @@ -245,6 +250,11 @@ __PACKAGE__->register_method ({ $cfg->{$realm}->{$p} = $param->{$p}; } + # port 0 ==> use default + if (defined($param->{port}) && !$param->{port}) { + delete $cfg->{$realm}->{port}; + } + cfs_write_file($domainconfigfile, $cfg); }, "update auth server failed"); diff --git a/PVE/AccessControl.pm b/PVE/AccessControl.pm index 3bdc7de..3db2bff 100644 --- a/PVE/AccessControl.pm +++ b/PVE/AccessControl.pm @@ -552,7 +552,7 @@ my $valid_attributes = { server1 => '[\w\d]+(.[\w\d]+)*', server2 => '[\w\d]+(.[\w\d]+)*', domain => '\S+', - port => '\d*', + port => '\d+', secure => '', comment => '.*', }, @@ -562,7 +562,7 @@ my $valid_attributes = { base_dn => '\w+=[\w\s]+(,\s*\w+=[\w\s]+)*', user_attr => '\S{2,}', secure => '', - port => '\d*', + port => '\d+', comment => '.*', } }; -- 2.39.2