Skip to content

Commit

Permalink
Merge pull request #298 from oranenj/rhel8_support
Browse files Browse the repository at this point in the history
Fix selinux_port on RHEL 8/CentOS 8
  • Loading branch information
bastelfreak authored Oct 3, 2019
2 parents 5df2c73 + f682c34 commit 2ba6738
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
15 changes: 15 additions & 0 deletions lib/facter/selinux_python_command.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Facter.add(:selinux_python_command) do
confine osfamily: 'RedHat'
setcode do
if File.exist? '/usr/libexec/platform-python'
# RHEL 8 / CentOS 8
'/usr/libexec/platform-python'
elsif Facter::Core::Execution.execute('rpm -q python3-libsemanage') !~ %r{not installed}
'python3'
else
# This might be python 2 or 3. Keeping it at 'python' matches the module
# worked previously
'python'
end
end
end
6 changes: 0 additions & 6 deletions lib/facter/selinux_semanage_is_python3.rb

This file was deleted.

3 changes: 1 addition & 2 deletions lib/puppet/provider/selinux_port/semanage.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
# SELinux must be enabled. Is there a way to get a better error message?
confine selinux: true

# custom fact, needed for fedora 24+
python_command = Facter.value(:selinux_semanage_is_python3) ? 'python3' : 'python'
python_command = Facter.value(:selinux_python_command)
# current file path is lib/puppet/provider/selinux_port/semanage.rb
# semanage_ports.py is lib/puppet_x/voxpupuli/selinux/semanage_ports.py
PORTS_HELPER = File.expand_path('../../../../puppet_x/voxpupuli/selinux/semanage_ports.py', __FILE__)
Expand Down

0 comments on commit 2ba6738

Please sign in to comment.