forked from pool/libselinux
Accepting request 143038 from home:vitezslav_cizek:branches:security:SELinux
- update selinux-ready script OBS-URL: https://build.opensuse.org/request/show/143038 OBS-URL: https://build.opensuse.org/package/show/security:SELinux/libselinux?expand=0&rev=55
This commit is contained in:
@@ -22,37 +22,58 @@ check_dir()
|
||||
check_filesystem()
|
||||
{
|
||||
FSPATH="/proc/filesystems"
|
||||
FSNAME="securityfs"
|
||||
FSNAMES="securityfs selinuxfs"
|
||||
OK="O"
|
||||
|
||||
grep -w $FSNAME $FSPATH 1>&2 >/dev/null
|
||||
for FSNAME in $FSNAMES; do
|
||||
grep -w $FSNAME $FSPATH 1>&2 >/dev/null
|
||||
|
||||
if [ $? == 0 ]; then
|
||||
printf "\tcheck_filesystem: OK. Filesystem '$FSNAME' exists.\n"
|
||||
return 0
|
||||
if [ $? == 0 ]; then
|
||||
printf "\tcheck_filesystem: OK. Filesystem '$FSNAME' exists.\n"
|
||||
else
|
||||
printf "\tcheck_filesystem: ERR. Filesystem '$FSNAME' is missing. Please enable SELinux while compiling the kernel.\n"
|
||||
OK="1"
|
||||
fi
|
||||
done
|
||||
if [ "$OK" == "0" ]; then
|
||||
return 0;
|
||||
else
|
||||
printf "\tcheck_filesystem: ERR. Filesystem '$FSNAME' is missing. Please enable SELinux while compiling the kernel.\n"
|
||||
return 0
|
||||
return 1;
|
||||
fi
|
||||
}
|
||||
|
||||
check_boot()
|
||||
{
|
||||
BPARAM="selinux=1"
|
||||
BPARAM1="security=selinux"
|
||||
BPARAM2="selinux=1"
|
||||
|
||||
printf "\tcheck_boot: Assuming GRUB as bootloader.\n"
|
||||
printf "\tcheck_boot: Assuming GRUB2 as bootloader.\n"
|
||||
|
||||
BLINE=$(grep -- $BPARAM /boot/grub/menu.lst 2>/dev/null) # XXX check for multiple lines in config
|
||||
|
||||
if [ $? == 0 ]; then
|
||||
# look for parameters of the current kernel
|
||||
CURRENT_KERNEL=$(uname -r)
|
||||
OTHERS=""
|
||||
RETVAL="FAIL"
|
||||
while read BLINE
|
||||
do
|
||||
K=$(echo $BLINE | awk -F' ' '{print $2}')
|
||||
KERNEL=$(basename $K)
|
||||
K=$(echo $KERNEL | sed s/vmlinuz-//)
|
||||
INITRD=initrd-$K
|
||||
printf "\tcheck_boot: OK. Kernel '$KERNEL' has boot-parameter '$BPARAM'\n"
|
||||
|
||||
if [ "$K" == "$CURRENT_KERNEL" ]; then
|
||||
INITRD=initrd-$K
|
||||
RETVAL="OK"
|
||||
else
|
||||
OTHERS="$KERNEL $OTHERS"
|
||||
fi
|
||||
done < <(grep -- $BPARAM1 /boot/grub2/grub.cfg 2>/dev/null | grep -- $BPARAM2)
|
||||
|
||||
if [ "$RETVAL" == OK ]; then
|
||||
printf "\tcheck_boot: OK. Current kernel '$KERNEL' has boot-parameters '$BPARAM1 $BPARAM2'\n"
|
||||
printf "\tcheck_boot: OK. Other kernels with correct parameters: $OTHERS\n"
|
||||
return 0
|
||||
else
|
||||
printf "\tcheck_boot: ERR. Boot-parameter missing for booting the kernel.\n"
|
||||
printf "\t Please use YaST2 to add 'selinux=1' to the kernel boot-parameter list.\n"
|
||||
printf "\t Please use YaST2 to add 'security=selinux selinux=1' to the kernel boot-parameter list.\n"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
@@ -141,7 +162,7 @@ check_initupstart()
|
||||
return 1;
|
||||
fi
|
||||
|
||||
POL=$(grep SELINUXTYPE $CFGFILE | sed "s/SELINUXTYPE\s*=\s*"//)
|
||||
POL=$(grep "^\s*SELINUXTYPE" $CFGFILE | sed "s/SELINUXTYPE\s*=\(\S*\)\s*"/\\1/)
|
||||
|
||||
if ! [ -f /etc/selinux/$POL/booleans ]; then
|
||||
printf "\tcheck_initupstart: ERR. booleans file for policy $POL does not exist.\n"
|
||||
|
Reference in New Issue
Block a user