[21/30] security: dac: Add is_toplevel to SetImageLabelInternal

Message ID 253129220c00b19e0ae28d9d0e84aea7c7645834.1570482718.git.crobinso@redhat.com
State Accepted
Commit c1f0b31267d075b01b69b2d0f36f651e17112fbb
Headers show
Series
  • storagefile, security: qcow2 data_file support
Related show

Commit Message

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

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

---
 src/security/security_dac.c | 3 ++-
 1 file changed, 2 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, 3:34 p.m. | #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_dac.c | 3 ++-

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

>

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

> index bcc781213e..6d0c8a9b1c 100644

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

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

> @@ -882,6 +882,7 @@ virSecurityDACSetImageLabelInternal(virSecurityManagerPtr mgr,

>       virSecurityDeviceLabelDefPtr parent_seclabel = NULL;

>       virSecurityDACDataPtr priv = virSecurityManagerGetPrivateData(mgr);

>       bool remember;

> +    bool is_toplevel = parent == src;

>       uid_t user;

>       gid_t group;

>   

> @@ -926,7 +927,7 @@ virSecurityDACSetImageLabelInternal(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;

>   

>       return virSecurityDACSetOwnership(mgr, src, NULL, user, group, remember);

>   }


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

Patch

diff --git a/src/security/security_dac.c b/src/security/security_dac.c
index bcc781213e..6d0c8a9b1c 100644
--- a/src/security/security_dac.c
+++ b/src/security/security_dac.c
@@ -882,6 +882,7 @@  virSecurityDACSetImageLabelInternal(virSecurityManagerPtr mgr,
     virSecurityDeviceLabelDefPtr parent_seclabel = NULL;
     virSecurityDACDataPtr priv = virSecurityManagerGetPrivateData(mgr);
     bool remember;
+    bool is_toplevel = parent == src;
     uid_t user;
     gid_t group;
 
@@ -926,7 +927,7 @@  virSecurityDACSetImageLabelInternal(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;
 
     return virSecurityDACSetOwnership(mgr, src, NULL, user, group, remember);
 }