Showing with 54 additions and 40 deletions.
  1. +6 −0 CHANGELOG.md
  2. +1 −3 README.md
  3. +1 −1 manifests/config.pp
  4. +25 −28 manifests/module.pp
  5. +1 −1 metadata.json
  6. +20 −3 spec/classes/selinux_config_mode_spec.rb
  7. +0 −4 spec/default_module_facts.yml
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Change Log

## 2016-12-28 Release 0.7.1

- selinux::module syncversion parameter now defaults to undef
to workaround puppet selmodule syncversion bug on CentOS >= 7.3 ([PR #158](https://github.com/voxpupuli/puppet-selinux/pull/158))
- Bugfix for wrong named fact used in selinux::config ([PR #159](https://github.com/voxpupuli/puppet-selinux/pull/159))

## 2016-12-14 Release 0.7.0

- Remove custom fact selinux_custom_policy (not used anymore)
Expand Down
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@ This class manages SELinux on RHEL based systems.

## Requirements

* Puppet-3.x or later
* Facter 1.7.0 or later
* Ruby-1.9.3 or later (Ruby-1.8.7 is **not** supported).
* Puppet 3.8.7 or later

## Module Description

Expand Down
2 changes: 1 addition & 1 deletion manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
# a complete relabeling is required when switching from disabled to
# permissive or enforcing. Ensure the autorelabel trigger file is created.
if $mode in ['enforcing','permissive'] and
!$::selinux_enabled {
!$::selinux {
file { '/.autorelabel':
ensure => 'file',
owner => 'root',
Expand Down
53 changes: 25 additions & 28 deletions manifests/module.pp
Original file line number Diff line number Diff line change
@@ -1,40 +1,35 @@
# Definition: selinux::module
# Defined type: selinux::module
#
# Description
# This class will either install or uninstall a SELinux module from a running system.
# This module allows an admin to keep .te files in text form in a repository, while
# allowing the system to compile and manage SELinux modules.
# This class will either install or uninstall a SELinux module from a running system.
# This module allows an admin to keep .te files in text form in a repository, while
# allowing the system to compile and manage SELinux modules.
#
# Concepts incorporated from:
# http://stuckinadoloop.wordpress.com/2011/06/15/puppet-managed-deployment-of-selinux-modules/
#
# Parameters:
# - $ensure: (present|absent) - sets the state for a module
# - $sx_mod_dir (absolute_path) - sets the module directory.
# - $source: the source file (either a puppet URI or local file) of the SELinux .te module
# - $makefile: the makefile file path
# - $prefix: the prefix to add to the loaded module. Defaults to ''.
#
# Actions:
# Compiles a module using make and installs it
#
# Requires:
# - SELinux
#
# Sample Usage:
# selinux::module{ 'apache':
# ensure => 'present',
# source => 'puppet:///modules/selinux/apache.te',
# }
# Concepts incorporated from:
# http://stuckinadoloop.wordpress.com/2011/06/15/puppet-managed-deployment-of-selinux-modules/
#
# @example compile and load the apache module
# selinux::module{ 'apache':
# ensure => 'present',
# source => 'puppet:///modules/selinux/apache.te',
# }
#
# @param ensure present or absent
# @param sx_mod_dir path where source is stored and the module built.
# Valid values: absolute path
# @param source the source file (either a puppet URI or local file) of the SELinux .te file
# @param content content of the source .te file
# @param makefile absolute path to the selinux-devel Makefile
# @param prefix (DEPRECATED) the prefix to add to the loaded module. Defaults to ''.
# Does not work with CentOS >= 7.2 and Fedora >= 24 SELinux tools.
# @param syncversion selmodule syncversion param
define selinux::module(
$source = undef,
$content = undef,
$ensure = 'present',
$makefile = '/usr/share/selinux/devel/Makefile',
$prefix = '',
$sx_mod_dir = '/usr/share/selinux',
$syncversion = true,
$syncversion = undef,
) {

include ::selinux
Expand All @@ -52,7 +47,9 @@
validate_string($prefix)
validate_absolute_path($sx_mod_dir)
validate_absolute_path($makefile)
validate_bool($syncversion)
if $syncversion != undef {
validate_bool($syncversion)
}

## Begin Configuration
file { "${sx_mod_dir}/${prefix}${name}.te":
Expand Down
2 changes: 1 addition & 1 deletion metadata.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "puppet-selinux",
"version": "0.7.0",
"version": "0.7.1",
"author": "Vox Pupuli",
"summary": "This class manages SELinux on RHEL based systems",
"license": "Apache-2.0",
Expand Down
23 changes: 20 additions & 3 deletions spec/classes/selinux_config_mode_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@
on_supported_os.each do |os, facts|
context "on #{os}" do
let(:facts) do
facts
facts.merge(
selinux: true,
selinux_config_mode: 'enforcing',
selinux_config_policy: 'targeted',
selinux_current_mode: 'enforcing'
)
end

context 'config' do
Expand Down Expand Up @@ -54,15 +59,27 @@

context 'disabled to permissive creates autorelabel trigger file' do
let(:facts) do
facts.merge(selinux_enabled: false)
hash = facts.merge(
selinux: false
)
hash.delete(:selinux_config_mode)
hash.delete(:selinux_current_mode)
hash.delete(:selinux_config_policy)
hash
end
let(:params) { { mode: 'permissive' } }
it { is_expected.to contain_file('/.autorelabel').with(ensure: 'file') }
end

context 'disabled to enforcing creates autorelabel trigger file' do
let(:facts) do
facts.merge(selinux_enabled: false)
hash = facts.merge(
selinux: false
)
hash.delete(:selinux_config_mode)
hash.delete(:selinux_current_mode)
hash.delete(:selinux_config_policy)
hash
end
let(:params) { { mode: 'enforcing' } }
it { is_expected.to contain_file('/.autorelabel').with(ensure: 'file') }
Expand Down
4 changes: 0 additions & 4 deletions spec/default_module_facts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@
osfamily: RedHat
operatingsystem: RedHat
operatingsystemmajrelease: '7'
selinux_config_mode: enforcing
selinux_current_mode: enforcing
selinux_enabled: true
selinux_config_policy: targeted
# concat facts
id: 0
path: /tmp