Skip to content

Commit

Permalink
Use the simplevars lens instead of semanage
Browse files Browse the repository at this point in the history
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
  • Loading branch information
dgdavid committed Feb 11, 2021
1 parent 47de341 commit f7b4286
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
9 changes: 8 additions & 1 deletion src/lib/cfa/selinux.rb
Expand Up @@ -60,13 +60,20 @@ 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

# 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
4 changes: 2 additions & 2 deletions test/cfa/selinux_test.rb
Expand Up @@ -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
Expand Down

0 comments on commit f7b4286

Please sign in to comment.