[PATCH] qemuConnectMonitor: do not mask SELinux failure

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



coverity spotted the expressions that could never be true:
(a && b && c) < 0.  Here's the fix:


>From 6d61d90a6df81900f4b2be752403758175000973 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering@xxxxxxxxxx>
Date: Tue, 13 Jul 2010 15:15:04 -0500
Subject: [PATCH] qemuConnectMonitor: fix a bug that would have masked SELinux failure

* src/qemu/qemu_driver.c (qemuConnectMonitor): Correct erroneous
parenthesization in two expressions.  Without this fix, failure
to set or clear SELinux security context in the monitor would go
undiagnosed.  Also correct a diagnostic and split some long lines.
---
 src/qemu/qemu_driver.c |   20 ++++++++++++--------
 1 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 487bfa3..96277cd 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -1194,10 +1194,12 @@ qemuConnectMonitor(struct qemud_driver *driver, virDomainObjPtr vm)
     qemuDomainObjPrivatePtr priv = vm->privateData;
     int ret = -1;

-    if ((driver->securityDriver &&
-         driver->securityDriver->domainSetSecuritySocketLabel &&
-         driver->securityDriver->domainSetSecuritySocketLabel(driver->securityDriver,vm)) < 0) {
-        VIR_ERROR(_("Failed to set security context for monitor for %s"), vm->def->name);
+    if (driver->securityDriver &&
+        driver->securityDriver->domainSetSecuritySocketLabel &&
+        driver->securityDriver->domainSetSecuritySocketLabel
+          (driver->securityDriver,vm) < 0) {
+        VIR_ERROR(_("Failed to set security context for monitor for %s"),
+                  vm->def->name);
         goto error;
     }

@@ -1213,10 +1215,12 @@ qemuConnectMonitor(struct qemud_driver *driver, virDomainObjPtr vm)
     if (priv->mon == NULL)
         virDomainObjUnref(vm);

-    if ((driver->securityDriver &&
-         driver->securityDriver->domainClearSecuritySocketLabel &&
-         driver->securityDriver->domainClearSecuritySocketLabel(driver->securityDriver,vm)) < 0) {
-        VIR_ERROR(_("Failed to set security context for monitor for %s"), vm->def->name);
+    if (driver->securityDriver &&
+        driver->securityDriver->domainClearSecuritySocketLabel &&
+        driver->securityDriver->domainClearSecuritySocketLabel
+          (driver->securityDriver,vm) < 0) {
+        VIR_ERROR(_("Failed to clear security context for monitor for %s"),
+                  vm->def->name);
         goto error;
     }

--
1.7.1.460.gf3c4c

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]