Skip to content

Commit

Permalink
Fixing change-selinux-status-to-disabled exec
Browse files Browse the repository at this point in the history
setenforce only accepts enforcing or permissive (or 0 and 1) as possible modes.
When calling the selinux module with the current mode as either enforcing or permissive and $mode => disabled, the exec change-selinux-status-to-disabled will give exit code 1. A reboot does solve this, but until that happens. each puppet run will result in a report with a corrective change.
  • Loading branch information
bjvrielink authored and Bart-Jan Vrielink committed Jan 4, 2018
1 parent ee251e8 commit b9b1db6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
11 changes: 7 additions & 4 deletions manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,13 @@
}
}

exec { "change-selinux-status-to-${_real_mode}":
command => "setenforce ${sestatus}",
unless => "getenforce | grep -Eqi '${_real_mode}|disabled'",
path => '/bin:/sbin:/usr/bin:/usr/sbin',
# setenforce only works when SELinux itself is enabled
if $_real_mode in ['enforcing','permissive'] {
exec { "change-selinux-status-to-${_real_mode}":
command => "setenforce ${sestatus}",
unless => "getenforce | grep -Eqi '${_real_mode}|disabled'",
path => '/bin:/sbin:/usr/bin:/usr/sbin',
}
}
}

Expand Down
1 change: 0 additions & 1 deletion spec/classes/selinux_config_mode_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@

it { is_expected.to contain_file('/var/lib/puppet/puppet-selinux') }
it { is_expected.to contain_file_line('set-selinux-config-to-disabled').with(line: 'SELINUX=disabled') }
it { is_expected.to contain_exec('change-selinux-status-to-disabled').with(command: 'setenforce 0') }
it { is_expected.not_to contain_file('/.autorelabel') }
end

Expand Down

0 comments on commit b9b1db6

Please sign in to comment.