5
0
mirror of git://git.proxmox.com/git/pve-common.git synced 2024-12-22 21:33:47 +03:00

runtest: clone config before passing to write to avoid side effects

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>
This commit is contained in:
Thomas Lamprecht 2020-03-13 11:01:01 +01:00
parent 3219cb94e3
commit ffe0b0e075

View File

@ -8,6 +8,7 @@ use warnings;
use Carp; use Carp;
use POSIX; use POSIX;
use IO::Handle; 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. # Turn the current network config into a string.
sub w() { 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);
} }
## ##