From 7566819139e31c95038f9f1c39a2995d1fc93c17 Mon Sep 17 00:00:00 2001 From: Olivier Bourdon Date: Sat, 7 Apr 2018 14:36:59 +0200 Subject: [PATCH] Fix CentOS image build failure when dib runs on system where audit disabled Without this fix, building a CentOS image on Ubuntu where audit=0 is passed as a kernel boot parameter will lead to the following error: disk-image-create centos7 dhcp-all-interfaces cloud-init-nocloud \ devuser yum epel baremetal ... dib-run-parts Running tmpdir/hooks/cleanup.d/99-selinux-fixfiles-restore ... Error connecting to audit system. Change-Id: I229d9b72f88bffddca42da57f01c27e902427071 --- .../elements/rpm-distro/cleanup.d/99-selinux-fixfiles-restore | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/diskimage_builder/elements/rpm-distro/cleanup.d/99-selinux-fixfiles-restore b/diskimage_builder/elements/rpm-distro/cleanup.d/99-selinux-fixfiles-restore index b13e98f74..3d259bdf2 100755 --- a/diskimage_builder/elements/rpm-distro/cleanup.d/99-selinux-fixfiles-restore +++ b/diskimage_builder/elements/rpm-distro/cleanup.d/99-selinux-fixfiles-restore @@ -66,6 +66,10 @@ fi IFS='|' read -ra SPLIT_MOUNTS <<< "$DIB_MOUNTPOINTS" for MOUNTPOINT in "${SPLIT_MOUNTS[@]}"; do if [ "${MOUNTPOINT}" != "/tmp/in_target.d" ] && [ "${MOUNTPOINT}" != "/dev" ] && [ "${MOUNTPOINT}" != "/boot/efi" ]; then + if ! pgrep kauditd >/dev/null; then + echo "*** kauditd not found, suggesting auditing support is disabled in the host kernel. setfiles will fail without this, please enable and rebuild" + exit 1 + fi sudo ${_runcon} chroot ${TARGET_ROOT} \ /usr/sbin/setfiles -F ${_dash_m} \ /etc/selinux/targeted/contexts/files/file_contexts ${MOUNTPOINT}