From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:36864) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TLyvn-0004Oa-2f for qemu-devel@nongnu.org; Wed, 10 Oct 2012 12:14:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TLyvf-0003LZ-B3 for qemu-devel@nongnu.org; Wed, 10 Oct 2012 12:14:47 -0400 Message-ID: <50759EEC.8070308@weilnetz.de> Date: Wed, 10 Oct 2012 18:14:36 +0200 From: Stefan Weil MIME-Version: 1.0 References: <1349868762-10021-1-git-send-email-pbonzini@redhat.com> In-Reply-To: <1349868762-10021-1-git-send-email-pbonzini@redhat.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH] virtfs-proxy-helper: check return code of setfsgid/setfsuid List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: qemu-trivial@nongnu.org, qemu-devel@nongnu.org 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 =E2=80=98setfsugid=E2=80=99: > virtfs-proxy-helper.c:293:13: error: ignoring return value of =E2=80=98= setfsgid=E2=80=99, declared with attribute warn_unused_result [-Werror=3D= unused-result] > virtfs-proxy-helper.c:294:13: error: ignoring return value of =E2=80=98= setfsuid=E2=80=99, declared with attribute warn_unused_result [-Werror=3D= unused-result] > cc1: all warnings being treated as errors > > Signed-off-by: Paolo Bonzini > --- > 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, > }; > =20 > - setfsgid(gid); > - setfsuid(uid); > + if (setfsgid(gid) !=3D 0) { > + return -1; > + } Wouldn't setfsgid(gid) =3D=3D 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) !=3D 0) { > + return -1; > + } > =20 The same question applies here. > if (uid !=3D 0 || gid !=3D 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