aboutsummaryrefslogtreecommitdiffstats
path: root/classes/selinux-image.bbclass
blob: 5174dc5a6689e9d5119ba38746c502f8669a57a7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
selinux_set_labels () {
    POL_TYPE=$(sed -n -e "s&^SELINUXTYPE[[:space:]]*=[[:space:]]*\([0-9A-Za-z_]\+\)&\1&p" ${IMAGE_ROOTFS}/${sysconfdir}/selinux/config)
    if ! setfiles -m -r ${IMAGE_ROOTFS} ${IMAGE_ROOTFS}/${sysconfdir}/selinux/${POL_TYPE}/contexts/files/file_contexts ${IMAGE_ROOTFS}
    then
        echo WARNING: Unable to set filesystem context, setfiles / restorecon must be run on the live image.
        touch ${IMAGE_ROOTFS}/.autorelabel
        exit 0
    fi
}

DEPENDS += "policycoreutils-native"

IMAGE_PREPROCESS_COMMAND += "selinux_set_labels ;"

inherit core-image