qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Stefan Weil <sw@weilnetz.de>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: qemu-trivial@nongnu.org, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] virtfs-proxy-helper: check return code of setfsgid/setfsuid
Date: Wed, 10 Oct 2012 18:14:36 +0200	[thread overview]
Message-ID: <50759EEC.8070308@weilnetz.de> (raw)
In-Reply-To: <1349868762-10021-1-git-send-email-pbonzini@redhat.com>

Am 10.10.2012 13:32, schrieb Paolo Bonzini:
> Fixes the following error with glibc 2.16 on Fedora 18:
>
> virtfs-proxy-helper.c: In function ‘setfsugid’:
> virtfs-proxy-helper.c:293:13: error: ignoring return value of ‘setfsgid’, declared with attribute warn_unused_result [-Werror=unused-result]
> virtfs-proxy-helper.c:294:13: error: ignoring return value of ‘setfsuid’, declared with attribute warn_unused_result [-Werror=unused-result]
> cc1: all warnings being treated as errors
>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>   fsdev/virtfs-proxy-helper.c | 8 ++++++--
>   1 file modificato, 6 inserzioni(+), 2 rimozioni(-)
>
> diff --git a/fsdev/virtfs-proxy-helper.c b/fsdev/virtfs-proxy-helper.c
> index f9a8270..b34a84a 100644
> --- a/fsdev/virtfs-proxy-helper.c
> +++ b/fsdev/virtfs-proxy-helper.c
> @@ -290,8 +290,12 @@ static int setfsugid(int uid, int gid)
>           CAP_DAC_OVERRIDE,
>       };
>   
> -    setfsgid(gid);
> -    setfsuid(uid);
> +    if (setfsgid(gid) != 0) {
> +        return -1;
> +    }

Wouldn't setfsgid(gid) == gid be also ok?

I have no idea whether it is a realistic scenario to call
that function with a gid which is already set.


> +    if (setfsuid(uid) != 0) {
> +        return -1;
> +    }
>   

The same question applies here.

>       if (uid != 0 || gid != 0) {
>           return do_cap_set(cap_list, ARRAY_SIZE(cap_list), 0);

The Linux manpage for both functions says something
completely different. Extract from manpage of setfsuid:

"On success, the previous value of fsuid is returned.
  On error, the current value of fsuid is returned."

In reality, the functions return 0 when called by root.

Regards

Stefan

  reply	other threads:[~2012-10-10 16:14 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-10 11:32 [Qemu-devel] [PATCH] virtfs-proxy-helper: check return code of setfsgid/setfsuid Paolo Bonzini
2012-10-10 16:14 ` Stefan Weil [this message]
2012-10-10 16:17   ` Paolo Bonzini
2012-10-10 16:23     ` Stefan Weil
2012-10-10 16:36       ` Paolo Bonzini
2012-10-10 16:54         ` Stefan Weil
2012-10-10 16:59           ` Stefan Weil
2012-10-11  7:25             ` M. Mohan Kumar
2012-10-11 12:25               ` Paolo Bonzini
2012-12-04 18:55                 ` Aneesh Kumar K.V
2012-12-05  6:59                   ` M. Mohan Kumar
2012-12-05  8:35                   ` Aneesh Kumar K.V
2012-12-05 12:37                     ` Paolo Bonzini
2012-12-12 13:52                       ` Paolo Bonzini
2012-12-12 16:50                         ` Aneesh Kumar K.V
2012-10-10 17:00           ` Paolo Bonzini
2012-10-10 17:58     ` Eric Blake
2012-10-10 17:55 ` Eric Blake

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=50759EEC.8070308@weilnetz.de \
    --to=sw@weilnetz.de \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-trivial@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).