Support semanage.mods

Aimee OS variants can now supply a `semange.mods` file in their
configuration directories.  This file contains SELinux customizations,
in the format produced by `semanage export`.  Variants can use this
mechanism to set SELinux booleans, change user/login mappings, and other
SELinux policy customization.  At build time, the base `selinux.mods`
file in the source directory is combined with the variant's file, if it
exists, and the resultant customizations are applied in a single
transaction.
master
Dustin 2023-03-29 18:39:40 -05:00
parent a1999939eb
commit 02c3a12c08
3 changed files with 25 additions and 5 deletions

View File

@ -39,6 +39,11 @@ $(O)/.built: \
./build.sh ./build.sh
touch $(O)/.built touch $(O)/.built
$(O)/semanage.mods: \
semanage.mods \
$(wildcard $(CONFIGDIR)/semanage.mods)
cat $^ > $@
$(O)/.ready: \ $(O)/.ready: \
build-rootfs.sh \ build-rootfs.sh \
install.packages \ install.packages \
@ -46,11 +51,12 @@ $(O)/.ready: \
$(CONFIGDIR)/installonly.packages \ $(CONFIGDIR)/installonly.packages \
$(CONFIGDIR)/busybox.symlinks \ $(CONFIGDIR)/busybox.symlinks \
$(O)/linux/arch/arm64/boot/Image.gz \ $(O)/linux/arch/arm64/boot/Image.gz \
$(O)/semanage.mods \
$(shell find overlay -type f) \ $(shell find overlay -type f) \
$(shell find $(CONFIGDIR)/overlay -type f 2>/dev/null) \ $(shell find $(CONFIGDIR)/overlay -type f 2>/dev/null) \
$(O)/.host-tools \ $(O)/.host-tools \
$(O)/.built $(O)/.built
./build-rootfs.sh ./build-rootfs.sh "$(O)"
touch $(O)/.ready touch $(O)/.ready
$(O)/squashfs.exclude: \ $(O)/squashfs.exclude: \

View File

@ -5,6 +5,8 @@ set -e
. "${CONFIGDIR:=${PWD}}"/config . "${CONFIGDIR:=${PWD}}"/config
O="${1}"
mkdir -p \ mkdir -p \
/mnt/gentoo/usr/bin \ /mnt/gentoo/usr/bin \
/mnt/gentoo/usr/lib \ /mnt/gentoo/usr/lib \
@ -97,10 +99,7 @@ fi
unshare -m sh -e <<EOF unshare -m sh -e <<EOF
mount -o bind /mnt/gentoo/var/lib/selinux /var/lib/selinux mount -o bind /mnt/gentoo/var/lib/selinux /var/lib/selinux
mount -o bind /mnt/gentoo/etc/selinux /etc/selinux mount -o bind /mnt/gentoo/etc/selinux /etc/selinux
semanage boolean -N -m --on systemd_tmpfiles_manage_all semanage import -N -f "${O}"/semanage.mods
semanage boolean -N -m --on ssh_sysadm_login
semanage login -N -m -s root root
semanage user -N -m -R sysadm_r root
EOF EOF
setfiles \ setfiles \

15
semanage.mods Normal file
View File

@ -0,0 +1,15 @@
boolean -D
login -D
interface -D
user -D
port -D
node -D
fcontext -D
module -D
ibendport -D
ibpkey -D
permissive -D
boolean -m -1 ssh_sysadm_login
boolean -m -1 systemd_tmpfiles_manage_all
login -m -s root -r 's0-s0:c0.c1023' root
user -m -L s0 -r s0-s0:c0.c1023 -R 'sysadm_r' root