diff mbox series

[27/30] security: selinux: Add is_toplevel to SetImageLabelInternal

Message ID 726ba82b9504505face29a83451f27a046635bcd.1570482718.git.crobinso@redhat.com
State Accepted
Commit a36d3b88d637c59d541aaa6c77ccf32f7a915826
Headers show
Series storagefile, security: qcow2 data_file support | expand

Commit Message

Cole Robinson Oct. 7, 2019, 9:49 p.m. UTC
This will simplify future patches and make the logic easier to follow

Signed-off-by: Cole Robinson <crobinso@redhat.com>

---
 src/security/security_selinux.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

-- 
2.23.0

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

Comments

Daniel Henrique Barboza Oct. 10, 2019, 4:07 p.m. UTC | #1
On 10/7/19 6:49 PM, Cole Robinson wrote:
> This will simplify future patches and make the logic easier to follow

>

> Signed-off-by: Cole Robinson <crobinso@redhat.com>

> ---



Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>



>   src/security/security_selinux.c | 5 +++--

>   1 file changed, 3 insertions(+), 2 deletions(-)

>

> diff --git a/src/security/security_selinux.c b/src/security/security_selinux.c

> index e384542c49..fd7dd080c1 100644

> --- a/src/security/security_selinux.c

> +++ b/src/security/security_selinux.c

> @@ -1824,6 +1824,7 @@ virSecuritySELinuxSetImageLabelInternal(virSecurityManagerPtr mgr,

>       virSecurityDeviceLabelDefPtr parent_seclabel = NULL;

>       char *use_label = NULL;

>       bool remember;

> +    bool is_toplevel = parent == src;

>       int ret;

>   

>       if (!src->path || !virStorageSourceIsLocalStorage(src))

> @@ -1845,7 +1846,7 @@ virSecuritySELinuxSetImageLabelInternal(virSecurityManagerPtr mgr,

>        * but the top layer, or read only image, or disk explicitly

>        * marked as shared.

>        */

> -    remember = src == parent && !src->readonly && !src->shared;

> +    remember = is_toplevel && !src->readonly && !src->shared;

>   

>       disk_seclabel = virStorageSourceGetSecurityLabelDef(src,

>                                                           SECURITY_SELINUX_NAME);

> @@ -1862,7 +1863,7 @@ virSecuritySELinuxSetImageLabelInternal(virSecurityManagerPtr mgr,

>               return 0;

>   

>           use_label = parent_seclabel->label;

> -    } else if (parent == src) {

> +    } else if (is_toplevel) {

>           if (src->shared) {

>               use_label = data->file_context;

>           } else if (src->readonly) {


--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
diff mbox series

Patch

diff --git a/src/security/security_selinux.c b/src/security/security_selinux.c
index e384542c49..fd7dd080c1 100644
--- a/src/security/security_selinux.c
+++ b/src/security/security_selinux.c
@@ -1824,6 +1824,7 @@  virSecuritySELinuxSetImageLabelInternal(virSecurityManagerPtr mgr,
     virSecurityDeviceLabelDefPtr parent_seclabel = NULL;
     char *use_label = NULL;
     bool remember;
+    bool is_toplevel = parent == src;
     int ret;
 
     if (!src->path || !virStorageSourceIsLocalStorage(src))
@@ -1845,7 +1846,7 @@  virSecuritySELinuxSetImageLabelInternal(virSecurityManagerPtr mgr,
      * but the top layer, or read only image, or disk explicitly
      * marked as shared.
      */
-    remember = src == parent && !src->readonly && !src->shared;
+    remember = is_toplevel && !src->readonly && !src->shared;
 
     disk_seclabel = virStorageSourceGetSecurityLabelDef(src,
                                                         SECURITY_SELINUX_NAME);
@@ -1862,7 +1863,7 @@  virSecuritySELinuxSetImageLabelInternal(virSecurityManagerPtr mgr,
             return 0;
 
         use_label = parent_seclabel->label;
-    } else if (parent == src) {
+    } else if (is_toplevel) {
         if (src->shared) {
             use_label = data->file_context;
         } else if (src->readonly) {