]> git.proxmox.com Git - pve-access-control.git/blobdiff - PVE/API2/Domains.pm
fix perl syntax
[pve-access-control.git] / PVE / API2 / Domains.pm
index f080c716e92eeeecfdcdeae113166aa228001102..c79e44e0f033a1cbc08a645efabe029677ef9812 100644 (file)
@@ -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};
@@ -146,7 +146,15 @@ __PACKAGE__->register_method ({
 
                foreach my $p (keys %$param) {
                    next if $p eq 'realm';
-                   $cfg->{$realm}->{$p} = $param->{$p};
+                   $cfg->{$realm}->{$p} = $param->{$p} if $param->{$p};
+               }
+
+               # port 0 ==> use default
+               # server2 == '' ===> delete server2
+               for my $p (qw(port server2)) { 
+                   if (defined($param->{$p}) && !$param->{$p}) { 
+                       delete $cfg->{$realm}->{$p};
+                   }
                }
 
                cfs_write_file($domainconfigfile, $cfg);
@@ -190,9 +198,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,
            },
@@ -242,7 +250,11 @@ __PACKAGE__->register_method ({
                }
 
                foreach my $p (keys %$param) {
-                   $cfg->{$realm}->{$p} = $param->{$p};
+                   if ($param->{$p}) {
+                       $cfg->{$realm}->{$p} = $param->{$p};
+                   } else {
+                       delete $cfg->{$realm}->{$p};
+                   }
                }
 
                cfs_write_file($domainconfigfile, $cfg);