From 0c4aec29b6bc9e0aa1e6bd999e32f4bf9d746d3e Mon Sep 17 00:00:00 2001 From: "Daniel P. Berrange" Date: Thu, 10 Oct 2013 17:45:14 +0100 Subject: [PATCH] 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) --- src/libvirt.c | 8 ++++++++ 1 file changed, 8 insertions(+) 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 -- GitLab