[30/30] security: selinux: Label externalDataStore

Message ID 94b8d03253117e2155925f69743cafca7e00d321.1570482718.git.crobinso@redhat.com
State Accepted
Commit 36138eaecf8920d843ca3b1cec38cc765369144c
Headers show
Series
  • storagefile, security: qcow2 data_file support
Related show

Commit Message

Cole Robinson Oct. 7, 2019, 9:49 p.m.
We mirror the labeling strategy that was used for its top image

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

---
 src/security/security_selinux.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

-- 
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:11 p.m. | #1
On 10/7/19 6:49 PM, Cole Robinson wrote:
> We mirror the labeling strategy that was used for its top image

>

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

> ---


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


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

>   1 file changed, 9 insertions(+), 1 deletion(-)

>

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

> index feb703d325..2a3b7fc10d 100644

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

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

> @@ -1844,7 +1844,7 @@ virSecuritySELinuxSetImageLabelInternal(virSecurityManagerPtr mgr,

>       virSecurityDeviceLabelDefPtr parent_seclabel = NULL;

>       char *use_label = NULL;

>       bool remember;

> -    bool is_toplevel = parent == src;

> +    bool is_toplevel = parent == src || parent->externalDataStore == src;

>       int ret;

>   

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

> @@ -1931,6 +1931,14 @@ virSecuritySELinuxSetImageLabelRelative(virSecurityManagerPtr mgr,

>           if (virSecuritySELinuxSetImageLabelInternal(mgr, def, n, parent) < 0)

>               return -1;

>   

> +        if (n->externalDataStore &&

> +            virSecuritySELinuxSetImageLabelRelative(mgr,

> +                                                    def,

> +                                                    n->externalDataStore,

> +                                                    parent,

> +                                                    flags) < 0)

> +            return -1;

> +

>           if (!(flags & VIR_SECURITY_DOMAIN_IMAGE_LABEL_BACKING_CHAIN))

>               break;

>       }


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

Patch

diff --git a/src/security/security_selinux.c b/src/security/security_selinux.c
index feb703d325..2a3b7fc10d 100644
--- a/src/security/security_selinux.c
+++ b/src/security/security_selinux.c
@@ -1844,7 +1844,7 @@  virSecuritySELinuxSetImageLabelInternal(virSecurityManagerPtr mgr,
     virSecurityDeviceLabelDefPtr parent_seclabel = NULL;
     char *use_label = NULL;
     bool remember;
-    bool is_toplevel = parent == src;
+    bool is_toplevel = parent == src || parent->externalDataStore == src;
     int ret;
 
     if (!src->path || !virStorageSourceIsLocalStorage(src))
@@ -1931,6 +1931,14 @@  virSecuritySELinuxSetImageLabelRelative(virSecurityManagerPtr mgr,
         if (virSecuritySELinuxSetImageLabelInternal(mgr, def, n, parent) < 0)
             return -1;
 
+        if (n->externalDataStore &&
+            virSecuritySELinuxSetImageLabelRelative(mgr,
+                                                    def,
+                                                    n->externalDataStore,
+                                                    parent,
+                                                    flags) < 0)
+            return -1;
+
         if (!(flags & VIR_SECURITY_DOMAIN_IMAGE_LABEL_BACKING_CHAIN))
             break;
     }