Skip to content

Commit

Permalink
[Review] Request from 'schubi2' @ 'yast/yast-yast2/review_170928_disa…
Browse files Browse the repository at this point in the history
…ble_remote_installation' (#628)

* disable vnc, shh,... installation if it is not supported
  • Loading branch information
schubi2 committed Oct 6, 2017
1 parent b46be37 commit ffd155a
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 1 deletion.
29 changes: 29 additions & 0 deletions library/general/src/modules/Linuxrc.rb
Expand Up @@ -31,6 +31,8 @@

module Yast
class LinuxrcClass < Module
include Yast::Logger

# Disables filesystem snapshots (fate#317973)
# Possible values: all, post, pre, single
DISABLE_SNAPSHOTS = "disable_snapshots".freeze
Expand Down Expand Up @@ -239,6 +241,32 @@ def value_for(feature_key)
ret
end

# Reset settings for vnc, ssh,... in install.inf which have been made
# by linuxrc settings.
#
# @param [Array<String>] list of services which will be disabled.
def disable_remote(services)
return if !services || services.empty?
log.warn "Disabling #{services} due missing packages."
services.each do |service|
case service
when "vnc"
SCR.Write(path(".etc.install_inf.VNC"), 0)
SCR.Write(path(".etc.install_inf.VNCPassword"), "")
when "ssh"
SCR.Write(path(".etc.install_inf.UseSSH"), 0)
when "braille"
SCR.Write(path(".etc.install_inf.Braille"), 0)
when "display-ip"
SCR.Write(path(".etc.install_inf.DISPLAY_IP"), 0)
else
log.error "#{service} not supported"
end
end
SCR.Write(path(".etc.install_inf"), nil) # Flush the cache
ResetInstallInf()
end

publish function: :ResetInstallInf, type: "void ()"
publish function: :InstallInf, type: "string (string)"
publish function: :manual, type: "boolean ()"
Expand All @@ -253,6 +281,7 @@ def value_for(feature_key)
publish function: :SaveInstallInf, type: "boolean (string)"
publish function: :keys, type: "list <string> ()"
publish function: :value_for, type: "string (string)"
publish function: :disable_remote, type: "list <string> ()"

private

Expand Down
35 changes: 35 additions & 0 deletions library/general/test/linuxrc_test.rb
Expand Up @@ -230,4 +230,39 @@ def load_install_inf(defaults_replacement = {})
end
end
end

describe "#disable_remote" do
before(:each) do
allow(Yast::SCR).to receive(:Write)
.with(path(".etc.install_inf"), nil)
end

context "when vnc will be disabled" do
it "updates install.inf" do
expect(Yast::SCR).to receive(:Write)
.with(path(".etc.install_inf.VNC"), 0)
expect(Yast::SCR).to receive(:Write)
.with(path(".etc.install_inf.VNCPassword"), "")
subject.disable_remote(["vnc"])
end
end

context "when ssh will be disabled" do
it "updates install.inf" do
expect(Yast::SCR).to receive(:Write)
.with(path(".etc.install_inf.UseSSH"), 0)
subject.disable_remote(["ssh"])
end
end

context "when braille and dispaly_ip will be disabled" do
it "updates install.inf" do
expect(Yast::SCR).to receive(:Write)
.with(path(".etc.install_inf.Braille"), 0)
expect(Yast::SCR).to receive(:Write)
.with(path(".etc.install_inf.DISPLAY_IP"), 0)
subject.disable_remote(["braille", "display-ip"])
end
end
end
end
7 changes: 7 additions & 0 deletions package/yast2.changes
@@ -1,3 +1,10 @@
-------------------------------------------------------------------
Thu Oct 5 14:04:46 UTC 2017 - schubi@suse.de

- Disable vnc, ssh,... installation in install.inf if it is not
supported. (bnc#1055279, bnc#1058071)
- 4.0.10

-------------------------------------------------------------------
Thu Oct 5 13:04:46 UTC 2017 - mvidner@suse.com

Expand Down
2 changes: 1 addition & 1 deletion package/yast2.spec
Expand Up @@ -17,7 +17,7 @@


Name: yast2
Version: 4.0.9
Version: 4.0.10
Release: 0
Summary: YaST2 - Main Package
License: GPL-2.0
Expand Down

0 comments on commit ffd155a

Please sign in to comment.