Open johnnybubonic opened 5 years ago
@johnnybubonic Thanks for the extensive documentation of the proper fix!
I'm leaning towards a cleaner version of "the hacky way" based on #151, because
a) decoupling formulas (selinux/openssh) reduces need for maintenance.
b) I think a simple use_check_cmd: False
in osfingermap.yaml
is sufficient to prevent the original bug.
Nevertheless I would add proper documentation in pillar.example
on
1) how to set the flag based on grains. (use_check_cmd: {{ salt['grains.get']('selinux:enforced', False) != 'Enforcing' }}
)
2) how to do it properly, which will essentially be a link to this Issue.
@alxwr -
true, and agreed on all points, and it DOES reduce dependencies. sometimes KISS is best. :) thanks for reviewing this!
In RHEL/CentOS 6.10 with SELinux set to
enforcing
, the following access violation will occur when testing the new sshd_config with check_cmd (openssh/config.sls
, line17
):Which, according to
audit2allow -w
, is because:This issue was reported in the (as yet unresolved) https://github.com/saltstack-formulas/openssh-formula/issues/98.
There are two ways around this.
The hacky way:
or the proper way - by using selinux.module_install, you can install an SELinux policy that will allow the tmp file to be read by check_cmd.
I have taken the liberty of generating this policy. In the interest of transparency for those that wish to use it, here's how (all commands assume root):
yum -y install policycoreutils-python
(if you currently don't have theaudit2allow
program installed)grep 'name="__salt.tmp.' /var/log/audit/audit.log > /tmp/avc_err
cat /tmp/avc_err | audit2allow -m salt.openssh_formula.fix_centos6_selinux > salt.openssh_formula.fix_centos6_selinux.te
checkmodule -M -m -o salt.openssh_formula.fix_centos6_selinux.mod salt.openssh_formula.fix_centos6_selinux.te
semodule_package -o salt.openssh_formula.fix_centos6_selinux.pp -m salt.openssh_formula.fix_centos6_selinux.mod
semodule -i salt.openssh_formula.fix_centos6_selinux.pp
but in this case, SaltStack should install this.Here are those files that are generated:
salt.openssh_formula.fix_centos6_selinux.te:
salt.openssh_formula.fix_centos6_selinux.mod (binary file; in Base64)[0]:
salt.openssh_formula.fix_centos6_selinux.pp (binary file; in Base64)[0]:
[0] To decode base64 back into a binary file, copy the entire base64 string to a file (e.g.
selinuxpolicy.b64
) and then dobase64 -d selinuxpolicy.b64 > newfilename
.newfilename
is the reassembled file. You can pipe it as well:echo '<base64_string>' | base64 -d > newfilename
- but if you do it this way, you must remove the linebreaks.You SHOULD only need the
salt.openssh_formula.fix_centos6_selinux.pp
file. Use a file.manage to get that in place if:and then apply it with selinux.module_install.
I have tested the policy and it does indeed work.
I have confirmed the following works on a fresh install of CentOS 6.10: