init-storage: Copy file contexts from rootfs

Apparently, BusyBox's `cp` does NOT copy SELinux contexts when the `-a`
argument is specified.  This differs from GNU coreutils's `cp`, and
explains why the files copied from the rootfs image to the persistent
storage volume were not being labelled correctly.  The `-c` argument is
required.

Now that files are labelled correctly when they are copied, the step to
run `restorecon` is no longer necessary.
This commit is contained in:
2023-03-14 14:39:22 -05:00
parent 31d8a98f64
commit 292a4d2268
3 changed files with 32 additions and 16 deletions

View File

@@ -16,7 +16,7 @@ copy_var() {
echo 'Copying /var contents to data volume'
mount -o subvol=var "${dev}" "${tmpdir}" || exit
cp -auv /var/. "${tmpdir}" || exit
cp -acuv /var/. "${tmpdir}" || exit
umount "${tmpdir}"
}