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.
This commit is contained in:
2023-03-09 09:36:20 -06:00
parent c97c7f565b
commit 5939fb525c

View File

@@ -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}"