commit yast2-ntp-client for openSUSE:Factory
Hello community, here is the log from the commit of package yast2-ntp-client for openSUSE:Factory checked in at 2017-07-02 13:32:45 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/yast2-ntp-client (Old) and /work/SRC/openSUSE:Factory/.yast2-ntp-client.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Package is "yast2-ntp-client" Sun Jul 2 13:32:45 2017 rev:95 rq:507026 version:3.3.0 Changes: -------- --- /work/SRC/openSUSE:Factory/yast2-ntp-client/yast2-ntp-client.changes 2017-06-07 13:09:02.410318193 +0200 +++ /work/SRC/openSUSE:Factory/.yast2-ntp-client.new/yast2-ntp-client.changes 2017-07-02 13:32:46.708747391 +0200 @@ -1,0 +2,7 @@ +Mon Jun 26 17:23:52 UTC 2017 - jlopez@suse.com + +- AutoYaST: Fixed crash in CFA when creating restrict record from + scratch (bsc#1045777) +- 3.3.0 + +------------------------------------------------------------------- Old: ---- yast2-ntp-client-3.2.8.tar.bz2 New: ---- yast2-ntp-client-3.3.0.tar.bz2 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ yast2-ntp-client.spec ++++++ --- /var/tmp/diff_new_pack.FfV1yJ/_old 2017-07-02 13:32:47.288665618 +0200 +++ /var/tmp/diff_new_pack.FfV1yJ/_new 2017-07-02 13:32:47.292665054 +0200 @@ -17,7 +17,7 @@ Name: yast2-ntp-client -Version: 3.2.8 +Version: 3.3.0 Release: 0 Summary: YaST2 - NTP Client Configuration License: GPL-2.0+ ++++++ yast2-ntp-client-3.2.8.tar.bz2 -> yast2-ntp-client-3.3.0.tar.bz2 ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-ntp-client-3.2.8/package/yast2-ntp-client.changes new/yast2-ntp-client-3.3.0/package/yast2-ntp-client.changes --- old/yast2-ntp-client-3.2.8/package/yast2-ntp-client.changes 2017-06-06 11:09:07.669780499 +0200 +++ new/yast2-ntp-client-3.3.0/package/yast2-ntp-client.changes 2017-06-29 12:41:52.639939132 +0200 @@ -1,4 +1,11 @@ ------------------------------------------------------------------- +Mon Jun 26 17:23:52 UTC 2017 - jlopez@suse.com + +- AutoYaST: Fixed crash in CFA when creating restrict record from + scratch (bsc#1045777) +- 3.3.0 + +------------------------------------------------------------------- Fri Jun 2 16:37:27 CEST 2017 - schubi@suse.de - AutoYaST: Fixed crash in CFA class while writing settings to diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-ntp-client-3.2.8/package/yast2-ntp-client.spec new/yast2-ntp-client-3.3.0/package/yast2-ntp-client.spec --- old/yast2-ntp-client-3.2.8/package/yast2-ntp-client.spec 2017-06-06 11:09:07.669780499 +0200 +++ new/yast2-ntp-client-3.3.0/package/yast2-ntp-client.spec 2017-06-29 12:41:52.639939132 +0200 @@ -17,7 +17,7 @@ Name: yast2-ntp-client -Version: 3.2.8 +Version: 3.3.0 Release: 0 Summary: YaST2 - NTP Client Configuration License: GPL-2.0+ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-ntp-client-3.2.8/src/lib/cfa/ntp_conf.rb new/yast2-ntp-client-3.3.0/src/lib/cfa/ntp_conf.rb --- old/yast2-ntp-client-3.2.8/src/lib/cfa/ntp_conf.rb 2017-06-06 11:09:07.681780499 +0200 +++ new/yast2-ntp-client-3.3.0/src/lib/cfa/ntp_conf.rb 2017-06-29 12:41:52.643939132 +0200 @@ -488,30 +488,46 @@ # For example: # restrict -4 default notrap nomodify nopeer noquery # + # FIXME: right now there is no way to create an ipv4 restrict + # record from scratch using old lens. The reason is that it + # is not possible to detect an old_lens? case for a new record. + # # Restrict entry has its own options interpretation. class RestrictRecord < Record AUGEAS_KEY = "restrict[]".freeze def options return [] unless tree_value? - res = augeas_options.map { |option| option[:value] } - res.shift if old_lens? + res = augeas_options.map { |augeas_option| option(augeas_option) } + + if old_lens? + res.shift + res.unshift("ipv4") if orig_value == "-4" + end res end + # Set restrict options + # @param options [Array<String>] It can contain values as "ipv4", "ipv6", + # "notrap", "nomodify", "nopeer", "noquery". + # + # @note ip version is an option: "ipv4" or "ipv6" def options=(options) + ensure_tree_value + # backward compatibility with old lens that set value ip restriction # instead of address if old_lens? options = options.dup + self.orig_value = "-4" if options.include?("ipv4") + options.delete("ipv4") address = augeas_options.map { |option| option[:value] }.first options.unshift(address) if address end - ensure_tree_value tree_value.tree.delete(options_matcher) - options.each { |option| tree_value.tree.add("action[]", option) } + options.each { |option| add_option(option) } end alias_method :orig_value, :value @@ -519,6 +535,7 @@ old_lens? ? augeas_options.map { |option| option[:value] }.first : orig_value end + alias_method :orig_value=, :value= def value=(value) if old_lens? holder = tree_value.tree.select(options_matcher).first @@ -531,8 +548,25 @@ private + def add_option(option) + if ["ipv4", "ipv6"].include?(option) + key = option + value = nil + else + key = "action[]" + value = option + end + tree_value.tree.add(key, value) + end + + def option(augeas_option) + key = augeas_option[:key] + return key if ["ipv4", "ipv6"].include?(key) + augeas_option[:value] + end + def options_matcher - Matcher.new { |k, _v| k.include?("action") } + Matcher.new { |k, _v| !k.match(/action|ipv4|ipv6/).nil? } end # backward compatibility with old lens that set value ip restriction diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-ntp-client-3.2.8/src/modules/NtpClient.rb new/yast2-ntp-client-3.3.0/src/modules/NtpClient.rb --- old/yast2-ntp-client-3.2.8/src/modules/NtpClient.rb 2017-06-06 11:09:07.681780499 +0200 +++ new/yast2-ntp-client-3.3.0/src/modules/NtpClient.rb 2017-06-29 12:41:52.647939132 +0200 @@ -676,13 +676,17 @@ end next deep_copy(p) end + + # sanitize records + @ntp_records = @ntp_records.map { |r| sanitize_record(r) } + # restricts is a list of entries whereas restrict_map # is a map with target key (ip, ipv4-tag, ipv6-tag,...). restricts = settings["restricts"] || [] @restrict_map = {} restricts.each do |entry| - target = entry.delete("target") - @restrict_map[target] = entry + target = entry.delete("target").strip + @restrict_map[target] = sanitize_record(entry) end @modified = true true @@ -983,6 +987,13 @@ private + # Remove blank spaces in values + def sanitize_record(record) + sanitized = record.dup + sanitized.each_value(&:strip!) + sanitized + end + # Set @ntp_policy according to NETCONFIG_NTP_POLICY value found in # /etc/sysconfig/network/config or with "auto" if not found # @@ -1227,14 +1238,23 @@ # Returns current restrict map as a list of ntp records def restrict_map_records @restrict_map.map do |key, m| - options = " " - options << "mask #{m["mask"]} " if !m["mask"].to_s.empty? - options << m["options"].to_s + address = key + options = m["options"].to_s.split + + if ["-4", "-6"].include?(key) + address = options.first + options.shift + options.unshift("ipv4") if key == "-4" + options.unshift("ipv6") if key == "-6" + end + + options << "mask #{m["mask"]}" if !m["mask"].to_s.empty? + { "type" => "restrict", - "address" => key, + "address" => address, "comment" => m["comment"].to_s, - "options" => options, + "options" => options.join(" "), "cfa_record" => m["cfa_record"] } end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-ntp-client-3.2.8/test/cfa/ntp_conf_test.rb new/yast2-ntp-client-3.3.0/test/cfa/ntp_conf_test.rb --- old/yast2-ntp-client-3.2.8/test/cfa/ntp_conf_test.rb 2017-06-06 11:09:07.681780499 +0200 +++ new/yast2-ntp-client-3.3.0/test/cfa/ntp_conf_test.rb 2017-06-29 12:41:52.647939132 +0200 @@ -390,13 +390,13 @@ describe "#options" do it "obtains the options of the record" do - expect(record.options).to eq(%w(notrap nomodify nopeer)) + expect(record.options).to eq(%w(ipv4 notrap nomodify nopeer)) end end context "#options=" do it "sets options to the record" do - options = ["notrap"] + options = ["ipv4", "notrap"] record.options = options expect(record.options).to eq(options) ntp.save @@ -406,18 +406,29 @@ describe "#raw_options" do it "obtains options as string" do - expect(record.raw_options).to eq("notrap nomodify nopeer") + expect(record.raw_options).to eq("ipv4 notrap nomodify nopeer") end end describe "#raw_options=" do it "sets options from a string" do - record.raw_options = "notrap" - expect(record.options).to eq(["notrap"]) + record.raw_options = "ipv4 notrap" + expect(record.options).to eq(["ipv4", "notrap"]) ntp.save expect(file.content).to include("restrict -4 default notrap\n") end end + + context "when creating a new record from scratch" do + it "sets values correctly" do + record = CFA::NtpConf::RestrictRecord.new + record.value = "default" + record.options = ["ipv6", "notrap"] + ntp.records << record + ntp.save + expect(file.content).to include("restrict -6 default notrap\n") + end + end end describe CFA::NtpConf::TrustedkeyRecord do
participants (1)
-
root@hilbert.suse.de