selinux-autorelabel: disable enforcing mode before relabel
PATCH 1/1 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/fixfiles. The relabel operation is not permitted under enforcing mode. Set /sys/fs/selinux/enforce to 0 to ensure the enforcing mode is disabled before relabel.
--- recipes-security/selinux/selinux-autorelabel/selinux-autorelabel.sh | 1 + 1 file changed, 1 insertion(+)
recipes-security/selinux/selinux-autorelabel/selinux-autorelabel.sh +1 -0
@@ -13,6 +13,7 @@ fi # If /.autorelabel placed, the whole file system should be relabeled if [ -f /.autorelabel ]; then echo "SELinux: /.autorelabel placed, filesystem will be relabeled..." + echo "0" > /sys/fs/selinux/enforce ${FIXFILES} -F -f relabel /bin/rm -f /.autorelabel echo " * Relabel done, rebooting the system."
Signature · 1 line
2.7.4
Quoted 5 lines · [[meta-selinux][PATCH] selinux-autorelabel: disable enforcing mode before…
The commit
b0d31db104d9a4e94bc1409c2ffcc1d82f4a780fintroduced an issue when first boot with bootparams="selinux=1 enforcing=1". At first boot, all files are unlabeled including/sbin/fixfiles. The relabel operation is not permitted under enforcing mode. Set/sys/fs/selinux/enforceto 0 to ensure the enforcing mode is disabled before relabel.
Did you try this with '/usr/sbin/setenforce 0' instead? The rationale makes sense but going straight at sysfs like that isn't the right approach intuitively. If that's not working, please just include a bit of an explanation for why this is the best option.
Thanks.
-J.
Quoted 21 lines
Signed-off-by Yi Zhao <[email protected]>--- recipes-security/selinux/selinux-autorelabel/selinux-autorelabel.sh | 1 + 1 file changed, 1 insertion(+)recipes-security/selinux/selinux-autorelabel/selinux-autorelabel.sh +1
-0@@ -13,6 +13,7 @@ fi # If /.autorelabel placed, the whole file system should be relabeled if [ -f /.autorelabel ]; then echo "SELinux: /.autorelabel placed, filesystem will be relabeled..." + echo "0" > /sys/fs/selinux/enforce ${FIXFILES} -F -f relabel /bin/rm -f /.autorelabel echo " * Relabel done, rebooting the system."Signature · 1 line
2.7.4
Quoted 11 lines · Joe MacDonald
Quoted 5 lines · [[meta-selinux][PATCH] selinux-autorelabel: disable enforcing mode before…
The commit
b0d31db104d9a4e94bc1409c2ffcc1d82f4a780fintroduced an issue when first boot with bootparams="selinux=1 enforcing=1". At first boot, all files are unlabeled including/sbin/fixfiles. The relabel operation is not permitted under enforcing mode. Set/sys/fs/selinux/enforceto 0 to ensure the enforcing mode is disabled before relabel.Did you try this with '
/usr/sbin/setenforce0' instead? The rationale makes sense but going straight at sysfs like that isn't the right approach intuitively. If that's not working, please just include a bit of an explanation for why this is the best option.
It also works with setenforce.
I referred to the selinux-autorelabel script on Fedora 30, it uses echo "0" > /sys/fs/selinux/enforce to disables enforcing mode:
cat /usr/libexec/selinux/selinux-autorelabel
[snip]
32 relabel_selinux() {
33 # if /sbin/init is not labeled correctly this process is running in the 34 # wrong context, so a reboot will be required after relabel 35 AUTORELABEL=
36 . /etc/selinux/config
37 echo "0" > /sys/fs/selinux/enforce
38 [ -x /bin/plymouth ] && plymouth --quit
39
[snip]
//Yi
Quoted 24 lines
Thanks.
-J.Quoted 20 lines
Signed-off-by Yi Zhao <[email protected]>--- recipes-security/selinux/selinux-autorelabel/selinux-autorelabel.sh | 1 + 1 file changed, 1 insertion(+)recipes-security/selinux/selinux-autorelabel/selinux-autorelabel.sh +1
-0@@ -13,6 +13,7 @@ fi # If /.autorelabel placed, the whole file system should be relabeled if [ -f /.autorelabel ]; then echo "SELinux: /.autorelabel placed, filesystem will be relabeled..." + echo "0" > /sys/fs/selinux/enforce ${FIXFILES} -F -f relabel /bin/rm -f /.autorelabel echo " * Relabel done, rebooting the system."Signature · 1 line
2.7.4
Quoted 21 lines · [Re: [meta-selinux][PATCH] selinux-autorelabel: disable enforcing mode before…
Quoted 11 lines · Joe MacDonald
Quoted 5 lines · [[meta-selinux][PATCH] selinux-autorelabel: disable enforcing mode before…
The commit
b0d31db104d9a4e94bc1409c2ffcc1d82f4a780fintroduced an issue when first boot with bootparams="selinux=1 enforcing=1". At first boot, all files are unlabeled including/sbin/fixfiles. The relabel operation is not permitted under enforcing mode. Set/sys/fs/selinux/enforceto 0 to ensure the enforcing mode is disabled before relabel.Did you try this with '
/usr/sbin/setenforce0' instead? The rationale makes sense but going straight at sysfs like that isn't the right approach intuitively. If that's not working, please just include a bit of an explanation for why this is the best option.It also works with setenforce.
I referred to the selinux-autorelabel script on Fedora 30, it uses `echo "0"
Quoted 1 line
/sys/fs/selinux/enforce` to disables enforcing mode:
cat
/usr/libexec/selinux/selinux-autorelabel
Quoted 11 lines
[snip]
32relabel_selinux(){
33 # if/sbin/initis not labeled correctly this process is running in the
34 # wrong context, so a reboot will be required after relabel 35 AUTORELABEL=
36 ./etc/selinux/config
37 echo "0" >/sys/fs/selinux/enforce
38 [ -x/bin/plymouth] && plymouth --quit
39
[snip]
Okay, but our version of the script is much less complex than the Fedora one and we already have the precedent of calling fixfiles by full path and variable, I'd rather keep the script consistent in style. If you want to propose replacing our selinux-autorelabel.sh with the one from Fedora, please submit a patch for that, but for this patch I'd just rather see the style remain consistent with what's already there.
Thanks.
-J.
Quoted 29 lines
//Yi
Quoted 24 lines
Thanks.
-J.Quoted 20 lines
Signed-off-by Yi Zhao <[email protected]>--- recipes-security/selinux/selinux-autorelabel/selinux-autorelabel.sh | 1 + 1 file changed, 1 insertion(+)recipes-security/selinux/selinux-autorelabel/selinux-autorelabel.sh +1
-0@@ -13,6 +13,7 @@ fi # If /.autorelabel placed, the whole file system should be relabeled if [ -f /.autorelabel ]; then echo "SELinux: /.autorelabel placed, filesystem will be relabeled..." + echo "0" > /sys/fs/selinux/enforce ${FIXFILES} -F -f relabel /bin/rm -f /.autorelabel echo " * Relabel done, rebooting the system."Signature · 1 line
2.7.4
Signature · 3 lines
-Joe MacDonald. Linux Architect | Mentor® A Siemens Business :wq