aboutsummaryrefslogtreecommitdiffstats
path: root/recipes-security/selinux/selinux-labeldev/selinux-labeldev.sh
blob: 62e7a4297d696272a829f816f99ef48f1eb936d5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/bin/sh

/usr/sbin/selinuxenabled 2>/dev/null || exit 0

CHCON=/usr/bin/chcon
MATCHPATHCON=/usr/sbin/matchpathcon
RESTORECON=/sbin/restorecon

for i in ${CHCON} ${MATCHPATHCON} ${RESTORECON}; do
	test -x $i && continue
	echo "$i is missing in the system."
	echo "Please add \"selinux=0\" in the kernel command line to disable SELinux."
	exit 1
done

# Because /dev/console is not relabeled by kernel, many commands
# would can not use it, including restorecon.
${CHCON} -t `${MATCHPATHCON} -n /dev/null | cut -d: -f3` /dev/null
${CHCON} -t `${MATCHPATHCON} -n /dev/console | cut -d: -f3` /dev/console

# Now, we should relabel /dev for most services.
${RESTORECON} -RF /dev

exit 0