From: Ivan Gyurdiev <ivg2@cornell.edu>
To: selinux@tycho.nsa.gov
Cc: Stephen Smalley <sds@tycho.nsa.gov>
Subject: [ SEMANAGE ] Assert whitespace between records
Date: Fri, 04 Nov 2005 13:31:02 -0500 [thread overview]
Message-ID: <436BA8E6.8030508@cornell.edu> (raw)
[-- 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;
next reply other threads:[~2005-11-04 18:31 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-11-04 18:31 Ivan Gyurdiev [this message]
2005-11-04 19:22 ` [ SEMANAGE ] Assert whitespace between records 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=436BA8E6.8030508@cornell.edu \
--to=ivg2@cornell.edu \
--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.