[PATCH 1/1] Checking the value returned by the function

Sergey Mironov mironov at fintech.ru
Wed Oct 11 14:31:55 UTC 2023


In version 0.10.0-rc0 (https://github.com/libvirt/libvirt/blob/v0.10.0-rc0/src/security/security_selinux.c ) 11 years ago,
the virSecuritySELinuxSetFileconHelper function appeared, which returned 1 if the optional is true.
Considering that at the moment the virSecuritySELinuxSetFilecon function (by definition) can only return 0 or -1, I suggest removing the "dead code" in the current patch.

Co-developed-by: sdl.qemu <sdl.qemu at linuxtesting.org>
Signed-off-by: Sergey Mironov <mironov at fintech.ru>
---
 src/security/security_selinux.c | 11 -----------
 1 file changed, 11 deletions(-)

diff --git a/src/security/security_selinux.c b/src/security/security_selinux.c
index 7914aba84d..a7abab9cf8 100644
--- a/src/security/security_selinux.c
+++ b/src/security/security_selinux.c
@@ -1988,17 +1988,6 @@ virSecuritySELinuxSetImageLabelInternal(virSecurityManager *mgr,
         ret = virSecuritySELinuxSetFilecon(mgr, path, use_label, remember);
     }
 
-    if (ret == 1 && !disk_seclabel) {
-        /* If we failed to set a label, but virt_use_nfs let us
-         * proceed anyway, then we don't need to relabel later.  */
-        disk_seclabel = virSecurityDeviceLabelDefNew(SECURITY_SELINUX_NAME);
-        if (!disk_seclabel)
-            return -1;
-        disk_seclabel->labelskip = true;
-        VIR_APPEND_ELEMENT(src->seclabels, src->nseclabels, disk_seclabel);
-        ret = 0;
-    }
-
     return ret;
 }
 
-- 
2.31.1



More information about the libvir-list mailing list