All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] virtiofsd: Fix check of chown()'s return value
@ 2021-05-07 16:12 Greg Kurz
  2021-05-07 16:19 ` Eric Blake
  2021-05-10 14:16 ` Dr. David Alan Gilbert
  0 siblings, 2 replies; 6+ messages in thread
From: Greg Kurz @ 2021-05-07 16:12 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-trivial, Dr. David Alan Gilbert

Otherwise you always get this warning when using --socket-group=users

 vhost socket failed to set group to users (100)

While here, print out the error if chown() fails.

Signed-off-by: Greg Kurz <groug@kaod.org>
---
 tools/virtiofsd/fuse_virtio.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/virtiofsd/fuse_virtio.c b/tools/virtiofsd/fuse_virtio.c
index 3e13997406bf..638d3ffe2f8a 100644
--- a/tools/virtiofsd/fuse_virtio.c
+++ b/tools/virtiofsd/fuse_virtio.c
@@ -978,9 +978,9 @@ static int fv_create_listen_socket(struct fuse_session *se)
     if (se->vu_socket_group) {
         struct group *g = getgrnam(se->vu_socket_group);
         if (g) {
-            if (!chown(se->vu_socket_path, -1, g->gr_gid)) {
+            if (chown(se->vu_socket_path, -1, g->gr_gid) == -1) {
                 fuse_log(FUSE_LOG_WARNING,
-                         "vhost socket failed to set group to %s (%d)\n",
+                         "vhost socket failed to set group to %s (%d): %m\n",
                          se->vu_socket_group, g->gr_gid);
             }
         }




^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] virtiofsd: Fix check of chown()'s return value
  2021-05-07 16:12 [PATCH] virtiofsd: Fix check of chown()'s return value Greg Kurz
@ 2021-05-07 16:19 ` Eric Blake
  2021-05-07 16:34   ` Greg Kurz
  2021-05-10 14:16 ` Dr. David Alan Gilbert
  1 sibling, 1 reply; 6+ messages in thread
From: Eric Blake @ 2021-05-07 16:19 UTC (permalink / raw)
  To: Greg Kurz, qemu-devel; +Cc: qemu-trivial, Dr. David Alan Gilbert

On 5/7/21 11:12 AM, Greg Kurz wrote:
> Otherwise you always get this warning when using --socket-group=users
> 
>  vhost socket failed to set group to users (100)
> 
> While here, print out the error if chown() fails.
> 
> Signed-off-by: Greg Kurz <groug@kaod.org>
> ---
>  tools/virtiofsd/fuse_virtio.c |    4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/tools/virtiofsd/fuse_virtio.c b/tools/virtiofsd/fuse_virtio.c
> index 3e13997406bf..638d3ffe2f8a 100644
> --- a/tools/virtiofsd/fuse_virtio.c
> +++ b/tools/virtiofsd/fuse_virtio.c
> @@ -978,9 +978,9 @@ static int fv_create_listen_socket(struct fuse_session *se)
>      if (se->vu_socket_group) {
>          struct group *g = getgrnam(se->vu_socket_group);
>          if (g) {
> -            if (!chown(se->vu_socket_path, -1, g->gr_gid)) {
> +            if (chown(se->vu_socket_path, -1, g->gr_gid) == -1) {
>                  fuse_log(FUSE_LOG_WARNING,
> -                         "vhost socket failed to set group to %s (%d)\n",
> +                         "vhost socket failed to set group to %s (%d): %m\n",

Is %m portable?  POSIX requires it for syslog, but not for printf (where
glibc has it as an extension), but I'm not sure what fuse_log supports.
Best might be a manual %s/strerror(errno)

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] virtiofsd: Fix check of chown()'s return value
  2021-05-07 16:19 ` Eric Blake
@ 2021-05-07 16:34   ` Greg Kurz
  0 siblings, 0 replies; 6+ messages in thread
From: Greg Kurz @ 2021-05-07 16:34 UTC (permalink / raw)
  To: Eric Blake; +Cc: qemu-trivial, qemu-devel, Dr. David Alan Gilbert

On Fri, 7 May 2021 11:19:07 -0500
Eric Blake <eblake@redhat.com> wrote:

> On 5/7/21 11:12 AM, Greg Kurz wrote:
> > Otherwise you always get this warning when using --socket-group=users
> > 
> >  vhost socket failed to set group to users (100)
> > 
> > While here, print out the error if chown() fails.
> > 
> > Signed-off-by: Greg Kurz <groug@kaod.org>
> > ---
> >  tools/virtiofsd/fuse_virtio.c |    4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> > 
> > diff --git a/tools/virtiofsd/fuse_virtio.c b/tools/virtiofsd/fuse_virtio.c
> > index 3e13997406bf..638d3ffe2f8a 100644
> > --- a/tools/virtiofsd/fuse_virtio.c
> > +++ b/tools/virtiofsd/fuse_virtio.c
> > @@ -978,9 +978,9 @@ static int fv_create_listen_socket(struct fuse_session *se)
> >      if (se->vu_socket_group) {
> >          struct group *g = getgrnam(se->vu_socket_group);
> >          if (g) {
> > -            if (!chown(se->vu_socket_path, -1, g->gr_gid)) {
> > +            if (chown(se->vu_socket_path, -1, g->gr_gid) == -1) {
> >                  fuse_log(FUSE_LOG_WARNING,
> > -                         "vhost socket failed to set group to %s (%d)\n",
> > +                         "vhost socket failed to set group to %s (%d): %m\n",
> 
> Is %m portable?  POSIX requires it for syslog, but not for printf (where
> glibc has it as an extension), but I'm not sure what fuse_log supports.
> Best might be a manual %s/strerror(errno)
> 

virtiofsd is for linux+glibc only and %m is already used a few lines
above in the same function.



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] virtiofsd: Fix check of chown()'s return value
  2021-05-07 16:12 [PATCH] virtiofsd: Fix check of chown()'s return value Greg Kurz
  2021-05-07 16:19 ` Eric Blake
@ 2021-05-10 14:16 ` Dr. David Alan Gilbert
  2021-05-10 14:23   ` Greg Kurz
  1 sibling, 1 reply; 6+ messages in thread
From: Dr. David Alan Gilbert @ 2021-05-10 14:16 UTC (permalink / raw)
  To: Greg Kurz; +Cc: qemu-trivial, qemu-devel

* Greg Kurz (groug@kaod.org) wrote:
> Otherwise you always get this warning when using --socket-group=users
> 
>  vhost socket failed to set group to users (100)
> 
> While here, print out the error if chown() fails.
> 
> Signed-off-by: Greg Kurz <groug@kaod.org>

probably needs a fixes:  but yes.

Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>

> ---
>  tools/virtiofsd/fuse_virtio.c |    4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/tools/virtiofsd/fuse_virtio.c b/tools/virtiofsd/fuse_virtio.c
> index 3e13997406bf..638d3ffe2f8a 100644
> --- a/tools/virtiofsd/fuse_virtio.c
> +++ b/tools/virtiofsd/fuse_virtio.c
> @@ -978,9 +978,9 @@ static int fv_create_listen_socket(struct fuse_session *se)
>      if (se->vu_socket_group) {
>          struct group *g = getgrnam(se->vu_socket_group);
>          if (g) {
> -            if (!chown(se->vu_socket_path, -1, g->gr_gid)) {
> +            if (chown(se->vu_socket_path, -1, g->gr_gid) == -1) {
>                  fuse_log(FUSE_LOG_WARNING,
> -                         "vhost socket failed to set group to %s (%d)\n",
> +                         "vhost socket failed to set group to %s (%d): %m\n",
>                           se->vu_socket_group, g->gr_gid);
>              }
>          }
> 
> 
-- 
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] virtiofsd: Fix check of chown()'s return value
  2021-05-10 14:16 ` Dr. David Alan Gilbert
@ 2021-05-10 14:23   ` Greg Kurz
  2021-05-13 15:49     ` Laurent Vivier
  0 siblings, 1 reply; 6+ messages in thread
From: Greg Kurz @ 2021-05-10 14:23 UTC (permalink / raw)
  To: Dr. David Alan Gilbert; +Cc: qemu-trivial, qemu-devel

On Mon, 10 May 2021 15:16:23 +0100
"Dr. David Alan Gilbert" <dgilbert@redhat.com> wrote:

> * Greg Kurz (groug@kaod.org) wrote:
> > Otherwise you always get this warning when using --socket-group=users
> > 
> >  vhost socket failed to set group to users (100)
> > 
> > While here, print out the error if chown() fails.
> > 
> > Signed-off-by: Greg Kurz <groug@kaod.org>
> 
> probably needs a fixes:  but yes.
> 

Fixes: f6698f2b03b0 ("tools/virtiofsd: add support for --socket-group")

> Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
> 
> > ---
> >  tools/virtiofsd/fuse_virtio.c |    4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> > 
> > diff --git a/tools/virtiofsd/fuse_virtio.c b/tools/virtiofsd/fuse_virtio.c
> > index 3e13997406bf..638d3ffe2f8a 100644
> > --- a/tools/virtiofsd/fuse_virtio.c
> > +++ b/tools/virtiofsd/fuse_virtio.c
> > @@ -978,9 +978,9 @@ static int fv_create_listen_socket(struct fuse_session *se)
> >      if (se->vu_socket_group) {
> >          struct group *g = getgrnam(se->vu_socket_group);
> >          if (g) {
> > -            if (!chown(se->vu_socket_path, -1, g->gr_gid)) {
> > +            if (chown(se->vu_socket_path, -1, g->gr_gid) == -1) {
> >                  fuse_log(FUSE_LOG_WARNING,
> > -                         "vhost socket failed to set group to %s (%d)\n",
> > +                         "vhost socket failed to set group to %s (%d): %m\n",
> >                           se->vu_socket_group, g->gr_gid);
> >              }
> >          }
> > 
> > 



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] virtiofsd: Fix check of chown()'s return value
  2021-05-10 14:23   ` Greg Kurz
@ 2021-05-13 15:49     ` Laurent Vivier
  0 siblings, 0 replies; 6+ messages in thread
From: Laurent Vivier @ 2021-05-13 15:49 UTC (permalink / raw)
  To: Greg Kurz, Dr. David Alan Gilbert; +Cc: qemu-trivial, qemu-devel

Le 10/05/2021 à 16:23, Greg Kurz a écrit :
> On Mon, 10 May 2021 15:16:23 +0100
> "Dr. David Alan Gilbert" <dgilbert@redhat.com> wrote:
> 
>> * Greg Kurz (groug@kaod.org) wrote:
>>> Otherwise you always get this warning when using --socket-group=users
>>>
>>>  vhost socket failed to set group to users (100)
>>>
>>> While here, print out the error if chown() fails.
>>>
>>> Signed-off-by: Greg Kurz <groug@kaod.org>
>>
>> probably needs a fixes:  but yes.
>>
> 
> Fixes: f6698f2b03b0 ("tools/virtiofsd: add support for --socket-group")
> 

Applied to my trivial-patches branch.

Thanks,
Laurent



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-05-13 15:51 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-07 16:12 [PATCH] virtiofsd: Fix check of chown()'s return value Greg Kurz
2021-05-07 16:19 ` Eric Blake
2021-05-07 16:34   ` Greg Kurz
2021-05-10 14:16 ` Dr. David Alan Gilbert
2021-05-10 14:23   ` Greg Kurz
2021-05-13 15:49     ` Laurent Vivier

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.