Skip to content

Commit

Permalink
Translate <enable_sysrq> to <kernel.sysrq> with the correct value (#76)
Browse files Browse the repository at this point in the history
* Translate <enable_sysrq> to <kernel.sysrq> with the correct value (#75)
  • Loading branch information
schubi2 committed Oct 28, 2020
1 parent 8584f2f commit 30e2725
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ Metrics/BlockNesting:
# Offense count: 1
# Configuration parameters: CountComments.
Metrics/ClassLength:
Max: 634
Max: 650

# Offense count: 19
Metrics/CyclomaticComplexity:
Expand Down
7 changes: 7 additions & 0 deletions package/yast2-security.changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
-------------------------------------------------------------------
Tue Oct 27 13:26:57 CET 2020 - schubi@suse.de

- AY-Import: Translate <enable_sysrq> setting to <kernel.sysrq>
with the correct value format (bsc#1177720).
- 4.3.4

-------------------------------------------------------------------
Thu Aug 13 10:00:58 UTC 2020 - Ladislav Slezák <lslezak@suse.cz>

Expand Down
2 changes: 1 addition & 1 deletion package/yast2-security.spec
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@


Name: yast2-security
Version: 4.3.3
Version: 4.3.4
Release: 0
Group: System/YaST
License: GPL-2.0-only
Expand Down
14 changes: 12 additions & 2 deletions src/modules/Security.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,14 @@ class SecurityClass < Module
include Yast::Logger
include ::Security::CtrlAltDelConfig

SYSCTL_VALUES = {
SYSCTL_VALUES_TO_BOOLEAN = {
"yes" => true,
"no" => false
}
SYSCTL_VALUES_TO_INTSTRING = {
"yes" => "1",
"no" => "0"
}

SHADOW_ATTRS = [
"FAIL_DELAY",
Expand Down Expand Up @@ -784,9 +788,15 @@ def Import(settings)
tmpSettings[k] = settings[k]
else
if @sysctl.key?(k) && settings.key?(@sysctl2sysconfig[k])
# using the old sysconfig AY format
val = settings[@sysctl2sysconfig[k]].to_s
tmpSettings[k] = SYSCTL_VALUES.key?(val) ? SYSCTL_VALUES[val] : val
if @sysctl[k].is_a?(TrueClass) || @sysctl[k].is_a?(FalseClass)
tmpSettings[k] = SYSCTL_VALUES_TO_BOOLEAN.key?(val) ? SYSCTL_VALUES_TO_BOOLEAN[val] : val
else
tmpSettings[k] = SYSCTL_VALUES_TO_INTSTRING.key?(val) ? SYSCTL_VALUES_TO_INTSTRING[val] : val
end
else
# using old login defs settings ?
tmpSettings[k] = settings[@obsolete_login_defs[k]] || v
end
end
Expand Down
6 changes: 6 additions & 0 deletions test/security_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -782,6 +782,12 @@ def enabled?
expect(Security.Settings["SYS_GID_MIN"]).to eql("150")
end

it "imports enable_sysrq settings transforming key name" do
expect(Security.Import("enable_sysrq" => "no")).to eql(true)

expect(Security.Settings["kernel.sysrq"]).to eql("0")
end

it "does not modify not given settings" do
expect(Security.Import("EXTRA_SERVICES" => "yes")).to eql(true)

Expand Down

0 comments on commit 30e2725

Please sign in to comment.