[libvirt] [PATCH 1/1] Fuse file system mounted at /proc/meminfo needs correct label.

dwalsh at redhat.com dwalsh at redhat.com
Wed Apr 24 13:00:06 UTC 2013


From: Dan Walsh <dwalsh at redhat.com>

Currently the /proc/meminfo is labeled fusefs_t rather then proc_t.
SELinux blocks openshift instances from reading fusefs_t, this
patch sets the file to the default label of /proc/meminfo
---
 src/lxc/lxc_container.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/src/lxc/lxc_container.c b/src/lxc/lxc_container.c
index ac0f69c..bba2e3a 100644
--- a/src/lxc/lxc_container.c
+++ b/src/lxc/lxc_container.c
@@ -52,6 +52,10 @@
 # include <blkid/blkid.h>
 #endif
 
+#if WITH_SELINUX
+# include <selinux/selinux.h>
+#endif
+
 #include "virerror.h"
 #include "virlog.h"
 #include "lxc_container.h"
@@ -763,6 +767,26 @@ static int lxcContainerMountProcFuse(virDomainDefPtr def,
                            def->name)) < 0)
         return ret;
 
+#if WITH_SELINUX
+    if (is_selinux_enabled() > 0) {
+        security_context_t scon;
+        ret = getfilecon("/proc/meminfo", &scon);
+        if (ret) {
+            virReportSystemError(errno,
+                                 _("Failed to get security context of %s for /proc/meminfo mount point"),
+                                 meminfo_path);
+            return ret;
+        }
+        ret = setfilecon(meminfo_path, scon);
+        freecon(scon);
+        if (ret) {
+            virReportSystemError(errno,
+                                 _("Failed to set security context of %s for /proc/meminfo mount point"),
+                                 meminfo_path);
+            return ret;
+        }
+    }
+#endif
     if ((ret = mount(meminfo_path, "/proc/meminfo",
                      NULL, MS_BIND, NULL)) < 0) {
         virReportSystemError(errno,
-- 
1.8.2




More information about the libvir-list mailing list