selinux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] scripts/selinux/mdp: fix initial SID handling
@ 2020-06-17 19:22 Stephen Smalley
  2020-06-24  0:52 ` Paul Moore
  0 siblings, 1 reply; 2+ messages in thread
From: Stephen Smalley @ 2020-06-17 19:22 UTC (permalink / raw)
  To: selinux; +Cc: omosnace, paul, Stephen Smalley

commit e3e0b582c321 ("selinux: remove unused initial SIDs and improve
handling") broke scripts/selinux/mdp since the unused initial SID names
were removed and the corresponding generation of policy initial SID
definitions by mdp was not updated accordingly.  Fix it.  With latest
upstream checkpolicy it is no longer necessary to include the SID context
definitions for the unused initial SIDs but retain them for compatibility
with older checkpolicy.

Fixes: e3e0b582c321 ("selinux: remove unused initial SIDs and improve handling")
Signed-off-by: Stephen Smalley <stephen.smalley.work@gmail.com>
---
 scripts/selinux/mdp/mdp.c | 23 ++++++++++++++++++-----
 1 file changed, 18 insertions(+), 5 deletions(-)

diff --git a/scripts/selinux/mdp/mdp.c b/scripts/selinux/mdp/mdp.c
index 576d11a60417..6ceb88eb9b59 100644
--- a/scripts/selinux/mdp/mdp.c
+++ b/scripts/selinux/mdp/mdp.c
@@ -67,8 +67,14 @@ int main(int argc, char *argv[])
 
 	initial_sid_to_string_len = sizeof(initial_sid_to_string) / sizeof (char *);
 	/* print out the sids */
-	for (i = 1; i < initial_sid_to_string_len; i++)
-		fprintf(fout, "sid %s\n", initial_sid_to_string[i]);
+	for (i = 1; i < initial_sid_to_string_len; i++) {
+		const char *name = initial_sid_to_string[i];
+
+		if (name)
+			fprintf(fout, "sid %s\n", name);
+		else
+			fprintf(fout, "sid unused%d\n", i);
+	}
 	fprintf(fout, "\n");
 
 	/* print out the class permissions */
@@ -126,9 +132,16 @@ int main(int argc, char *argv[])
 #define OBJUSERROLETYPE "user_u:object_r:base_t"
 
 	/* default sids */
-	for (i = 1; i < initial_sid_to_string_len; i++)
-		fprintf(fout, "sid %s " SUBJUSERROLETYPE "%s\n",
-			initial_sid_to_string[i], mls ? ":" SYSTEMLOW : "");
+	for (i = 1; i < initial_sid_to_string_len; i++) {
+		const char *name = initial_sid_to_string[i];
+
+		if (name)
+			fprintf(fout, "sid %s ", name);
+		else
+			fprintf(fout, "sid unused%d\n", i);
+		fprintf(fout, SUBJUSERROLETYPE "%s\n",
+			mls ? ":" SYSTEMLOW : "");
+	}
 	fprintf(fout, "\n");
 
 #define FS_USE(behavior, fstype)			    \
-- 
2.25.1


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

* Re: [PATCH] scripts/selinux/mdp: fix initial SID handling
  2020-06-17 19:22 [PATCH] scripts/selinux/mdp: fix initial SID handling Stephen Smalley
@ 2020-06-24  0:52 ` Paul Moore
  0 siblings, 0 replies; 2+ messages in thread
From: Paul Moore @ 2020-06-24  0:52 UTC (permalink / raw)
  To: Stephen Smalley; +Cc: selinux, Ondrej Mosnacek

On Wed, Jun 17, 2020 at 3:22 PM Stephen Smalley
<stephen.smalley.work@gmail.com> wrote:
>
> commit e3e0b582c321 ("selinux: remove unused initial SIDs and improve
> handling") broke scripts/selinux/mdp since the unused initial SID names
> were removed and the corresponding generation of policy initial SID
> definitions by mdp was not updated accordingly.  Fix it.  With latest
> upstream checkpolicy it is no longer necessary to include the SID context
> definitions for the unused initial SIDs but retain them for compatibility
> with older checkpolicy.
>
> Fixes: e3e0b582c321 ("selinux: remove unused initial SIDs and improve handling")
> Signed-off-by: Stephen Smalley <stephen.smalley.work@gmail.com>
> ---
>  scripts/selinux/mdp/mdp.c | 23 ++++++++++++++++++-----
>  1 file changed, 18 insertions(+), 5 deletions(-)

Merged into selinux/next, thanks Stephen.

-- 
paul moore
www.paul-moore.com

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

end of thread, other threads:[~2020-06-24  0:52 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-17 19:22 [PATCH] scripts/selinux/mdp: fix initial SID handling Stephen Smalley
2020-06-24  0:52 ` Paul Moore

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).