blob: 64bf1a8612dc1d3f9d7df0e9df7598fa3b217b6f [file] [log] [blame]
xf.li86118912025-03-19 20:07:27 -07001#!/bin/sh
2
3/usr/sbin/selinuxenabled 2>/dev/null || exit 0
4
5CHCON=/usr/bin/chcon
6MATCHPATHCON=/usr/sbin/matchpathcon
7RESTORECON=/sbin/restorecon
8
9mkdir -p /dev/socket -m 777
10for i in ${CHCON} ${MATCHPATHCON} ${RESTORECON}; do
11 test -x $i && continue
12 echo "$i is missing in the system."
13 echo "Please add \"selinux=0\" in the kernel command line to disable SELinux."
14 exit 1
15done
16
17# Because /dev/console is not relabeled by kernel, many commands
18# would can not use it, including restorecon.
19${CHCON} -t `${MATCHPATHCON} -n /dev/null | cut -d: -f3` /dev/null
20${CHCON} -t `${MATCHPATHCON} -n /dev/console | cut -d: -f3` /dev/console
21
22# Now, we should relabel /dev for most services.
23mkdir -p /dev/socket -m 777
24${RESTORECON} -RF /dev
25
26exit 0