]> git.proxmox.com Git - pve-common.git/commitdiff
runtest: clone config before passing to write to avoid side effects
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Fri, 13 Mar 2020 10:01:01 +0000 (11:01 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Fri, 13 Mar 2020 10:02:01 +0000 (11:02 +0100)
write changes some parts of the config, if this is a reference to the
config used for checking parsing it may lead to unexpected failures
due to those side effects..

For me it was "cidr" and "cidr6" getting deleted, and thus upcomming
tests for a compat change failing without any apparent reason.. :/

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
test/etc_network_interfaces/runtest.pl

index c067dd1b38f3c498f437b850b9f33f204513a397..b5277c3b1b0350c9b448330d489dcbd3e5d5be16 100755 (executable)
@@ -8,6 +8,7 @@ use warnings;
 use Carp;
 use POSIX;
 use IO::Handle;
 use Carp;
 use POSIX;
 use IO::Handle;
+use Storable qw(dclone);
 
 use PVE::INotify;
 
 
 use PVE::INotify;
 
@@ -74,7 +75,9 @@ sub r($;$$) {
 
 # Turn the current network config into a string.
 sub w() {
 
 # Turn the current network config into a string.
 sub w() {
-    return PVE::INotify::__write_etc_network_interfaces($config);
+    # write shouldn't be able to change a previously parsed config
+    my $config_clone = dclone($config);
+    return PVE::INotify::__write_etc_network_interfaces($config_clone);
 }
 
 ##
 }
 
 ##