All of lore.kernel.org
 help / color / mirror / Atom feed
* [ SEMANAGE ] Assert whitespace between records
@ 2005-11-04 18:31 Ivan Gyurdiev
  2005-11-04 19:22 ` Stephen Smalley
  0 siblings, 1 reply; 2+ messages in thread
From: Ivan Gyurdiev @ 2005-11-04 18:31 UTC (permalink / raw)
  To: selinux; +Cc: Stephen Smalley

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

This patch will assert there is whitespace between seuser, boolean, 
interface, and port records (assert whitespace after each record). This 
has no effect on ports and interfaces, because they already check for 
that when looking for where the context ends (added for clarity only). 
Users don't require a space, because they have a semicolon.

In the case of seusers, this prevents parser confusion when MLS is 
disabled, and we encounter an MLS context:
a:b:c - complain about lack of whitespace, rather than treating the ":" 
as the next seuser, and saying something like: nonempty string expected, 
or whatever...

In the case of booleans, this change will consider a=TRUEb=false or 
things like that as a parse error.

This change will succeed on the last record, and at the end of each 
line, because the terminating '\0' is considered whitespace - it's 
present on all lines, including the last one. It will not succeed if you 
called skip_space right before that, because that zeros the buffer on 
EOF (intentionally).


[-- Attachment #2: libsemanage.space_between_records.diff --]
[-- Type: text/x-patch, Size: 2767 bytes --]

diff -Naurp --exclude CVS --exclude ChangeLog --exclude VERSION --exclude Makefile old/libselinux/src/seusers.c new/libselinux/src/seusers.c
--- old/libselinux/src/seusers.c	2005-11-04 10:13:47.000000000 -0500
+++ new/libselinux/src/seusers.c	2005-11-04 13:05:10.000000000 -0500
@@ -45,7 +45,6 @@ static int process_seusers(const char *b
 	if (!end) {
 		mls_found = 0;
 
-		/* MLS is disabled, so :level suffix not required. */
 		end = start;
 		while (*end && !isspace(*end))
 			end++;
@@ -55,9 +54,10 @@ static int process_seusers(const char *b
 	seuser = strdup(start);
 	if (!seuser)
 		goto err;
-
+	
+	/* Skip MLS if disabled, or missing. */
 	if (!mls_enabled || !mls_found)
-		goto out; /* skip any MLS level */
+		goto out;
 
 	start = ++end;
 	while (*end && !isspace(*end))
diff -Naurp --exclude CVS --exclude ChangeLog --exclude VERSION --exclude Makefile old/libsemanage/src/booleans_file.c new/libsemanage/src/booleans_file.c
--- old/libsemanage/src/booleans_file.c	2005-11-04 03:03:26.000000000 -0500
+++ new/libsemanage/src/booleans_file.c	2005-11-04 13:14:51.000000000 -0500
@@ -87,6 +87,9 @@ static int bool_parse(
 	}
 	semanage_bool_set_value(boolean, value);
 
+	if (parse_assert_space(handle, info) < 0)
+		goto err;
+
 	return STATUS_SUCCESS;
 
 	last:
diff -Naurp --exclude CVS --exclude ChangeLog --exclude VERSION --exclude Makefile old/libsemanage/src/interfaces_file.c new/libsemanage/src/interfaces_file.c
--- old/libsemanage/src/interfaces_file.c	2005-11-04 03:03:26.000000000 -0500
+++ new/libsemanage/src/interfaces_file.c	2005-11-04 13:22:57.000000000 -0500
@@ -127,6 +127,9 @@ static int iface_parse(
 	semanage_iface_set_msgcon(iface, con);
 	con = NULL;
 
+	if (parse_assert_space(handle, info) < 0)
+		goto err;
+
 	return STATUS_SUCCESS;
 
 	last:
diff -Naurp --exclude CVS --exclude ChangeLog --exclude VERSION --exclude Makefile old/libsemanage/src/ports_file.c new/libsemanage/src/ports_file.c
--- old/libsemanage/src/ports_file.c	2005-11-04 03:03:26.000000000 -0500
+++ new/libsemanage/src/ports_file.c	2005-11-04 13:13:43.000000000 -0500
@@ -134,6 +134,9 @@ static int port_parse(
 	semanage_port_set_con(port, con);
 	con = NULL;
 
+	if (parse_assert_space(handle, info) < 0)
+		goto err;
+
 	return STATUS_SUCCESS;
 
 	last:
diff -Naurp --exclude CVS --exclude ChangeLog --exclude VERSION --exclude Makefile old/libsemanage/src/seusers_file.c new/libsemanage/src/seusers_file.c
--- old/libsemanage/src/seusers_file.c	2005-11-04 03:03:26.000000000 -0500
+++ new/libsemanage/src/seusers_file.c	2005-11-04 13:12:33.000000000 -0500
@@ -96,7 +96,10 @@ static int seuser_parse(
 			goto err;
 		free(str);
 		str = NULL;
-	} 
+	}
+
+	if (parse_assert_space(handle, info) < 0)
+		goto err; 
 	
 	out:
 	return STATUS_SUCCESS;

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2005-11-04 19:22 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-11-04 18:31 [ SEMANAGE ] Assert whitespace between records Ivan Gyurdiev
2005-11-04 19:22 ` Stephen Smalley

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.