[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v2 2/5] virtiofsd: create lock/pid file in per user cache dir
From: |
Dr. David Alan Gilbert |
Subject: |
Re: [PATCH v2 2/5] virtiofsd: create lock/pid file in per user cache dir |
Date: |
Fri, 7 Aug 2020 18:34:30 +0100 |
User-agent: |
Mutt/1.14.6 (2020-07-11) |
* Vivek Goyal (vgoyal@redhat.com) wrote:
> Right now we create lock/pid file in /usr/local/var/... and unprivliged
> user does not have access to create files there.
I *think* the /usr/local there is coming from the build config of your
qemu; but I'm not 100% sure whether it's just it's --preifx
> Hence, in unprivileged mode, create this file in per user cache dir
> as specified by environment variable XDG_RUNTIME_DIR.
Yes; it's interesting that qemu daemons are somewhat inconsistent in
this; most of them ask for a --pidfile to say where you want it;
but not all.
> Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
> ---
> tools/virtiofsd/fuse_virtio.c | 15 ++++++++++++++-
> 1 file changed, 14 insertions(+), 1 deletion(-)
>
> diff --git a/tools/virtiofsd/fuse_virtio.c b/tools/virtiofsd/fuse_virtio.c
> index 6b21a93841..1551a94757 100644
> --- a/tools/virtiofsd/fuse_virtio.c
> +++ b/tools/virtiofsd/fuse_virtio.c
> @@ -972,8 +972,21 @@ static bool fv_socket_lock(struct fuse_session *se)
> g_autofree gchar *pidfile = NULL;
> g_autofree gchar *dir = NULL;
> Error *local_err = NULL;
> + gboolean unprivileged = false;
>
> - dir = qemu_get_local_state_pathname("run/virtiofsd");
> + if (geteuid() != 0)
> + unprivileged = true;
Note qemu style guides need {'s on that.
> + /*
> + * Unpriviliged users don't have access to /usr/local/var. Hence
> + * store lock/pid file in per user cache directory. Use environment
> + * variable XDG_RUNTIME_DIR.
> + */
> + if (unprivileged) {
> + dir = g_strdup_printf("%s/virtiofsd", g_get_user_runtime_dir());
> + } else {
> + dir = qemu_get_local_state_pathname("run/virtiofsd");
> + }
Yeh that's OK, so with the { fixed;
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
A few other possible thoughts:
a) Just always use g_get_runtime_dir as the top; even for root - it
seems to come out as /root/.cache for root, which isn't terrible.
b) Maybe put this code in qemu_get_local_state_pathname?
Dave
>
> if (g_mkdir_with_parents(dir, S_IRWXU) < 0) {
> fuse_log(FUSE_LOG_ERR, "%s: Failed to create directory %s: %s",
> --
> 2.25.4
>
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Re: [PATCH v2 2/5] virtiofsd: create lock/pid file in per user cache dir,
Dr. David Alan Gilbert <=