[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Mounting /sys within libselinux?



Hi guys,

Since selinux_init_load_policy tries to mount the selinuxfs on
/sys/fs/selinux, it of course fails when /sys is not available yet. It
currently falls back to /selinux then, but what about just mounting /sys
there?

Something akin to the following?

Wkr,
	Sven Vermeulen


diff -ur libselinux-2.1.9.orig/src/load_policy.c libselinux-2.1.9/src/load_policy.c
--- libselinux-2.1.9.orig/src/load_policy.c	2012-05-05 10:33:06.130719282 +0200
+++ libselinux-2.1.9/src/load_policy.c	2012-05-05 10:43:45.024720646 +0200
@@ -370,8 +370,16 @@
 	 * mount it if present for use in the calls below.  
 	 */
 	char *mntpoint = NULL;
-	if (mount(SELINUXFS, SELINUXMNT, SELINUXFS, 0, 0) == 0 || errno == EBUSY) {
-		mntpoint = SELINUXMNT;
+	/* First make sure /sys is mounted */
+	if (mount("sysfs", "/sys", "sysfs", 0, 0) == 0 || errno == EBUSY) {
+		if (mount(SELINUXFS, SELINUXMNT, SELINUXFS, 0, 0) == 0 || errno == EBUSY) {
+			mntpoint = SELINUXMNT;
+		} else {
+			/* check old mountpoint */
+			if (mount(SELINUXFS, OLDSELINUXMNT, SELINUXFS, 0, 0) == 0 || errno == EBUSY) {
+				mntpoint = OLDSELINUXMNT;
+			}
+		}
 	} else {
 		/* check old mountpoint */
 		if (mount(SELINUXFS, OLDSELINUXMNT, SELINUXFS, 0, 0) == 0 || errno == EBUSY) {

--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to majordomo@xxxxxxxxxxxxx with
the words "unsubscribe selinux" without quotes as the message.


[Fedora Users]     [Fedora Legacy]     [Fedora Desktop]     [Yosemite Photos]     [Yosemite News]     [Yosemite Campsites]     [KDE Users]     [Gnome Users]

Powered by Linux