Skip to contentSkip to conversation

virtfs-proxy-helper: check return code of setfsgid/setfsuid

PATCH In review Paolo Bonzini 2 participants 2 messages Oct 10, 2012

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 virtfs-proxy-helper: check return code of setfsgid/setfsuid

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

---
 fsdev/virtfs-proxy-helper.c | 8 ++++++--

1 file modificato, 6 inserzioni(+), 2 rimozioni(-)

fsdev/virtfs-proxy-helper.c +6 -2
index f9a8270..9060743 100644
@@ -290,8 +290,12 @@ static int setfsugid(int uid, int gid)
         CAP_DAC_OVERRIDE,
     };
 
-    setfsgid(gid);
-    setfsuid(uid);
+    if (setfsgid(gid) < 0) {
+        return -1;
+    }
+    if (setfsuid(uid) < 0) {
+        return -1;
+    }
 
     if (uid != 0 || gid != 0) {
         return do_cap_set(cap_list, ARRAY_SIZE(cap_list), 0);
Signature · 1 line
1.7.12.1
#1 lore raw

Am 10.10.2012 18:19, schrieb Paolo Bonzini:

Quoted 21 lines

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

---
  fsdev/virtfs-proxy-helper.c | 8 ++++++--

1 file modificato, 6 inserzioni(+), 2 rimozioni(-)

fsdev/virtfs-proxy-helper.c +0 -1
index f9a8270..9060743 100644
@@ -290,8 +290,12 @@ static int setfsugid(int uid, int gid)
          CAP_DAC_OVERRIDE,
      };
 
-    setfsgid(gid);

fsdev/virtfs-proxy-helper.c static int setfsugid(int uid, int gid) · line 301

Quoted 10 lines
fsdev/virtfs-proxy-helper.c +6 -1
-    setfsuid(uid);
+    if (setfsgid(gid) < 0) {
+        return -1;
+    }
+    if (setfsuid(uid) < 0) {
+        return -1;
+    }
 
      if (uid != 0 || gid != 0) {
          return do_cap_set(cap_list, ARRAY_SIZE(cap_list), 0);

You are too fast for me :-)

Patch v3 is needed, see my other mail.

Stefan