diff --git a/doc/examples/ask_resize_windows_partition.rb b/doc/examples/ask_resize_windows_partition.rb index 9e86a53c8..bc809cd6c 100644 --- a/doc/examples/ask_resize_windows_partition.rb +++ b/doc/examples/ask_resize_windows_partition.rb @@ -24,8 +24,8 @@ # Example when to use a headline: # # There is lengthy text that advanced users might have read several times -# before, so we give him a concise headline that identifies that dialog so he -# can keep on working without having to read everything again. +# before, so we give the users a concise headline that identifies that dialogue +# so they can keep on working without having to read everything again. module Yast class AskResizeWindowsPartitionClient < Client def main diff --git a/doc/examples/popups2.rb b/doc/examples/popups2.rb index 961ae91ce..2a1a103cd 100644 --- a/doc/examples/popups2.rb +++ b/doc/examples/popups2.rb @@ -58,7 +58,7 @@ def main "Really delete world?", "You in your infinite wisdom have chosen to delete this only world of ours.\n" \ "This will mean the end to all of mankind and all life in the only known planet\n" \ - "known to habitate intelligent or other life in the entire universe.\n" \ + "known to be inhabited by intelligent or other life in the entire universe.\n" \ "\n" \ "Even though it is well known that mankind and human character are far from perfect,\n" \ "we urgently request you to reconsider that decision.\n" \ @@ -72,17 +72,17 @@ def main "\n" \ "\n" \ "\n" \ - "If make the wrong decision, creatures from outer space may decide\n" \ + "If you make the wrong decision, creatures from outer space may choose\n" \ "\n" \ - "to get rid of that planet of ours to make room for some interstellar\n" \ + "to get rid of this planet of ours to make room for some interstellar\n" \ "\n" \ "hyper expressway.\n" \ "\n" \ "\n" \ "\n" \ - "So: Do you fail to be aware to recognize the lack of not being able\n" \ - "\n" \ - "to face this kind of indecision may kill all of mankind?", + "So: Do you fail to recognize that your inability to confront\n" \ + "\n" \ + "this kind of indecision may destroy all of mankind?", "&Everything you say", "I'll &buy one of it", :focus_no @@ -94,17 +94,17 @@ def main "\n" \ "\n" \ "\n" \ - "If make the wrong decision, creatures from outer space may decide\n" \ + "If you make the wrong decision, creatures from outer space may choose\n" \ "\n" \ - "to get rid of that planet of ours to make room for some interstellar\n" \ + "to get rid of this planet of ours to make room for some interstellar\n" \ "\n" \ "hyper expressway.\n" \ "\n" \ "\n" \ "\n" \ - "So: Do you fail to be aware to recognize the lack of not being able\n" \ - "\n" \ - "to face this kind of indecision may kill all of mankind?", + "So: Do you fail to recognize that your inability to confront\n" \ + "\n" \ + "this kind of indecision may destroy all of mankind?", "&Everything you say", "I'll &buy one of it", "But I don't have a &car", diff --git a/library/network/src/lib/network/susefirewall2.rb b/library/network/src/lib/network/susefirewall2.rb index a1d5a7696..e39aac428 100644 --- a/library/network/src/lib/network/susefirewall2.rb +++ b/library/network/src/lib/network/susefirewall2.rb @@ -278,12 +278,12 @@ def ReportOnlyOnce(what_to_report) # Function returns whether the feature 'any' network interface is supported in the # firewall configuration. The string 'any' must be in the 'EXT' zone. - # Updated: Currently returns only 'true' as every unasigned interface is + # Updated: Currently returns only 'true' as every unassigned interface is # automatically assigned to the EXT zone by SuSEfirewall2. # # @return [Boolean] is_supported whether the feature is supported or not def IsAnyNetworkInterfaceSupported - # Currently unasigned interfaces belong to the EXT zone by dafault + # Currently unassigned interfaces belong to the EXT zone by dafault true end @@ -360,7 +360,7 @@ def ReadSysconfigSuSEFirewall(variables) nil end - # Local function for reseting list of sysconfig variables in internal variables. + # Local function for resetting list of sysconfig variables in internal variables. # # @param [Array] variables of sysconfig variables def ResetSysconfigSuSEFirewall(variables) @@ -492,7 +492,7 @@ def SetBroadcastConfiguration(zone, broadcast_configuration) nil end - # Local function return map of allowed ports (without aliases). + # Local function returns map of allowed ports (without aliases). # If any list for zone is defined but empty, all allowed # UDP ports for this zone also accept broadcast packets. # This function returns only ports that are mentioned in configuration, @@ -526,7 +526,7 @@ def GetBroadcastAllowedPorts # BNC #694782: "yes" is automatically translated by SuSEfirewall2 elsif broadcast == "yes" Ops.set(allowed_ports, zone, ["yes"]) - # only listed ports allows broadcast + # only listed ports allow broadcast else Ops.set(allowed_ports, zone, Builtins.splitstring(broadcast, " ")) Ops.set( @@ -1761,7 +1761,7 @@ def WriteConfiguration true end - # Helper function for the backward compatibility. + # Helper function for backward compatibility. # See WriteConfiguration(). Remove from code ASAP. # # @return [Boolean] if succesful @@ -1769,7 +1769,7 @@ def WriteOnly WriteConfiguration() end - # Function for writing and enabling configuration it is an union of + # Function for writing and enabling configuration, it is a union of # WriteConfiguration() and ActivateConfiguration(). # # @return [Boolean] if succesfull @@ -1789,7 +1789,7 @@ def Write # This powerful function returns list of services/ports which are # not assigned to any fully-supported known-services. # This function doesn't check for services defined by packages. - # They are listed by a different way. + # They are listed by a different method. # # @return [Array] of additional (unassigned) services # @@ -1939,7 +1939,7 @@ def RemoveSpecialInterfaceFromZone(interface, zone) nil end - # Functions adds special string into defined zone. + # Function adds special string into defined zone. # # @param [String] interface # @param [String] zone @@ -1985,7 +1985,7 @@ def SetMasquerade(enable, _zone = nil) Ops.set(@SETTINGS, "FW_MASQUERADE", enable ? "yes" : "no") - # routing is needed for masquerading, but we can't swithc it off when disabling masquerading + # routing is needed for masquerading, but we can't switch it off when disabling masquerading Ops.set(@SETTINGS, "FW_ROUTE", "yes") if enable nil @@ -2223,7 +2223,7 @@ def SetLoggingSettings(rule, state) nil end - # Function returns yes/no - ingoring broadcast for zone + # Function returns yes/no - ignoring broadcast for zone # # @param [String] zone # @return [String] "yes" or "no" @@ -2240,7 +2240,7 @@ def GetIgnoreLoggingBroadcast(zone) Ops.get_string(@SETTINGS, Ops.add("FW_IGNORE_FW_BROADCAST_", zone), "no") end - # Function sets yes/no - ingoring broadcast for zone + # Function sets yes/no - ignoring broadcast for zone # # @param [String] zone # @param [String] bcast ignore 'yes' or 'no' @@ -2261,7 +2261,7 @@ def SetIgnoreLoggingBroadcast(zone, bcast) nil end - # Firewall Expert Rulezz + # Firewall Expert Rules # Returns list of rules describing protocols and ports that are allowed # to be accessed from listed hosts. All is returned as a single string. diff --git a/library/systemd/src/lib/yast2/system_service.rb b/library/systemd/src/lib/yast2/system_service.rb index b7ff3513a..8ff97eddc 100644 --- a/library/systemd/src/lib/yast2/system_service.rb +++ b/library/systemd/src/lib/yast2/system_service.rb @@ -173,6 +173,13 @@ def initialize(service) @errors = {} end + # Determines whether the service exists in the underlying system + # + # @return [Boolean] true if it exists; false otherwise. + def found? + !service.not_found? + end + # State of the service # # In case the service is not active but socket is, the socket state is considered @@ -228,8 +235,13 @@ def currently_active? # * :on_demand: The service will be started on demand. # * :manual: The service is disabled and it will be started manually. # + # @note When the service does not exist in the underlying system (for instance, + # during 1st stage) all possible start modes are returned, as there is no way + # to find out which of them are supported. + # # @return [Array] List of supported modes. def start_modes + @start_modes = [:on_boot, :manual, :on_demand] unless found? return @start_modes if @start_modes @start_modes = [:on_boot, :manual] @start_modes << :on_demand if socket @@ -425,7 +437,7 @@ def save_start_mode when :on_boot service.enable && (socket ? socket.disable : true) when :on_demand - service.disable && (socket ? socket.enable : true) + service.disable && (socket ? socket.enable : false) when :manual service.disable && (socket ? socket.disable : true) end diff --git a/library/systemd/src/lib/yast2/systemd_unit.rb b/library/systemd/src/lib/yast2/systemd_unit.rb index c358b0d2f..d47a57cde 100644 --- a/library/systemd/src/lib/yast2/systemd_unit.rb +++ b/library/systemd/src/lib/yast2/systemd_unit.rb @@ -81,7 +81,8 @@ class PropMap < Hash :loaded?, :active_state, :sub_state, - :can_reload? + :can_reload?, + :not_found? ].freeze private_constant :FORWARDED_METHODS diff --git a/library/systemd/src/modules/systemd_service.rb b/library/systemd/src/modules/systemd_service.rb index 0971ead3e..89508afc7 100644 --- a/library/systemd/src/modules/systemd_service.rb +++ b/library/systemd/src/modules/systemd_service.rb @@ -190,19 +190,13 @@ def restart # Returns socket associated with service or nil if there is no such socket # - # @return [Yast::SystemdSocketClass::Socket] + # @note The current implementation is too simplistic. At this point, checking the + # 'Triggers' property of each socket would be a better way. However, it won't work + # during installation as 'systemctl show' is not available. + # + # @return [Yast::SystemdSocketClass::Socket,nil] def socket - return @socket if @socket - - # not triggered - socket_name = properties.triggered_by - return unless socket_name - - # this may be a space separated list - socket_name = socket_name[/\S+\.socket/] - return unless socket_name # triggered by non-socket - - @socket = Yast::SystemdSocket.find(socket_name) + @socket ||= Yast::SystemdSocket.find(name) end # Determines whether the service has an associated socket diff --git a/library/systemd/test/systemd_service_test.rb b/library/systemd/test/systemd_service_test.rb index 405cad466..0001f3532 100755 --- a/library/systemd/test/systemd_service_test.rb +++ b/library/systemd/test/systemd_service_test.rb @@ -179,20 +179,22 @@ module Yast describe "#socket" do subject(:service) { SystemdService.find(service_name) } + let(:service_name) { "sshd" } - before { stub_services(service: service_name) } + before do + allow(SystemdSocket).to receive(:find).with(service_name).and_return(socket) + end - context "when the service is triggered by a socket" do - let(:service_name) { "cups" } + context "when a socket named after the service exists" do + let(:socket) { instance_double(SystemdSocketClass::Socket) } it "returns the socket" do - expect(service.socket).to be_a(Yast::SystemdSocketClass::Socket) - expect(service.socket.unit_name).to eq("iscsid") + expect(service.socket).to eq(socket) end end - context "when the service is not triggered by a socket" do - let(:service_name) { "sshd" } + context "when no socket named after the service exists" do + let(:socket) { nil } it "returns nil" do expect(service.socket).to be_nil @@ -201,12 +203,14 @@ module Yast end describe "#socket?" do - subject(:service) { SystemdService.find(service_name) } + subject(:service) { SystemdService.find("sshd") } - before { stub_services(service: service_name) } + before do + allow(service).to receive(:socket).and_return(socket) + end context "when there is an associated socket" do - let(:service_name) { "cups" } + let(:socket) { instance_double(SystemdSocketClass::Socket) } it "returns true" do expect(service.socket?).to eq(true) @@ -214,7 +218,7 @@ module Yast end context "when there is no associated socket" do - let(:service_name) { "sshd" } + let(:socket) { nil } it "returns false" do expect(service.socket?).to eq(false) diff --git a/library/systemd/test/yast2/system_service_test.rb b/library/systemd/test/yast2/system_service_test.rb index 424005b01..88ad398c0 100755 --- a/library/systemd/test/yast2/system_service_test.rb +++ b/library/systemd/test/yast2/system_service_test.rb @@ -28,14 +28,16 @@ let(:service) do instance_double(Yast::SystemdServiceClass::Service, - name: "cups", - enabled?: service_enabled, - active?: service_active, - refresh!: true) + name: "cups", + enabled?: service_enabled, + active?: service_active, + not_found?: !service_found, + refresh!: true) end let(:service_enabled) { true } let(:service_active) { true } + let(:service_found) { true } let(:service_socket) do instance_double(Yast::SystemdSocketClass::Socket, @@ -311,6 +313,15 @@ expect(system_service.start_modes).to contain_exactly(:on_boot, :manual) end end + + context "when the service is not found" do + let(:socket) { nil } + let(:service_found) { false } + + it "returns all available start modes" do + expect(system_service.start_modes).to contain_exactly(:on_boot, :manual, :on_demand) + end + end end describe "#start_mode" do @@ -609,6 +620,17 @@ system_service.save end + + context "but there is not associated socket (possible during 1st stage)" do + before do + allow(system_service).to receive(:socket).and_return(nil) + end + + it "registers an error" do + system_service.save + expect(system_service.errors).to include(start_mode: :on_demand) + end + end end context "and the new start mode is :manual" do @@ -1093,4 +1115,22 @@ end end end + + describe "#found?" do + context "when the service is found" do + let(:service_found) { true } + + it "returns true" do + expect(system_service.found?).to eq(true) + end + end + + context "when the service is not found" do + let(:service_found) { false } + + it "returns false" do + expect(system_service.found?).to eq(false) + end + end + end end diff --git a/package/yast2.changes b/package/yast2.changes index 0fd6cdd9f..82390928d 100644 --- a/package/yast2.changes +++ b/package/yast2.changes @@ -1,3 +1,11 @@ +------------------------------------------------------------------- +Wed Aug 8 10:09:55 UTC 2018 - igonzalezsosa@suse.com + +- Add a method to detect whether a systemd service exists in + the underlying system or not (related to fate#319428). +- Fix systemd socket detection. +- 4.0.83 + ------------------------------------------------------------------- Wed Aug 1 10:48:04 UTC 2018 - igonzalezsosa@suse.com @@ -19,12 +27,6 @@ Wed Jul 25 08:13:31 UTC 2018 - jlopez@suse.com socket (needed for bsc#1080738 and fate#319428). - 4.0.80 -------------------------------------------------------------------- -Mon Jul 16 09:12:23 UTC 2018 - knut.anderssen@suse.com - -- Replace the deprecated firewallctl command with firewall-cmd for - obtaining the firewalld state (bsc#1093111) - ------------------------------------------------------------------- Tue Jul 3 08:01:07 UTC 2018 - knut.anderssen@suse.com @@ -57,6 +59,12 @@ Wed May 23 15:25:04 CEST 2018 - schubi@suse.de pre Snapper image has already been failed (bnc#1093374) - 4.0.75 +------------------------------------------------------------------- +Tue May 15 09:12:23 UTC 2018 - knut.anderssen@suse.com + +- Replace the deprecated firewallctl command with firewall-cmd for + obtaining the firewalld state (bsc#1093111) + ------------------------------------------------------------------- Mon May 14 09:00:43 UTC 2018 - lslezak@suse.cz diff --git a/package/yast2.spec b/package/yast2.spec index 48c59940e..8114fd1c6 100644 --- a/package/yast2.spec +++ b/package/yast2.spec @@ -17,7 +17,7 @@ Name: yast2 -Version: 4.0.82 +Version: 4.0.83 Release: 0 Summary: YaST2 - Main Package License: GPL-2.0-only