]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
selinux: Don't fail RestoreAll if file doesn't have a default label
authorCole Robinson <crobinso@redhat.com>
Sat, 20 Oct 2012 19:57:28 +0000 (15:57 -0400)
committerCole Robinson <crobinso@redhat.com>
Sat, 27 Oct 2012 19:46:10 +0000 (15:46 -0400)
When restoring selinux labels after a VM is stopped, any non-standard
path that doesn't have a default selinux label causes the process
to stop and exit early. This isn't really an error condition IMO.

Of course the selinux API could be erroring for some other reason
but hopefully that's rare enough to not need explicit handling.

Common example here is storing disk images in a non-standard location
like under /mnt.
(cherry picked from commit 767be8be7226abe9a242c812ba5ff28108d2955c)

src/security/security_selinux.c

index 1e27e10f553139a2495298c041969c82ca1fc8e0..89bae7e8f681c32c902ba09101d9b5cb57ae9af8 100644 (file)
@@ -568,7 +568,11 @@ SELinuxRestoreSecurityFileLabel(const char *path)
     }
 
     if (getContext(newpath, buf.st_mode, &fcon) < 0) {
+        /* Any user created path likely does not have a default label,
+         * which makes this an expected non error
+         */
         VIR_WARN("cannot lookup default selinux label for %s", newpath);
+        rc = 0;
     } else {
         rc = SELinuxSetFilecon(newpath, fcon);
     }