From: Daniel P. Berrange Date: Thu, 10 Oct 2013 16:45:14 +0000 (+0100) Subject: Block all use of libvirt.so in setuid programs X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=0c4aec29b6bc9e0aa1e6bd999e32f4bf9d746d3e;p=thirdparty%2Flibvirt.git Block all use of libvirt.so in setuid programs 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 (cherry picked from commit 9cd6a57db6ea6762fbf85c59c379a27fa6e7fd2e) --- diff --git a/src/libvirt.c b/src/libvirt.c index dd07db6988..d4d7f71728 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -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