From 35264e3a40ad483eea1a74281ce92b8145431fbf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20D=C3=ADaz=20Gonz=C3=A1lez?= Date: Fri, 19 Jul 2019 13:17:32 +0100 Subject: [PATCH 01/10] adapt Rakefile and Dockerfile for SLE-12-SP5 --- Dockerfile | 3 ++- Rakefile | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 57e75e9b..57087fbf 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,5 @@ -FROM yastdevel/ruby:sle12-sp4 +FROM yastdevel/ruby:sle12-sp5 + COPY . /usr/src/app diff --git a/Rakefile b/Rakefile index 2cf05745..6be65221 100644 --- a/Rakefile +++ b/Rakefile @@ -1,6 +1,6 @@ require "yast/rake" -Yast::Tasks.submit_to :sle12sp4 +Yast::Tasks.submit_to :sle12sp5 Yast::Tasks.configuration do |conf| # lets ignore license check for now From 17af584b43f423a2b31c45030e69e8e3d09a15e3 Mon Sep 17 00:00:00 2001 From: Arvin Schnell Date: Fri, 2 Aug 2019 15:19:11 +0200 Subject: [PATCH 02/10] Fixed saving /etc/ntp.conf with certain comments (bsc#1142026) --- package/yast2-ntp-client.changes | 6 ++++++ package/yast2-ntp-client.spec | 2 +- src/lib/cfa/ntp_conf.rb | 4 ++-- src/modules/NtpClient.rb | 3 ++- test/cfa/ntp_conf_test.rb | 13 +++++++++++++ 5 files changed, 24 insertions(+), 4 deletions(-) diff --git a/package/yast2-ntp-client.changes b/package/yast2-ntp-client.changes index 224b6e6a..481b62d7 100644 --- a/package/yast2-ntp-client.changes +++ b/package/yast2-ntp-client.changes @@ -1,3 +1,9 @@ +------------------------------------------------------------------- +Fri Aug 02 15:16:17 CEST 2019 - aschnell@suse.com + +- Fixed saving /etc/ntp.conf with certain comments (bsc#1142026) +- 3.2.19 + ------------------------------------------------------------------- Thu Dec 13 12:45:27 UTC 2018 - knut.anderssen@suse.com diff --git a/package/yast2-ntp-client.spec b/package/yast2-ntp-client.spec index 9d324bfe..d255390e 100644 --- a/package/yast2-ntp-client.spec +++ b/package/yast2-ntp-client.spec @@ -17,7 +17,7 @@ Name: yast2-ntp-client -Version: 3.2.18 +Version: 3.2.19 Release: 0 Summary: YaST2 - NTP Client Configuration License: GPL-2.0+ diff --git a/src/lib/cfa/ntp_conf.rb b/src/lib/cfa/ntp_conf.rb index 57970936..95c889e1 100755 --- a/src/lib/cfa/ntp_conf.rb +++ b/src/lib/cfa/ntp_conf.rb @@ -97,8 +97,8 @@ def save comments = r.augeas[:multiline].split("\n") matcher = Matcher.new(key: r.augeas[:key], value_matcher: r.augeas[:value]) placer = BeforePlacer.new(matcher) - comments.each do |c| - data.add("#comment[]", c, placer) + comments.each do |comment| + data.add("#comment[]", comment.strip, placer) end end super diff --git a/src/modules/NtpClient.rb b/src/modules/NtpClient.rb index 3a5daac4..f0f0338f 100644 --- a/src/modules/NtpClient.rb +++ b/src/modules/NtpClient.rb @@ -1021,7 +1021,8 @@ def AutoPackages # Remove blank spaces in values # # @note to avoid augeas parsing errors, comments should be sanitized by - # removing blank spaces at the beginning and adding line break. + # removing blank spaces at the beginning and adding line break. Further + # sanitation is done in NtpConf.save. def sanitize_record(record) sanitized = record.dup sanitized.each do |key, value| diff --git a/test/cfa/ntp_conf_test.rb b/test/cfa/ntp_conf_test.rb index 2ab6b287..b9e89c09 100644 --- a/test/cfa/ntp_conf_test.rb +++ b/test/cfa/ntp_conf_test.rb @@ -94,6 +94,19 @@ def ntp_conf(file) expect(file.content.lines).to include("#test comment 2\n") expect(file.content.lines).to include("#test comment3\n") end + + # see bsc #1142026 + it "can write multi lines comments with unstripped whitespaces from autoyast profiles" do + record = CFA::NtpConf::ServerRecord.new + record.value = "4.pool.ntp.org" + record.comment = " test comment 4 \n \n test comment 5 " + ntp.records << record + expect(record.comment).to eq " test comment 4 \n \n test comment 5 " + ntp.save + expect(file.content.lines).to include("#test comment 4\n") + expect(file.content.lines).to include("#test comment 5\n") + expect(file.content.lines).to include("server 4.pool.ntp.org\n") + end end context "when a record is deleted" do From c3ae2e5f5f8e4629436f37bc3c0b3035a9c322d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Iv=C3=A1n=20L=C3=B3pez=20Gonz=C3=A1lez?= Date: Mon, 19 Aug 2019 12:56:59 +0100 Subject: [PATCH 03/10] Remove blank lines when sanitizing comments --- src/modules/NtpClient.rb | 61 ++++++++++++++++++++++++----- test/fixtures/autoyast/autoinst.xml | 6 ++- test/ntp_client_test.rb | 17 +++++++- 3 files changed, 72 insertions(+), 12 deletions(-) diff --git a/src/modules/NtpClient.rb b/src/modules/NtpClient.rb index f0f0338f..da90ef28 100644 --- a/src/modules/NtpClient.rb +++ b/src/modules/NtpClient.rb @@ -1018,24 +1018,65 @@ def AutoPackages private - # Remove blank spaces in values + # Sanitizes values of a record (mainly, by removing blank spaces) # - # @note to avoid augeas parsing errors, comments should be sanitized by - # removing blank spaces at the beginning and adding line break. Further - # sanitation is done in NtpConf.save. + # @param record [Hash] + # @return [Hash] def sanitize_record(record) sanitized = record.dup + sanitized.each do |key, value| - if key.include?("comment") - value.sub!(/^ */, "") - value << "\n" unless value.include?("\n") - elsif value.respond_to?(:strip!) - value.strip! - end + sanitized[key] = sanitize_attribute(key, value) end + sanitized end + # Sanitizes the value of an attribute + # + # @note To avoid augeas parsing errors, each comment line should be sanitized by removing blank + # spaces at the beginning and ensuring a line break, see {#sanitize_comment}. + # + # @param attribute [String] + # @param value [String] + # + # @return [String] sanitized value + def sanitize_attribute(attribute, value) + if attribute.include?("comment") + sanitize_comment(value) + elsif value.respond_to?(:strip) + value.strip + else + value + end + end + + # Sanitizes each line from a comment + # + # @param comment [String] + # @return [String] sanitized comment + def sanitize_comment(comment) + lines = comment.split("\n") + + sanitized_lines = lines.map { |l| sanitize_comment_line(l) } + + sanitized_lines.compact.join + end + + # Sanitizes a comment line by removing blank spaces at the beginning and ensuring a line break + # + # @param line [String] + # @return [String, nil] sanitized line. It returns nil if the line only contains blank spaces. + def sanitize_comment_line(line) + sanitized_line = line.lstrip + + return nil if sanitized_line.empty? + + sanitized_line << "\n" unless sanitized_line.include?("\n") + + sanitized_line + end + # Set @ntp_policy according to NETCONFIG_NTP_POLICY value found in # /etc/sysconfig/network/config or with "auto" if not found # diff --git a/test/fixtures/autoyast/autoinst.xml b/test/fixtures/autoyast/autoinst.xml index e0246fa5..ffba45f2 100644 --- a/test/fixtures/autoyast/autoinst.xml +++ b/test/fixtures/autoyast/autoinst.xml @@ -13,7 +13,11 @@
1.opensuse.pool.ntp.org
- + # a comment with spaces + + # and blank lines + + iburst server
diff --git a/test/ntp_client_test.rb b/test/ntp_client_test.rb index e594ae10..fdca87d9 100644 --- a/test/ntp_client_test.rb +++ b/test/ntp_client_test.rb @@ -61,6 +61,12 @@ expect(record["comment"]).to eq "# a comment with spaces \n" end + # see bsc #1142026 + it "sanitizes comments by removing blank lines" do + record = subject.ntp_records[1] + expect(record["comment"]).to eq "# a comment with spaces\n# and blank lines\n" + end + it "reads the list of peers" do expect(subject.ntp_records.size).to eq 5 end @@ -147,7 +153,16 @@ it "produces an output equivalent to #Import" do subject.Import(ntp_client_section) - expect(subject.Export()).to eq ntp_client_section + + result = subject.Export + + expect(result["synchronize_time"]).to eq(ntp_client_section["synchronize_time"]) + expect(result["sync_interval"]).to eq(ntp_client_section["sync_interval"]) + expect(result["start_at_boot"]).to eq(ntp_client_section["start_at_boot"]) + expect(result["start_in_chroot"]).to eq(ntp_client_section["start_in_chroot"]) + expect(result["ntp_policy"]).to eq(ntp_client_section["ntp_policy"]) + expect(result["peers"].size).to eq(ntp_client_section["peers"].size) + expect(result["restricts"].size).to eq(ntp_client_section["restricts"].size) end it "clones without encountering a CFA object" do From 32973927db5cf42de7064ec36f7a18c91f7ac799 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Iv=C3=A1n=20L=C3=B3pez=20Gonz=C3=A1lez?= Date: Mon, 19 Aug 2019 12:59:03 +0100 Subject: [PATCH 04/10] Do not modify values when saving --- src/lib/cfa/ntp_conf.rb | 2 +- test/cfa/ntp_conf_test.rb | 13 ------------- 2 files changed, 1 insertion(+), 14 deletions(-) diff --git a/src/lib/cfa/ntp_conf.rb b/src/lib/cfa/ntp_conf.rb index 95c889e1..80823107 100755 --- a/src/lib/cfa/ntp_conf.rb +++ b/src/lib/cfa/ntp_conf.rb @@ -98,7 +98,7 @@ def save matcher = Matcher.new(key: r.augeas[:key], value_matcher: r.augeas[:value]) placer = BeforePlacer.new(matcher) comments.each do |comment| - data.add("#comment[]", comment.strip, placer) + data.add("#comment[]", comment, placer) end end super diff --git a/test/cfa/ntp_conf_test.rb b/test/cfa/ntp_conf_test.rb index b9e89c09..2ab6b287 100644 --- a/test/cfa/ntp_conf_test.rb +++ b/test/cfa/ntp_conf_test.rb @@ -94,19 +94,6 @@ def ntp_conf(file) expect(file.content.lines).to include("#test comment 2\n") expect(file.content.lines).to include("#test comment3\n") end - - # see bsc #1142026 - it "can write multi lines comments with unstripped whitespaces from autoyast profiles" do - record = CFA::NtpConf::ServerRecord.new - record.value = "4.pool.ntp.org" - record.comment = " test comment 4 \n \n test comment 5 " - ntp.records << record - expect(record.comment).to eq " test comment 4 \n \n test comment 5 " - ntp.save - expect(file.content.lines).to include("#test comment 4\n") - expect(file.content.lines).to include("#test comment 5\n") - expect(file.content.lines).to include("server 4.pool.ntp.org\n") - end end context "when a record is deleted" do From d17b1532b6392855858b3776f2ae4fb59d6d9ae4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Iv=C3=A1n=20L=C3=B3pez=20Gonz=C3=A1lez?= Date: Mon, 19 Aug 2019 13:07:13 +0100 Subject: [PATCH 05/10] Updates version and changelog --- package/yast2-ntp-client.changes | 7 +++++++ package/yast2-ntp-client.spec | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/package/yast2-ntp-client.changes b/package/yast2-ntp-client.changes index 481b62d7..3dee0449 100644 --- a/package/yast2-ntp-client.changes +++ b/package/yast2-ntp-client.changes @@ -1,3 +1,10 @@ +------------------------------------------------------------------- +Mon Aug 19 12:04:19 UTC 2019 - José Iván López González + +- AutoYaST: improve importing when a comment contains empty lines. +- This also fixes bsc#1142026. +- 3.2.20 + ------------------------------------------------------------------- Fri Aug 02 15:16:17 CEST 2019 - aschnell@suse.com diff --git a/package/yast2-ntp-client.spec b/package/yast2-ntp-client.spec index d255390e..b83d0215 100644 --- a/package/yast2-ntp-client.spec +++ b/package/yast2-ntp-client.spec @@ -17,7 +17,7 @@ Name: yast2-ntp-client -Version: 3.2.19 +Version: 3.2.20 Release: 0 Summary: YaST2 - NTP Client Configuration License: GPL-2.0+ From 258cd0a13a1656b913d28f9e203482128c929c4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Iv=C3=A1n=20L=C3=B3pez=20Gonz=C3=A1lez?= Date: Mon, 19 Aug 2019 17:01:37 +0100 Subject: [PATCH 06/10] Revert "adapt Rakefile and Dockerfile for SLE-12-SP5" This reverts commit 35264e3a40ad483eea1a74281ce92b8145431fbf. --- Dockerfile | 3 +-- Rakefile | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 57087fbf..57e75e9b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,4 @@ -FROM yastdevel/ruby:sle12-sp5 - +FROM yastdevel/ruby:sle12-sp4 COPY . /usr/src/app diff --git a/Rakefile b/Rakefile index 6be65221..2cf05745 100644 --- a/Rakefile +++ b/Rakefile @@ -1,6 +1,6 @@ require "yast/rake" -Yast::Tasks.submit_to :sle12sp5 +Yast::Tasks.submit_to :sle12sp4 Yast::Tasks.configuration do |conf| # lets ignore license check for now From 1984c2e2ca8495cf3f4b3b52508b2d9dedbd6a2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Iv=C3=A1n=20L=C3=B3pez=20Gonz=C3=A1lez?= Date: Mon, 19 Aug 2019 17:02:33 +0100 Subject: [PATCH 07/10] Revert "Updates version and changelog" This reverts commit d17b1532b6392855858b3776f2ae4fb59d6d9ae4. --- package/yast2-ntp-client.changes | 7 ------- package/yast2-ntp-client.spec | 2 +- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/package/yast2-ntp-client.changes b/package/yast2-ntp-client.changes index 3dee0449..481b62d7 100644 --- a/package/yast2-ntp-client.changes +++ b/package/yast2-ntp-client.changes @@ -1,10 +1,3 @@ -------------------------------------------------------------------- -Mon Aug 19 12:04:19 UTC 2019 - José Iván López González - -- AutoYaST: improve importing when a comment contains empty lines. -- This also fixes bsc#1142026. -- 3.2.20 - ------------------------------------------------------------------- Fri Aug 02 15:16:17 CEST 2019 - aschnell@suse.com diff --git a/package/yast2-ntp-client.spec b/package/yast2-ntp-client.spec index b83d0215..d255390e 100644 --- a/package/yast2-ntp-client.spec +++ b/package/yast2-ntp-client.spec @@ -17,7 +17,7 @@ Name: yast2-ntp-client -Version: 3.2.20 +Version: 3.2.19 Release: 0 Summary: YaST2 - NTP Client Configuration License: GPL-2.0+ From fa0e047c69e17aa74c3a4c443b8f4ce0d549a7ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Iv=C3=A1n=20L=C3=B3pez=20Gonz=C3=A1lez?= Date: Mon, 19 Aug 2019 17:03:11 +0100 Subject: [PATCH 08/10] Revert "Do not modify values when saving" This reverts commit 32973927db5cf42de7064ec36f7a18c91f7ac799. --- src/lib/cfa/ntp_conf.rb | 2 +- test/cfa/ntp_conf_test.rb | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/lib/cfa/ntp_conf.rb b/src/lib/cfa/ntp_conf.rb index 80823107..95c889e1 100755 --- a/src/lib/cfa/ntp_conf.rb +++ b/src/lib/cfa/ntp_conf.rb @@ -98,7 +98,7 @@ def save matcher = Matcher.new(key: r.augeas[:key], value_matcher: r.augeas[:value]) placer = BeforePlacer.new(matcher) comments.each do |comment| - data.add("#comment[]", comment, placer) + data.add("#comment[]", comment.strip, placer) end end super diff --git a/test/cfa/ntp_conf_test.rb b/test/cfa/ntp_conf_test.rb index 2ab6b287..b9e89c09 100644 --- a/test/cfa/ntp_conf_test.rb +++ b/test/cfa/ntp_conf_test.rb @@ -94,6 +94,19 @@ def ntp_conf(file) expect(file.content.lines).to include("#test comment 2\n") expect(file.content.lines).to include("#test comment3\n") end + + # see bsc #1142026 + it "can write multi lines comments with unstripped whitespaces from autoyast profiles" do + record = CFA::NtpConf::ServerRecord.new + record.value = "4.pool.ntp.org" + record.comment = " test comment 4 \n \n test comment 5 " + ntp.records << record + expect(record.comment).to eq " test comment 4 \n \n test comment 5 " + ntp.save + expect(file.content.lines).to include("#test comment 4\n") + expect(file.content.lines).to include("#test comment 5\n") + expect(file.content.lines).to include("server 4.pool.ntp.org\n") + end end context "when a record is deleted" do From 4b2723a94b44f829c8b372ea3532bc58b2970b20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Iv=C3=A1n=20L=C3=B3pez=20Gonz=C3=A1lez?= Date: Mon, 19 Aug 2019 17:03:27 +0100 Subject: [PATCH 09/10] Revert "Remove blank lines when sanitizing comments" This reverts commit c3ae2e5f5f8e4629436f37bc3c0b3035a9c322d6. --- src/modules/NtpClient.rb | 61 +++++------------------------ test/fixtures/autoyast/autoinst.xml | 6 +-- test/ntp_client_test.rb | 17 +------- 3 files changed, 12 insertions(+), 72 deletions(-) diff --git a/src/modules/NtpClient.rb b/src/modules/NtpClient.rb index da90ef28..f0f0338f 100644 --- a/src/modules/NtpClient.rb +++ b/src/modules/NtpClient.rb @@ -1018,65 +1018,24 @@ def AutoPackages private - # Sanitizes values of a record (mainly, by removing blank spaces) + # Remove blank spaces in values # - # @param record [Hash] - # @return [Hash] + # @note to avoid augeas parsing errors, comments should be sanitized by + # removing blank spaces at the beginning and adding line break. Further + # sanitation is done in NtpConf.save. def sanitize_record(record) sanitized = record.dup - sanitized.each do |key, value| - sanitized[key] = sanitize_attribute(key, value) + if key.include?("comment") + value.sub!(/^ */, "") + value << "\n" unless value.include?("\n") + elsif value.respond_to?(:strip!) + value.strip! + end end - sanitized end - # Sanitizes the value of an attribute - # - # @note To avoid augeas parsing errors, each comment line should be sanitized by removing blank - # spaces at the beginning and ensuring a line break, see {#sanitize_comment}. - # - # @param attribute [String] - # @param value [String] - # - # @return [String] sanitized value - def sanitize_attribute(attribute, value) - if attribute.include?("comment") - sanitize_comment(value) - elsif value.respond_to?(:strip) - value.strip - else - value - end - end - - # Sanitizes each line from a comment - # - # @param comment [String] - # @return [String] sanitized comment - def sanitize_comment(comment) - lines = comment.split("\n") - - sanitized_lines = lines.map { |l| sanitize_comment_line(l) } - - sanitized_lines.compact.join - end - - # Sanitizes a comment line by removing blank spaces at the beginning and ensuring a line break - # - # @param line [String] - # @return [String, nil] sanitized line. It returns nil if the line only contains blank spaces. - def sanitize_comment_line(line) - sanitized_line = line.lstrip - - return nil if sanitized_line.empty? - - sanitized_line << "\n" unless sanitized_line.include?("\n") - - sanitized_line - end - # Set @ntp_policy according to NETCONFIG_NTP_POLICY value found in # /etc/sysconfig/network/config or with "auto" if not found # diff --git a/test/fixtures/autoyast/autoinst.xml b/test/fixtures/autoyast/autoinst.xml index ffba45f2..e0246fa5 100644 --- a/test/fixtures/autoyast/autoinst.xml +++ b/test/fixtures/autoyast/autoinst.xml @@ -13,11 +13,7 @@
1.opensuse.pool.ntp.org
- # a comment with spaces - - # and blank lines - - + iburst server
diff --git a/test/ntp_client_test.rb b/test/ntp_client_test.rb index fdca87d9..e594ae10 100644 --- a/test/ntp_client_test.rb +++ b/test/ntp_client_test.rb @@ -61,12 +61,6 @@ expect(record["comment"]).to eq "# a comment with spaces \n" end - # see bsc #1142026 - it "sanitizes comments by removing blank lines" do - record = subject.ntp_records[1] - expect(record["comment"]).to eq "# a comment with spaces\n# and blank lines\n" - end - it "reads the list of peers" do expect(subject.ntp_records.size).to eq 5 end @@ -153,16 +147,7 @@ it "produces an output equivalent to #Import" do subject.Import(ntp_client_section) - - result = subject.Export - - expect(result["synchronize_time"]).to eq(ntp_client_section["synchronize_time"]) - expect(result["sync_interval"]).to eq(ntp_client_section["sync_interval"]) - expect(result["start_at_boot"]).to eq(ntp_client_section["start_at_boot"]) - expect(result["start_in_chroot"]).to eq(ntp_client_section["start_in_chroot"]) - expect(result["ntp_policy"]).to eq(ntp_client_section["ntp_policy"]) - expect(result["peers"].size).to eq(ntp_client_section["peers"].size) - expect(result["restricts"].size).to eq(ntp_client_section["restricts"].size) + expect(subject.Export()).to eq ntp_client_section end it "clones without encountering a CFA object" do From 582acc151b2c360f11985932276868f398146ad7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Iv=C3=A1n=20L=C3=B3pez=20Gonz=C3=A1lez?= Date: Mon, 19 Aug 2019 17:04:40 +0100 Subject: [PATCH 10/10] Revert "Fixed saving /etc/ntp.conf with certain comments (bsc#1142026)" This reverts commit 17af584b43f423a2b31c45030e69e8e3d09a15e3. --- package/yast2-ntp-client.changes | 6 ------ package/yast2-ntp-client.spec | 2 +- src/lib/cfa/ntp_conf.rb | 4 ++-- src/modules/NtpClient.rb | 3 +-- test/cfa/ntp_conf_test.rb | 13 ------------- 5 files changed, 4 insertions(+), 24 deletions(-) diff --git a/package/yast2-ntp-client.changes b/package/yast2-ntp-client.changes index 481b62d7..224b6e6a 100644 --- a/package/yast2-ntp-client.changes +++ b/package/yast2-ntp-client.changes @@ -1,9 +1,3 @@ -------------------------------------------------------------------- -Fri Aug 02 15:16:17 CEST 2019 - aschnell@suse.com - -- Fixed saving /etc/ntp.conf with certain comments (bsc#1142026) -- 3.2.19 - ------------------------------------------------------------------- Thu Dec 13 12:45:27 UTC 2018 - knut.anderssen@suse.com diff --git a/package/yast2-ntp-client.spec b/package/yast2-ntp-client.spec index d255390e..9d324bfe 100644 --- a/package/yast2-ntp-client.spec +++ b/package/yast2-ntp-client.spec @@ -17,7 +17,7 @@ Name: yast2-ntp-client -Version: 3.2.19 +Version: 3.2.18 Release: 0 Summary: YaST2 - NTP Client Configuration License: GPL-2.0+ diff --git a/src/lib/cfa/ntp_conf.rb b/src/lib/cfa/ntp_conf.rb index 95c889e1..57970936 100755 --- a/src/lib/cfa/ntp_conf.rb +++ b/src/lib/cfa/ntp_conf.rb @@ -97,8 +97,8 @@ def save comments = r.augeas[:multiline].split("\n") matcher = Matcher.new(key: r.augeas[:key], value_matcher: r.augeas[:value]) placer = BeforePlacer.new(matcher) - comments.each do |comment| - data.add("#comment[]", comment.strip, placer) + comments.each do |c| + data.add("#comment[]", c, placer) end end super diff --git a/src/modules/NtpClient.rb b/src/modules/NtpClient.rb index f0f0338f..3a5daac4 100644 --- a/src/modules/NtpClient.rb +++ b/src/modules/NtpClient.rb @@ -1021,8 +1021,7 @@ def AutoPackages # Remove blank spaces in values # # @note to avoid augeas parsing errors, comments should be sanitized by - # removing blank spaces at the beginning and adding line break. Further - # sanitation is done in NtpConf.save. + # removing blank spaces at the beginning and adding line break. def sanitize_record(record) sanitized = record.dup sanitized.each do |key, value| diff --git a/test/cfa/ntp_conf_test.rb b/test/cfa/ntp_conf_test.rb index b9e89c09..2ab6b287 100644 --- a/test/cfa/ntp_conf_test.rb +++ b/test/cfa/ntp_conf_test.rb @@ -94,19 +94,6 @@ def ntp_conf(file) expect(file.content.lines).to include("#test comment 2\n") expect(file.content.lines).to include("#test comment3\n") end - - # see bsc #1142026 - it "can write multi lines comments with unstripped whitespaces from autoyast profiles" do - record = CFA::NtpConf::ServerRecord.new - record.value = "4.pool.ntp.org" - record.comment = " test comment 4 \n \n test comment 5 " - ntp.records << record - expect(record.comment).to eq " test comment 4 \n \n test comment 5 " - ntp.save - expect(file.content.lines).to include("#test comment 4\n") - expect(file.content.lines).to include("#test comment 5\n") - expect(file.content.lines).to include("server 4.pool.ntp.org\n") - end end context "when a record is deleted" do