Skip to contentSkip to conversation

libselinux: helpful message when /selinux won't mount

PATCH In review Dax Kelson 4 participants 5 messages Apr 26, 2007 – Apr 27, 2007 SELinux security module

lore
Share & tools
lore

Dax Kelson

author
#0 lore raw

PATCH 1/1 libselinux: helpful message when /selinux won't mount

Last night a co-worker was trying to do a Phyical-2-Virtual (P2V) migration of a RHEL5 box.

During bootup, the following not-so-helpful message was seen:

"Unable to load SELinux Policy. Machine is in enforcing mode. Halting now."

I ran it down to the /selinux mount point not existing on the root filesystem, but the troubleshooting was more difficult than it should have been (it didn't help that it was a 3am).

Please consider the following trivial patch for inclusion into libselinux so that others may have an easier time if they happen into the same situation.

===================================================================

src/load_policy.c +1 -0
@@ -226,6 +226,7 @@
 			 */
 			*enforce = 0;
 		}
+		printf("Mount failed for selinuxfs on /selinux\n");
 		goto noload;
 	}
 	set_selinuxmnt(SELINUXMNT);

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

#1 lore raw
Quoted 22 lines · Dax Kelson

Last night a co-worker was trying to do a Phyical-2-Virtual (P2V) migration of a RHEL5 box.

During bootup, the following not-so-helpful message was seen:

"Unable to load SELinux Policy. Machine is in enforcing mode. Halting now."

I ran it down to the /selinux mount point not existing on the root filesystem, but the troubleshooting was more difficult than it should have been (it didn't help that it was a 3am).

Please consider the following trivial patch for inclusion into libselinux so that others may have an easier time if they happen into the same situation.

===================================================================

src/load_policy.c line 232

Quoted 7 lines
src/load_policy.c +1 -0
@@ -226,6 +226,7 @@
 			 */
 			*enforce = 0;
 		}
+		printf("Mount failed for selinuxfs on /selinux\n");
 		goto noload;
 	}
 	set_selinuxmnt(SELINUXMNT);

I'm fine with merging this for now, but I think we also likely want to introduce a similar error reporting facility into libselinux to match what we have in libsemanage and libsepol (e.g. see libsepol/include/sepol/debug.h and libsepol/src/debug.[hc]) to allow such messages to be handled in various ways by the caller. What do others think? One difference is that libselinux presently has no notion of handles.

Signature · 8 lines
Stephen Smalley
National Security Agency


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#2 lore raw
Quoted 31 lines · Stephen Smalley
Quoted 22 lines · Dax Kelson

Last night a co-worker was trying to do a Phyical-2-Virtual (P2V) migration of a RHEL5 box.

During bootup, the following not-so-helpful message was seen:

"Unable to load SELinux Policy. Machine is in enforcing mode. Halting now."

I ran it down to the /selinux mount point not existing on the root filesystem, but the troubleshooting was more difficult than it should have been (it didn't help that it was a 3am).

Please consider the following trivial patch for inclusion into libselinux so that others may have an easier time if they happen into the same situation.

===================================================================

src/load_policy.c line 232

Quoted 7 lines
src/load_policy.c +1 -0
@@ -226,6 +226,7 @@
 			 */
 			*enforce = 0;
 		}
+		printf("Mount failed for selinuxfs on /selinux\n");
 		goto noload;
 	}
 	set_selinuxmnt(SELINUXMNT);
Quoted 8 lines

I'm fine with merging this for now, but I think we also likely want to introduce a similar error reporting facility into libselinux to match what we have in libsemanage and libsepol (e.g. see libsepol/include/sepol/debug.h and libsepol/src/debug.[hc]) to allow such messages to be handled in various ways by the caller. What do others think? One difference is that libselinux presently has no notion of handles.

I'm not a huge fan of the handle thing - we don't really use it for much at the moment. I think just a global error reporting mechanism would be fine. That would give us the ERR, WARN, etc., macros and a way to change the level of output globally without having to rework the entire libselinux api to pass handles.

Karl

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

#3 lore raw
In reply to Stephen Smalley
Quoted 8 lines · Stephen Smalley

I'm fine with merging this for now, but I think we also likely want to introduce a similar error reporting facility into libselinux to match what we have in libsemanage and libsepol (e.g. see libsepol/include/sepol/debug.h and libsepol/src/debug.[hc]) to allow such messages to be handled in various ways by the caller. What do others think? One difference is that libselinux presently has no notion of handles.

libselinux does have the AVC logging callback.

It would be nice if these interfaces were consistent or even shared across all three libraries. The AVC logging callback needs to be changed anyway since it doesn't take a type code for passing to the audit framework.

Signature · 7 lines
Eamon Walsh <[email protected]>
National Security Agency

--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#4 lore raw
In reply to Dax Kelson
Quoted 22 lines · Dax Kelson

Last night a co-worker was trying to do a Phyical-2-Virtual (P2V) migration of a RHEL5 box.

During bootup, the following not-so-helpful message was seen:

"Unable to load SELinux Policy. Machine is in enforcing mode. Halting now."

I ran it down to the /selinux mount point not existing on the root filesystem, but the troubleshooting was more difficult than it should have been (it didn't help that it was a 3am).

Please consider the following trivial patch for inclusion into libselinux so that others may have an easier time if they happen into the same situation.

===================================================================

src/load_policy.c line 232

Quoted 7 lines
src/load_policy.c +1 -0
@@ -226,6 +226,7 @@
 			 */
 			*enforce = 0;
 		}
+		printf("Mount failed for selinuxfs on /selinux\n");
 		goto noload;
 	}
 	set_selinuxmnt(SELINUXMNT);

Merged, with the following diff on top of it to redirect to stderr and to provide more information. Shows up as the following message if you boot without a /selinux directory:
Mount failed for selinuxfs on /selinux: No such file or directory

src/load_policy.c +1 -1
Index: libselinux/src/load_policy.c
===================================================================
@@ -226,7 +226,7 @@
 			 */
 			*enforce = 0;
 		}
-		printf("Mount failed for selinuxfs on /selinux\n");
+		fprintf(stderr, "Mount failed for selinuxfs on %s:  %s\n", SELINUXMNT, strerror(errno));
 		goto noload;
 	}
 	set_selinuxmnt(SELINUXMNT);
Signature · 8 lines
Stephen Smalley
National Security Agency


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