image.mk: evaluate /etc/selinux/config to choose SELinux policy
authorDaniel Golle <daniel@makrotopia.org>
Tue, 29 Sep 2020 00:46:25 +0000 (01:46 +0100)
committerDaniel Golle <daniel@makrotopia.org>
Tue, 29 Sep 2020 00:48:27 +0000 (01:48 +0100)
Instead of hardcoding 'targeted' policy, evaluate /etc/selinux/config
in rootfs to choose according to which policy files in the rootfs got
to be labeled.

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
include/image.mk

index f72095db56345e1ca803a56cc93cc2416bebc7d4..28f40fe6a9901acd194788942a149caaddd4d216 100644 (file)
@@ -243,10 +243,11 @@ endef
 
 ifeq ($(CONFIG_TARGET_ROOTFS_SECURITY_LABELS),y)
 define Image/mkfs/squashfs
+       echo ". $(call mkfs_target_dir,$(1))/etc/selinux/config" > $@.fakeroot-script
        echo "$(STAGING_DIR_HOST)/bin/setfiles -r" \
             "$(call mkfs_target_dir,$(1))" \
-            "$(call mkfs_target_dir,$(1))/etc/selinux/targeted/contexts/files/file_contexts " \
-            "$(call mkfs_target_dir,$(1))" > $@.fakeroot-script
+            "$(call mkfs_target_dir,$(1))/etc/selinux/\$${SELINUXTYPE}/contexts/files/file_contexts " \
+            "$(call mkfs_target_dir,$(1))" >> $@.fakeroot-script
        echo "$(Image/mkfs/squashfs-common)" >> $@.fakeroot-script
        chmod +x $@.fakeroot-script
        $(FAKEROOT) "$@.fakeroot-script"