From f7b428696fe33814530c243511d52c42822c7587 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20D=C3=ADaz=20Gonz=C3=A1lez?= Date: Thu, 11 Feb 2021 09:24:24 +0000 Subject: [PATCH] Use the simplevars lens instead of semanage Because semanage lens was introduced in augeas-lenses 1.12, which might be not available in target products. See https://github.com/hercules-team/augeas/pull/594/files --- src/lib/cfa/selinux.rb | 9 ++++++++- test/cfa/selinux_test.rb | 4 ++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/lib/cfa/selinux.rb b/src/lib/cfa/selinux.rb index 8bba841a..171e09b0 100644 --- a/src/lib/cfa/selinux.rb +++ b/src/lib/cfa/selinux.rb @@ -60,7 +60,7 @@ def self.load(file_handler: Yast::TargetFile, file_path: PATH) # # @see CFA::BaseModel#initialize def initialize(file_handler: Yast::TargetFile, file_path: PATH) - super(AugeasParser.new("semanage.lns"), file_path, file_handler: file_handler) + super(AugeasParser.new(LENS), file_path, file_handler: file_handler) end private @@ -68,5 +68,12 @@ def initialize(file_handler: Yast::TargetFile, file_path: PATH) # Default path to the SELinux config file PATH = "/etc/selinux/config".freeze private_constant :PATH + + # The lens to be used by Augeas parser + # + # @note uses the simplevars lens instead of semanage because the latest is only available from + # augeas-lenses >= 1.12. See https://github.com/hercules-team/augeas/pull/594/files + LENS = "simplevars.lns".freeze + private_constant :LENS end end diff --git a/test/cfa/selinux_test.rb b/test/cfa/selinux_test.rb index 70bd3091..eea3b433 100644 --- a/test/cfa/selinux_test.rb +++ b/test/cfa/selinux_test.rb @@ -41,8 +41,8 @@ end describe "#initialize" do - it "creates an own Augeas instance" do - expect(::CFA::AugeasParser).to receive(:new).with("semanage.lns").and_call_original + it "creates an own Augeas instance using simplevars lens" do + expect(::CFA::AugeasParser).to receive(:new).with("simplevars.lns").and_call_original described_class.new(file_handler: file_handler) end