![]() |
Working chrooted BIND 9 broken by SELinux
Ladies & Gents,
I am having issues with bind9 after installing selinux on an external firewall/dhcp/dns host I am setting up. I have figured out what I think needs fixing. When I setup bind I put in in jail, not knowing that selinux makes that not really nessessary. So now selinux is not, due to policy, allowing bind access to the files in the jail. I have found the command to change the perimisions but I don't know what to change them to. The jail is set /var/bind9/chroot/...... the permissions are set as Code:
system_u:object_r:var_t:s0 named.confCode:
# chcon -v --type=named_conf_t /var/bind9/chroot/etc/named.confAnother issue is that a lot of the selinux doc's on google that I can understand are for RH based systems and file locations are not the same. For instance I see alot of reference to /var/log/audit/audit.log but I have no such. Also alot of the doc's are somewhat dated, almost 10 years now. I found these and figured they might be all the permissions I need to fix it. Code:
cat /etc/selinux/default/modules/active/file_contexts | grep /etc/bind > /home/rbees/chroot.bind[Code:
chcon -v --type=named_zone_t /var/bind9/chroot/etc/bind(/.*)?Thanks |
First thing to do would be to look at AVC messages and run them through 'audit2allow'. /var/log/audit/audit.log only exists if you also installed the audit service, so check /var/log/messages or equivalent.
|
Thanks,
But don't have /var/log/audit/audit.log and with the internet access broke on the machine I can't install it. Guess I will have to figure out how to set selinux back to permissive instead of enforcing. |
Quote:
Quote:
|
Thanks unSpawn
Your guidance always helps. I have the steps to correct the permissions now but there are some log entries that I am not sure I should allow. For instance I have a lot of entries like Code:
[ 33.154295] type=1400 audit 1357745774.794:5): avc: denied { read write } for pid=740 comm="vgscan" name="lvm" dev=dm-1 ino=32421 scontext=system_u:system_r:lvm_t:s0 tcontext=system_u:object_r:file_t:s0 tclass=diraudit2why says Code:
Was caused by: Missing type enforcement (TE) allow rule.Thanks |
Oh yea, I did get internet access by setting selinux to permissive and rebooting.
|
Quote:
Quote:
Quote:
Quote:
Code:
#============= lvm_t ==============Code:
grep ':file_t' -r /etc/selinux/targeted/contexts/Code:
find / -xdev -context "*:*:file_t"Quote:
|
Please slow down a little.
How did you test to get Quote:
Code:
restorecon -n -vv /dev/dm-1I also have Quote:
I tried Code:
:/home/rbees/selinux# grep ':file_t' -r /etc/selinux/default/contexts/files/ > my-file_tAnd I get Code:
# find / -xdev -context "*:*:file_t" > my-file_t2Code:
type=1400 audit(1357745773.384:3): avc: denied { read write } for pid=660 comm="hostname" name="tty1" dev=devtmpfs ino=1398 scontext=system_u:system_r:hostname_t:s0 tcontext=system_u:object_r:tty_device_t:s0 class=chr_fileCode:
type=1400 audit(1357745773.848:4): avc: denied { read write } for pid=700 comm="logsave" name="tty1" dev=devtmpfs ino=1398 scontext=system_u:system_r:fsadm_t:s0 tcontext=system_u:object_r:tty_device_t:s0 tclass=chr_fileCode:
type=1400 audit(1357745778.980:21): avc: denied { read write } for pid=1002 comm="ifconfig" name="tty1" dev=devtmpfs ino=1398 scontext=system_u:system_r:ifconfig_t:s0 tcontext=system_u:object_r:tty_device_t:s0 tclass=chr_file |
Quote:
I got it by running your "vgscan" through 'audit2allow': Code:
echo 'type=1400 audit 1357745774.794:5): avc: denied { read write } for pid=740 comm="vgscan" name="lvm" dev=dm-1 ino=32421 scontext=system_u:system_r:lvm_t:s0 tcontext=system_u:object_r:file_t:s0 tclass=dir'|audit2allowQuote:
Quote:
Quote:
Quote:
Quote:
Quote:
|
OK I get
Code:
echo 'type=1400 audit 1357745774.794:5): avc: denied { read write } for pid=740 comm="vgscan" name="lvm" dev=dm-1 ino=32421 scontext=system_u:system_r:lvm_t:s0 tcontext=system_u:object_r:file_t:s0 tclass=dir'|audit2allowQuote:
I have basic and default installed Quote:
|
Quote:
Quote:
Quote:
|
From my bootlog (which is not enabled by default)
Code:
Thu Jan 10 08:44:16 2013: e2fsck 1.41.12 (17-May-2010)There is also this in syslog after a fresh boot Code:
.I have looked at debians bug tracker but I can't find any bugs that list "missing TE rules". But then I am not sure I am using it right. Not sure how it may help but I ran the all the avc entries in syslog from yesterday through audit2allow and here is the mysys.te output. Code:
module mysys 1.0; |
After a quick check I don't see any unwanted action (like demanding execstack or shadow_t access) so I'd load them as local policies. Best separate them so you can disable modules at will should someone be visiting you (everybody expects Murphy's first Law but Nobody expects the Spanish Inquisition ;-p):
Code:
#!/bin/bash |
Quote:
So after looking at the script it looks like I run it and it will pull the info it needs out of /var/log/messages. Should I run it from any place in particular? In the other modules I made with audit2allow I did it in a folder I have in my home folder specific to the config of the host as root. I see from my reading that where the file is created and the context that it is created in can change the selinux permissions. Thanks again for your guidance. |
You're welcome. It should be run as root and if you want to run it inside /root you only have to change the directory name 'mktemp' uses. This will create directories like /root/selinux_dhcpc.aabbccdd, leave their contents intact and only echo the 'semodule' load command:
Code:
#!/bin/bash |
| All times are GMT -5. The time now is 01:52 PM. |