Skip to content

Commit

Permalink
The CentOS7 grep was broken
Browse files Browse the repository at this point in the history
  • Loading branch information
traylenator committed Nov 30, 2016
1 parent f1bb76a commit ea84fe3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
13 changes: 10 additions & 3 deletions manifests/fcontext.pp
Original file line number Diff line number Diff line change
Expand Up @@ -115,14 +115,21 @@
$resource_name = "add_${context}_${pathname}_type_${filemode}"
if $::osfamily == 'RedHat' and $::operatingsystemmajrelease == '6' {
case $filemode {
'a': { $_filemode = 'all files' }
default: { $_filemode = $filemode }
'a': {
$_filemode = 'all files'
$_quotedfilemode = '\'all files\''
}
default: {
$_filemode = $filemode
$_quotedfilemode = $_filemode
}
}
} else {
$_filemode = $filemode
$_quotedfilemode = $_filemode
}
$command = shellquote('semanage', 'fcontext','-a', '-f', $_filemode, '-t', $context, $pathname)
$unless = sprintf('semanage fcontext -E | grep -Fx %s', shellquote("fcontext -a -f '${_filemode}' -t ${context} '${pathname}'"))
$unless = sprintf('semanage fcontext -E | grep -Fx %s', shellquote("fcontext -a -f ${_quotedfilemode} -t ${context} '${pathname}'"))
}

Exec {
Expand Down
4 changes: 2 additions & 2 deletions spec/defines/selinux_fcontext_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,10 @@
end
if (facts[:osfamily] == 'RedHat') && (facts[:operatingsystemmajrelease] == '6')
it { is_expected.to contain_exec('add_user_home_dir_t_/tmp/file1_type_a').with(command: 'semanage fcontext -a -f "all files" -t user_home_dir_t /tmp/file1') }
it { is_expected.to contain_exec('add_user_home_dir_t_/tmp/file1_type_a').with(unless: 'semanage fcontext -E | grep -Fx "fcontext -a -f \'all files\' -t user_home_dir_t \'/tmp/file1\'"') }
it { is_expected.to contain_exec('add_user_home_dir_t_/tmp/file1_type_a').with(unless: "semanage fcontext -E | grep -Fx \"fcontext -a -f 'all files' -t user_home_dir_t '/tmp/file1'\"") }
else
it { is_expected.to contain_exec('add_user_home_dir_t_/tmp/file1_type_a').with(command: 'semanage fcontext -a -f a -t user_home_dir_t /tmp/file1') }
it { is_expected.to contain_exec('add_user_home_dir_t_/tmp/file1_type_a').with(unless: 'semanage fcontext -E | grep -Fx "fcontext -a -f \'a\' -t user_home_dir_t \'/tmp/file1\'"') }
it { is_expected.to contain_exec('add_user_home_dir_t_/tmp/file1_type_a').with(unless: "semanage fcontext -E | grep -Fx \"fcontext -a -f a -t user_home_dir_t '/tmp/file1'\"") }
end
it { is_expected.to contain_exec('restorecond add_user_home_dir_t_/tmp/file1_type_a').with(command: 'restorecon -R /tmp/file1/different') }
end
Expand Down

0 comments on commit ea84fe3

Please sign in to comment.