]> xenbits.xensource.com Git - libvirt.git/commitdiff
Block all use of libvirt.so in setuid programs
authorDaniel P. Berrange <berrange@redhat.com>
Thu, 10 Oct 2013 16:45:14 +0000 (17:45 +0100)
committerDaniel P. Berrange <berrange@redhat.com>
Mon, 21 Oct 2013 13:03:52 +0000 (14:03 +0100)
Avoid people introducing security flaws in their apps by
forbidding the use of libvirt.so in setuid programs, with
a check in virInitialize.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
src/libvirt.c

index 96d8fdca39377b722606ff03f8e8649312a4a3c4..d76e537c7f6cd6eb3497bd65ce33db2cc484643b 100644 (file)
@@ -409,6 +409,14 @@ virGlobalInit(void)
         virErrorInitialize() < 0)
         goto error;
 
+#ifndef IN_VIRT_LOGIN_SHELL
+    if (virIsSUID()) {
+        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                       _("libvirt.so is not safe to use from setuid programs"));
+        goto error;
+    }
+#endif
+
 #ifdef WITH_GNUTLS_GCRYPT
     /*
      * This sequence of API calls it copied exactly from