diff options
author | Yi Zhao <yi.zhao@windriver.com> | 2019-09-09 10:03:49 +0800 |
---|---|---|
committer | Joe MacDonald <joe_macdonald@mentor.com> | 2019-09-09 09:56:25 -0400 |
commit | 10d4a50fc5b4d6da9dc74247ad5ab5ca0eda68bb (patch) | |
tree | d6ccfa1ec820edd99c0dcb0a6ebf9f7f63b76ff5 | |
parent | 0c9ee0bcb7548ef1e493367b78c49c1b2691c613 (diff) | |
download | meta-selinux-10d4a50fc5b4d6da9dc74247ad5ab5ca0eda68bb.tar.gz |
selinux-autorelabel: disable enforcing mode before relabel
The commit b0d31db104d9a4e94bc1409c2ffcc1d82f4a780f introduced an issue
when first boot with bootparams="selinux=1 enforcing=1". At first boot,
all files are unlabeled including /sbin/setfiles. The relabel operations
are not permitted under enforcing mode. So we need to disable enforcing
mode before relabel.
Signed-off-by: Yi Zhao <yi.zhao@windriver.com>
Signed-off-by: Joe MacDonald <joe_macdonald@mentor.com>
-rw-r--r-- | recipes-security/selinux/selinux-autorelabel/selinux-autorelabel.sh | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/recipes-security/selinux/selinux-autorelabel/selinux-autorelabel.sh b/recipes-security/selinux/selinux-autorelabel/selinux-autorelabel.sh index 154dad1..25b6921 100644 --- a/recipes-security/selinux/selinux-autorelabel/selinux-autorelabel.sh +++ b/recipes-security/selinux/selinux-autorelabel/selinux-autorelabel.sh | |||
@@ -3,16 +3,19 @@ | |||
3 | /usr/sbin/selinuxenabled 2>/dev/null || exit 0 | 3 | /usr/sbin/selinuxenabled 2>/dev/null || exit 0 |
4 | 4 | ||
5 | FIXFILES=/sbin/fixfiles | 5 | FIXFILES=/sbin/fixfiles |
6 | SETENFORCE=/usr/sbin/setenforce | ||
6 | 7 | ||
7 | if ! test -x ${FIXFILES}; then | 8 | for i in ${FIXFILES} ${SETENFORCE}; do |
8 | echo "${FIXFILES} is missing in the system." | 9 | test -x $i && continue |
10 | echo "$i is missing in the system." | ||
9 | echo "Please add \"selinux=0\" in the kernel command line to disable SELinux." | 11 | echo "Please add \"selinux=0\" in the kernel command line to disable SELinux." |
10 | exit 1 | 12 | exit 1 |
11 | fi | 13 | done |
12 | 14 | ||
13 | # If /.autorelabel placed, the whole file system should be relabeled | 15 | # If /.autorelabel placed, the whole file system should be relabeled |
14 | if [ -f /.autorelabel ]; then | 16 | if [ -f /.autorelabel ]; then |
15 | echo "SELinux: /.autorelabel placed, filesystem will be relabeled..." | 17 | echo "SELinux: /.autorelabel placed, filesystem will be relabeled..." |
18 | ${SETENFORCE} 0 | ||
16 | ${FIXFILES} -F -f relabel | 19 | ${FIXFILES} -F -f relabel |
17 | /bin/rm -f /.autorelabel | 20 | /bin/rm -f /.autorelabel |
18 | echo " * Relabel done, rebooting the system." | 21 | echo " * Relabel done, rebooting the system." |