From 5939fb525c3cd5967c53a5656030940ddd7c1132 Mon Sep 17 00:00:00 2001 From: "Dustin C. Hatch" Date: Thu, 9 Mar 2023 09:36:20 -0600 Subject: [PATCH] init-storage: Use a static path as mount point There's no particular reason why the directory used as the temporary mount point for the data volume needs to be random. Using a static name, on the other hand, makes it easier for the SELinux policy to apply the correct type transition and ensure the directory is labelled correctly. --- overlay/usr/libexec/init-storage | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/overlay/usr/libexec/init-storage b/overlay/usr/libexec/init-storage index be18b33..1e963c4 100755 --- a/overlay/usr/libexec/init-storage +++ b/overlay/usr/libexec/init-storage @@ -15,8 +15,8 @@ copy_var() { dev="$1" echo 'Copying /var contents to data volume' - mount -o subvol=var "${dev}" "${tmpdir}" - cp -auv /var/. "${tmpdir}" + mount -o subvol=var "${dev}" "${tmpdir}" || exit + cp -auv /var/. "${tmpdir}" || exit umount "${tmpdir}" } @@ -46,7 +46,8 @@ else fi trap cleanup INT TERM QUIT EXIT -tmpdir=$(mktemp -d -p /run storinit.XXXXXX) +tmpdir=/run/storinit +mkdir -p "${tmpdir}" if ! has_fs "${datapart}"; then format_dev "${datapart}"