From cc4799a676331db92e00a0f56361007eb561c407 Mon Sep 17 00:00:00 2001 From: ivan Date: Sat, 26 Feb 2011 01:44:10 +0000 Subject: [PATCH] fix newlines in interface addition, throw some sort of error for duplicate addition, RT#10574 --- FS/FS/NetworkMonitoringSystem/Torrus_Internal.pm | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/FS/FS/NetworkMonitoringSystem/Torrus_Internal.pm b/FS/FS/NetworkMonitoringSystem/Torrus_Internal.pm index e7d3db12f..4c3264e68 100644 --- a/FS/FS/NetworkMonitoringSystem/Torrus_Internal.pm +++ b/FS/FS/NetworkMonitoringSystem/Torrus_Internal.pm @@ -132,9 +132,13 @@ sub add_interface { #should just use a proper XML parser huh + my @ddx = split(/\n/, $self->_torrus_loadddx); + + die "Torrus Service ID $serviceid in use\n" + if grep /^\s*$serviceid:/, @ddx; + my $newline = " $serviceid:$interface:Both:main,"; - my @ddx = split(/\n/, $self->_torrus_loadddx); my $new = ''; my $added = 0; @@ -149,10 +153,10 @@ sub add_interface { while ( my $paramline = shift(@ddx) ) { if ( $paramline =~ /^\s*<\/param>/ ) { - $new .= "$newline\n$paramline"; + $new .= "$newline\n$paramline\n"; last; #paramline } else { - $new .= $paramline; + $new .= "$paramline\n"; } } @@ -165,7 +169,7 @@ sub add_interface { qq( $newline\n"). qq( \n); } - $new .= $hostline; + $new .= "$hostline\n"; last; #hostline } @@ -212,7 +216,7 @@ sub _torrus_newddx { sub _torrus_reload { my($self) = @_; - #i should have better error checking + #i should use IPC::Run and have better error checking system('torrus', 'devdiscover', "--in=$ddxfile"); -- 2.11.0