]> xenbits.xensource.com Git - libvirt.git/commitdiff
BSD: Ensure UNIX socket credentials are valid
authorDoug Goldstein <cardoe@cardoe.com>
Wed, 4 Sep 2013 17:21:45 +0000 (12:21 -0500)
committerDoug Goldstein <cardoe@cardoe.com>
Fri, 27 Sep 2013 16:16:35 +0000 (11:16 -0500)
Ensure that the socket credentials we got back on BSD are valid before
using them.

src/rpc/virnetsocket.c

index b311aae8c261d705792082190012c5ca77c1e276..49c6ddc6faadc1a127956677a479b198b6aaefcb 100644 (file)
@@ -1166,6 +1166,18 @@ int virNetSocketGetUNIXIdentity(virNetSocketPtr sock,
         return -1;
     }
 
+    if (cr.cr_version != XUCRED_VERSION) {
+        virReportError(VIR_ERR_SYSTEM_ERROR, "%s",
+                       _("Failed to get valid client socket identity"));
+        return -1;
+    }
+
+    if (cr.cr_ngroups == 0) {
+        virReportError(VIR_ERR_SYSTEM_ERROR, "%s",
+                       _("Failed to get valid client socket identity groups"));
+        return -1;
+    }
+
     *pid = -1;
     *uid = cr.cr_uid;
     *gid = cr.cr_gid;