Patchwork Fix build error in virtfs-proxy-helper

login
register
mail settings
Submitter Anthony Liguori
Date Nov. 1, 2012, 9:06 p.m.
Message ID <1351803990-12983-1-git-send-email-aliguori@us.ibm.com>
Download mbox | patch
Permalink /patch/196380/
State New
Headers show

Comments

Anthony Liguori - Nov. 1, 2012, 9:06 p.m.
I don't have a kernel with the necessary syscalls so this is completely
untested.

Cc: "M. Mohan Kumar" <mohan@in.ibm.com>
Cc: Gerhard Wiesinger <lists@wiesinger.com>
Reported-by: Gerhard Wiesinger <lists@wiesinger.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
---
 fsdev/virtfs-proxy-helper.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
Eric Blake - Nov. 1, 2012, 9:22 p.m.
On 11/01/2012 03:06 PM, Anthony Liguori wrote:
> I don't have a kernel with the necessary syscalls so this is completely
> untested.
> 
> Cc: "M. Mohan Kumar" <mohan@in.ibm.com>
> Cc: Gerhard Wiesinger <lists@wiesinger.com>
> Reported-by: Gerhard Wiesinger <lists@wiesinger.com>
> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
> ---
>  fsdev/virtfs-proxy-helper.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/fsdev/virtfs-proxy-helper.c b/fsdev/virtfs-proxy-helper.c
> index f9a8270..bc50e3e3 100644
> --- a/fsdev/virtfs-proxy-helper.c
> +++ b/fsdev/virtfs-proxy-helper.c
> @@ -286,12 +286,16 @@ static int setfsugid(int uid, int gid)
>       * We still need DAC_OVERRIDE because  we don't change
>       * supplementary group ids, and hence may be subjected DAC rules
>       */
> +    int ret;
>      cap_value_t cap_list[] = {
>          CAP_DAC_OVERRIDE,
>      };
>  
> -    setfsgid(gid);
> -    setfsuid(uid);
> +    ret = setfsgid(gid);
> +    g_assert(ret != -1);

This has been reported several times now, with several different patches
proposed.  Can we get consensus on which one to use?
https://lists.gnu.org/archive/html/qemu-devel/2012-10/msg02013.html

Patch

diff --git a/fsdev/virtfs-proxy-helper.c b/fsdev/virtfs-proxy-helper.c
index f9a8270..bc50e3e3 100644
--- a/fsdev/virtfs-proxy-helper.c
+++ b/fsdev/virtfs-proxy-helper.c
@@ -286,12 +286,16 @@  static int setfsugid(int uid, int gid)
      * We still need DAC_OVERRIDE because  we don't change
      * supplementary group ids, and hence may be subjected DAC rules
      */
+    int ret;
     cap_value_t cap_list[] = {
         CAP_DAC_OVERRIDE,
     };
 
-    setfsgid(gid);
-    setfsuid(uid);
+    ret = setfsgid(gid);
+    g_assert(ret != -1);
+
+    ret = setfsuid(uid);
+    g_assert(ret != -1);
 
     if (uid != 0 || gid != 0) {
         return do_cap_set(cap_list, ARRAY_SIZE(cap_list), 0);