qemu_namespace: Only replicate labels on created files

Function qemuNamespaceMknodOne() is trying to replicate a file from the
parent namespace as perfectly as possible, with the same permissions,
labels, ACLs, etc.

If that file already existed it means that the qemu process is probably
using it already and the current setting is probably more correct than
the ones from the parent namespace.

In order to reflect that only replicate the file metadata when it was
(re-)created in this function.

Resolves: https://issues.redhat.com/browse/RHEL-62174
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
This commit is contained in:
Martin Kletzander 2024-10-15 15:12:55 +02:00
parent 26f249034d
commit f2710260d4

View File

@ -1090,6 +1090,7 @@ qemuNamespaceMknodOne(qemuNamespaceMknodItem *data)
goto cleanup;
}
if (!existed) {
if (lchown(data->file, data->sb.st_uid, data->sb.st_gid) < 0) {
virReportSystemError(errno,
_("Failed to chown device %1$s"),
@ -1127,6 +1128,7 @@ qemuNamespaceMknodOne(qemuNamespaceMknodItem *data)
}
}
# endif
}
/* Finish mount process started earlier. */
if ((isReg || isDir) &&