All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ivan Gyurdiev <ivg2@cornell.edu>
To: Joshua Brindle <jbrindle@tresys.com>
Cc: Chris PeBenito <pebenito@gentoo.org>,
	Stephen Smalley <sds@tycho.nsa.gov>,
	SELinux Mail List <selinux@tycho.nsa.gov>
Subject: Re: semanage non MLS breakage
Date: Sun, 19 Feb 2006 12:17:59 -0500	[thread overview]
Message-ID: <43F8A847.8010709@cornell.edu> (raw)
In-Reply-To: <43F8A2AC.9070601@tresys.com>

[-- Attachment #1: Type: text/plain, Size: 418 bytes --]


> It's an invalid context, I don't think there is anything you *can* do 
> except fatally error. Consider what would happen if there was a proper 
> MLS context with multiple levels on an MCS policy...
Well, in that case, patch attached. Also fixes printing of mls_range in 
the error case for seuser_validate.
Applies on top of the previous one.

That leaves the semanage tool to audit and fix for non-MLS issues.



[-- Attachment #2: libsemanage.sepol.mls_fix2.diff --]
[-- Type: text/x-patch, Size: 3383 bytes --]

diff -Naurp --exclude Makefile --exclude 'fcontext*' --exclude libselinux --exclude genhomedircon.c --exclude direct_api.c --exclude-from excludes old/libsemanage/src/seusers_local.c new/libsemanage/src/seusers_local.c
--- old/libsemanage/src/seusers_local.c	2006-02-17 16:29:48.000000000 -0500
+++ new/libsemanage/src/seusers_local.c	2006-02-19 12:11:55.000000000 -0500
@@ -126,6 +126,7 @@ static int validate_handler(
 		if (sepol_mls_contains(handle->sepolh, policydb, 
 			user_mls_range, mls_range, &mls_ok) < 0)
 			goto err;
+
 		if (!mls_ok) {
 			ERR(handle, "MLS range %s for Unix user %s "
 			     "exceeds allowed range %s for SELinux user %s",
@@ -133,24 +134,29 @@ static int validate_handler(
 			goto invalid;
 		}
 
-	} else if (mls_range)
-		WARN(handle, "MLS is disabled, MLS range %s "
-			"Unix user %s ignored", mls_range, name);
+	} else if (mls_range) {
+		ERR(handle, "MLS is disabled, but MLS range %s "
+			"was found for Unix user %s", mls_range, name);
+		goto invalid;
+	}
 
 	semanage_user_key_free(key);
 	semanage_user_free(user);
 	return 0;
 
 	err:
-	ERR(handle, "could not check if the seuser mapping "
-		"%s -> (%s, %s) is valid", name, sename, mls_range);
+	ERR(handle, "could not check if seuser mapping for %s is valid", name);
 	semanage_user_key_free(key);
 	semanage_user_free(user);
 	return -1;
 
 	invalid:
-	ERR(handle, "seuser mapping %s -> (%s, %s) is invalid",
-		name, sename, mls_range);
+	if (mls_range)
+		ERR(handle, "seuser mapping [%s -> (%s, %s)] is invalid",
+			name, sename, mls_range);
+	else 
+		ERR(handle, "seuser mapping [%s -> %s] is invalid",
+			name, sename);
 	semanage_user_key_free(key);
 	semanage_user_free(user);
 	return -1;
diff -Naurp --exclude Makefile --exclude 'fcontext*' --exclude libselinux --exclude genhomedircon.c --exclude direct_api.c --exclude-from excludes old/libsepol/src/context.c new/libsepol/src/context.c
--- old/libsepol/src/context.c	2006-01-06 09:36:28.000000000 -0500
+++ new/libsepol/src/context.c	2006-02-19 12:06:45.000000000 -0500
@@ -194,12 +194,11 @@ int context_from_record(
 
 	/* MLS */
 	if (mls && !policydb->mls) {
-		WARN(handle, "mls context \"%s\" ignored, since "
-				"mls is disabled", mls);
-		mls = NULL;
+		ERR(handle, "MLS is disabled, but MLS context \"%s\" found", mls);
+		goto err_destroy;
 	}
 	else if (!mls && policydb->mls) {
-	 	ERR(handle, "mls is enabled, but no mls context found");
+	 	ERR(handle, "MLS is enabled, but no MLS context found");
 		goto err_destroy;
 	}
 	if (mls && (mls_from_string(handle, policydb, mls, scontext) < 0)) 
diff -Naurp --exclude Makefile --exclude 'fcontext*' --exclude libselinux --exclude genhomedircon.c --exclude direct_api.c --exclude-from excludes old/libsepol/src/users.c new/libsepol/src/users.c
--- old/libsepol/src/users.c	2006-02-17 16:29:48.000000000 -0500
+++ new/libsepol/src/users.c	2006-02-19 12:07:32.000000000 -0500
@@ -219,10 +219,10 @@ int sepol_user_modify(
 		}
 		context_destroy(&context);
 
-	} else {
-		if (cmls_level != NULL || cmls_range != NULL)
-			WARN(handle, "MLS is disabled, MLS level/range "
-				"ignored for user %s", cname);
+	} else if (cmls_level != NULL || cmls_range != NULL) {
+		ERR(handle, "MLS is disabled, but MLS level/range "
+			"was found for user %s", cname);
+		goto err;
 	}
 
 	/* If there are no errors, and this is a new user, add the user to policy */

  reply	other threads:[~2006-02-19 17:17 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-02-17  4:24 semanage non MLS breakage Chris PeBenito
2006-02-17  5:41 ` Ivan Gyurdiev
2006-02-17 14:23   ` Joshua Brindle
2006-02-17 15:04     ` Ivan Gyurdiev
2006-02-17 15:10       ` Joshua Brindle
2006-02-17 15:19         ` Ivan Gyurdiev
2006-02-17 15:28           ` Joshua Brindle
2006-02-17 15:39             ` Ivan Gyurdiev
2006-02-17 21:30               ` Ivan Gyurdiev
2006-02-18 18:44                 ` Chris PeBenito
2006-02-18 20:06                   ` Ivan Gyurdiev
2006-02-19 12:10                     ` Ivan Gyurdiev
2006-02-19 16:54                       ` Joshua Brindle
2006-02-19 17:17                         ` Ivan Gyurdiev [this message]
2006-02-22 15:49                           ` Stephen Smalley

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=43F8A847.8010709@cornell.edu \
    --to=ivg2@cornell.edu \
    --cc=jbrindle@tresys.com \
    --cc=pebenito@gentoo.org \
    --cc=sds@tycho.nsa.gov \
    --cc=selinux@tycho.nsa.gov \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.