From 1c7d5214f68b5715e848a19db1cff7da542d89e6 Mon Sep 17 00:00:00 2001 From: rettenbe Date: Tue, 9 Dec 2008 13:52:22 +0000 Subject: [PATCH] bugfix: writing ntp server file git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@13206 594d385d-05f5-0310-b6e9-bd551577e9d8 --- gosa-si/client/events/corefunctions.pm | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/gosa-si/client/events/corefunctions.pm b/gosa-si/client/events/corefunctions.pm index 7af8f4941..7e19a8b18 100644 --- a/gosa-si/client/events/corefunctions.pm +++ b/gosa-si/client/events/corefunctions.pm @@ -241,26 +241,28 @@ sub new_ntp_config { open (FILE, "<$chrony_file"); my @file = ; close FILE; + my @new_file; foreach my $line (@file) { - if ($line =~ /server /) { - if ($found_server_flag) { - $line =~ s/^server [\s\S]+$//; + if ($line =~ /^server\s+/) { + if ($found_server_flag) { + $line =~ s/^server\s+[\S]+\s+$//; } else { - $line =~ s/^server [\s\S]+$/$ntp_servers_string/; + $line =~ s/^server\s+[\S]+\s+$/$ntp_servers_string/; } $found_server_flag++; } + push(@new_file, $line); } # Append new server if no old server configuration found if (not $found_server_flag) { - push(@file, "\n# ntp server configuration written by GOsa-si\n"); - push(@file, $ntp_servers_string); + push(@new_file, "\n# ntp server configuration written by GOsa-si\n"); + push(@new_file, $ntp_servers_string); } # Write changes to file and close it open (FILE, ">$chrony_file"); - print FILE join("", @file); + print FILE join("", @new_file); close FILE; &main::daemon_log("INFO: wrote new configuration file: $chrony_file", 5); -- 2.30.2