我一直在争论这个问题,似乎CentOS 6中有一个回归,因为anaconda忽略了se
linux –disabled指令.这似乎首先出现在
RHEL 4.8,然后在
RHEL 5.6重新出现.
现在使用以前的版本,您只需将sed语句添加到%post指令中即可将其禁用.
sed -i -e 's/\(^SELINUX=\).*$/\1permissive/' /etc/selinux/config
我遇到的问题是RHEL / CentOS 6中的新功能是它们默认设置文件系统属性,所以你现在必须去清除它们.
我尝试运行以下命令来删除我的%post部分中的那些属性,但它没有任何效果.
find . -exec setfattr -x security.selinux {} \;
我的kickstart文件位于下方,以防您发现它有用:
#version=RHEL6
install
url --url=http://ny-man01.ds.stackexchange.com/centos/6/os/x86_64
lang en_US.UTF-8
keyboard us
%include /tmp/nic-include
rootpw --iscrypted <mmm no you don't even get the encrypted version>
firewall --service=ssh,ntp,snmp
authconfig --enableshadow --passalgo=sha512 --enablefingerprint --enablekrb5
selinux --disabled
timezone --utc Etc/UTC
bootloader --location=mbr --driveorder=sda --append="crashkernel=auto rhgb quiet"
# The following is the partition information you requested
# Note that any partitions you deleted are not expressed
# here so unless you clear all partitions first,this is
# not guaranteed to work
clearpart --all --initlabel --drives=sda
part /boot --fstype=ext4 --size=500
part pv.M3dTcp-jomG-l0xc-Zl3I-wqR1-Gcwz-14jidB --grow --size=1
volgroup vg_test --pesize=4096 pv.M3dTcp-jomG-l0xc-Zl3I-wqR1-Gcwz-14jidB
logvol / --fstype=ext4 --name=lv_root --vgname=vg_test --grow --size=1024 --maxsize=51200
logvol swap --name=lv_swap --vgname=vg_test --grow --size=1024 --maxsize=6016
services --enabled ntpd,snmpd,puppet
reboot
repo --name="CentOS" --baseurl=http://ny-man01.ds.stackexchange.com/centos/6/os/x86_64/ -- cost=100
repo --name="EPEL6" --baseurl=http://ny-man01.ds.stackexchange.com/epel/6/x86_64/
repo --name="SEI" --baseurl=http://ny-man01.ds.stackexchange.com/sei/
%packages
@base
@core
@hardware-monitoring
@perl-runtime
@server-policy
@system-admin-tools
pam_krb5
sgpio
perl-DBD-sqlite
epel-release-6-5
net-snmp
ntp
mercurial
puppet
%pre
echo "# `grep /proc/net/dev eth| cut -d: -f1 | cut -d' ' -f3` " >>/tmp/nic-include
echo "# auto generated nic setup" > /tmp/nic-include
for nic in `grep eth /proc/net/dev| cut -d: -f1 | cut -d' ' -f3`
do
if [ "$nic" = "eth0" ]
then
echo "network --device $nic --bootproto dhcp " >> /tmp/nic-include
else
echo "network --device $nic --onboot no --bootproto dhcp" >> /tmp/nic-inclu de
fi
done
%post --log /root/ks-post.log
#sed -i -e 's/\(^SELINUX=\).*$/\1disabled/' /etc/selinux/config
#find / -exec setfattr -x security.selinux {} \;
wget -O- http://10.7.0.50/kickstart/generic-configs/get_files.sh | /bin/bash
cp /tmp/nic-include /root/
CentOS 6安装程序默认情况下以允许模式加载策略(我在安装期间通过运行dmesg确认).这意味着在安装后的步骤中,SELinux已经处于活动状态.只要它正在运行,它看起来就像你可以删除属性.
在安装开始之前,您必须在某个位置传递以下内容(在内核末尾的引导加载程序行):
selinux=0
所以这样的事情:
kernel /boot/vmlinuz-2.4.20-XXXXXXXXX ro root=/dev/hda1 nousb selinux=0
以下是在允许模式下尝试删除属性时发生的情况(原谅格式化,SF似乎不满意):
[root@centos6dev test]# find . -exec setfattr -x security.selinux {} \;
setfattr: .: Permission denied
setfattr: ./test2: Permission denied
setfattr: ./test3: Permission denied
setfattr: ./test: Permission denied
在启动时从grub禁用selinux:
[root@centos6dev test]# ls -Z
-rw-r--r--. root root unconfined_u:object_r:admin_home_t:s0 test
-rw-r--r--. root root unconfined_u:object_r:admin_home_t:s0 test2
-rw-r--r--. root root unconfined_u:object_r:admin_home_t:s0 test3
[root@centos6dev test]# find . -exec setfattr -x security.selinux {} \;
[root@centos6dev test]# ls -la
total 8
drwxr-xr-x 2 root root 4096 Dec 13 22:27 .
dr-xr-x---. 4 root root 4096 Dec 13 22:27 ..
-rw-r--r-- 1 root root 0 Dec 13 22:27 test
-rw-r--r-- 1 root root 0 Dec 13 22:27 test2
-rw-r--r-- 1 root root 0 Dec 13 22:27 test3
[root@centos6dev test]# ls -Z
-rw-r--r-- root root ? test
-rw-r--r-- root root ? test2
-rw-r--r-- root root ? test3
基于此以及此错误report,这可能意味着您将无法删除安装后的属性.因此,如我所述,您需要在启动安装之前禁用selinux.
(或者你可以放下它,学会忍受它.:)).