Skip to content
This repository was archived by the owner on Sep 18, 2020. It is now read-only.

Commit 91c7555

Browse files
committed
build-library: Rework selinux setup
Move the selinux policy build to before 'write_contents' and 'zero free space' are done so that the selinux modules are included in those operations. Also apply the selinux file lables as needed. Signed-off-by: Geoff Levand <[email protected]>
1 parent b2fb3ea commit 91c7555

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

build_library/build_image_util.sh

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -506,6 +506,16 @@ EOF
506506
"${BUILD_DIR}/${image_kconfig}"
507507
fi
508508

509+
# Build the selinux policy and apply file labels.
510+
if pkg_use_enabled coreos-base/coreos selinux; then
511+
setup_qemu_static "${root_fs_dir}"
512+
sudo chroot "${root_fs_dir}" /bin/bash << 'EOF'
513+
(cd /usr/share/selinux/mcs && semodule -s mcs -i *.pp)
514+
setfiles -F /usr/lib/selinux/mcs/contexts/files/file_contexts /usr/lib/modules
515+
EOF
516+
clean_qemu_static "${root_fs_dir}"
517+
fi
518+
509519
write_contents "${root_fs_dir}" "${BUILD_DIR}/${image_contents}"
510520

511521
# Zero all fs free space to make it more compressible so auto-update
@@ -515,13 +525,6 @@ EOF
515525
sudo fstrim "${root_fs_dir}/usr" || true
516526
fi
517527

518-
# Build the selinux policy
519-
if pkg_use_enabled coreos-base/coreos selinux; then
520-
setup_qemu_static "${root_fs_dir}"
521-
sudo chroot "${root_fs_dir}" bash -c "cd /usr/share/selinux/mcs && semodule -s mcs -i *.pp"
522-
clean_qemu_static "${root_fs_dir}"
523-
fi
524-
525528
# Make the filesystem un-mountable as read-write and setup verity.
526529
if [[ ${disable_read_write} -eq ${FLAGS_TRUE} ]]; then
527530
# Unmount /usr partition

0 commit comments

Comments
 (0)