[libvirt] [PATCH] qemu: fix up permissions for pre-created UNIX sockets

Ján Tomko posted 1 patch 5 years, 5 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/cfb9955b7f22932d315a3560b864c2a53be8719c.1538570612.git.jtomko@redhat.com
src/qemu/qemu_command.c | 6 ++++++
1 file changed, 6 insertions(+)
[libvirt] [PATCH] qemu: fix up permissions for pre-created UNIX sockets
Posted by Ján Tomko 5 years, 5 months ago
My commit d6b8838 fixed the uid:gid for the pre-created UNIX sockets
but did not account for the different umask of libvirtd and QEMU.
Since commit 0e1a1a8c we set umask to '0002' for the QEMU process.
Manually tune-up the permissions to match what we would have gotten
if QEMU had created the socket.

https://bugzilla.redhat.com/show_bug.cgi?id=1633389

Signed-off-by: Ján Tomko <jtomko@redhat.com>
---
 src/qemu/qemu_command.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 887947dc11..d77cf8c2d6 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -5034,6 +5034,12 @@ qemuOpenChrChardevUNIXSocket(const virDomainChrSourceDef *dev)
         goto error;
     }
 
+    /* We run QEMU with umask 0002. Compensate for the umask
+     * libvirtd might be running under to get the same permission
+     * QEMU would have. */
+    if (virFileUpdatePerm(dev->data.nix.path, 0002, 0664) < 0)
+        goto error;
+
     return fd;
 
  error:
-- 
2.17.1

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] qemu: fix up permissions for pre-created UNIX sockets
Posted by Jiri Denemark 5 years, 5 months ago
On Wed, Oct 03, 2018 at 14:44:28 +0200, Ján Tomko wrote:
> My commit d6b8838 fixed the uid:gid for the pre-created UNIX sockets
> but did not account for the different umask of libvirtd and QEMU.
> Since commit 0e1a1a8c we set umask to '0002' for the QEMU process.
> Manually tune-up the permissions to match what we would have gotten
> if QEMU had created the socket.
> 
> https://bugzilla.redhat.com/show_bug.cgi?id=1633389
> 
> Signed-off-by: Ján Tomko <jtomko@redhat.com>
> ---
>  src/qemu/qemu_command.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
> index 887947dc11..d77cf8c2d6 100644
> --- a/src/qemu/qemu_command.c
> +++ b/src/qemu/qemu_command.c
> @@ -5034,6 +5034,12 @@ qemuOpenChrChardevUNIXSocket(const virDomainChrSourceDef *dev)
>          goto error;
>      }
>  
> +    /* We run QEMU with umask 0002. Compensate for the umask
> +     * libvirtd might be running under to get the same permission
> +     * QEMU would have. */
> +    if (virFileUpdatePerm(dev->data.nix.path, 0002, 0664) < 0)
> +        goto error;
> +

The virFileUpdatePerm API is a very interesting one...

>      return fd;
>  
>   error:

Reviewed-by: Jiri Denemark <jdenemar@redhat.com>

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