Skip to contentSkip to conversation

addition for xdm.te

DISCUSSION Russell Coker 2 participants 3 messages Apr 16, 2002

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

I currently have the following in my policy Makefile:
POLICYFILES = security_classes initial_sids access_vectors
ifeq ($(MLS),y)
POLICYFILES += mls
endif
POLICYFILES += tmp/macro_used_flags.te tmp/program_used_flags.te tmp/all.te rbacPOLICYFILES += users
POLICYFILES += constraints
POLICYFILES += initial_sid_contexts fs_contexts devfs_contexts net_contexts

tmp/program_used_flags.te: domains/program/* domains/program
( cd domains/program/ ; for n in * ; do echo "define(\`$$n')"; done )

Quoted 1 line

$@

tmp/macro_used_flags.te: macros/program/* macros/program

        ( cd macros/program/ ; for n in * ; do echo "define(\`macro_$$n')"; 

done ) > $@

So now a policy file that needs dpkg can check for ifdef(dpkg.te' and a policy file that needs the GPG macros to be defines can check for ifdef(gpg_macros.te', ...

---------- Forwarded Message ----------

Subject: Re: addition for xdm.te
Date: Thu, 21 Mar 2002 21:39:10 +0100
From: Russell Coker <[email protected]>
To: Stephen Smalley <[email protected]>
Cc: SE Linux <[email protected]>

Quoted 5 lines · Stephen Smalley
Quoted 3 lines · Russell Coker

I think it makes more sense to have all the xdm policy in the xdm file. Then someone who doesn't use a xdm type program can remove the file and everything else will be fine.

Quoted 7 lines

This isn't as straightforward as it might appear. Consider the xdm-related rules in user_macros.te and netscape_macros.te. We can relocate those rules to xdm.te through the use of type attributes (to cover all user domains and all netscape domains), but you then have a little piece of the netscape policy in the xdm.te file. Perhaps that is more acceptable than having a little piece of the xdm policy in the netscape_macros.te file.

What if you have some shell code such as the following to generate m4 macro definitions:
( cd domains/program/ ; for n in * ; do echo "define(\`$n')"; done )

Then in netscape.te you can have:
ifdef(xdm.te', ...

Or in xdm.te you can have:
ifdef(netscape.te', ...

While we're at it we could use similar m4 code to use those generated macros in file_contexts to make it adapt to the policy files you have installed.

It may be almost as straightforward as it appears! ;)

--
If you send email to me or to a mailing list that I use which has >4 lines of legalistic junk at the end then you are specifically authorizing me to do whatever I wish with the message and all other messages from your domain, by posting the message you agree that your long legalistic sig is void.

-------------------------------------------------------

Signature · 9 lines
If you send email to me or to a mailing list that I use which has >4 lines
of legalistic junk at the end then you are specifically authorizing me to do
whatever I wish with the message and all other messages from your domain, by
posting the message you agree that your long legalistic sig is void.

--
You have received this message because you are subscribed to the selinux 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

Thanks. I edited it slightly, so I'm using the attached patch relative to our policy Makefile. I added $(wildcard), limited the lists to *.te to avoid picking up extraneous files, and dropped the macro_ prefix, since the macro files already have _macros in the name. I'm also not using a separate tmp directory, although it doesn't especially matter to me. Is there a strong reason to use a separate tmp directory for the intermediate files?

--
Stephen D. Smalley, NAI Labs
[email protected]

Quoted 74 lines · Russell Coker

I currently have the following in my policy Makefile:
POLICYFILES = security_classes initial_sids access_vectors
ifeq ($(MLS),y)
POLICYFILES += mls
endif
POLICYFILES += tmp/macro_used_flags.te tmp/program_used_flags.te tmp/all.te rbacPOLICYFILES += users
POLICYFILES += constraints
POLICYFILES += initial_sid_contexts fs_contexts devfs_contexts net_contexts

tmp/program_used_flags.te: domains/program/* domains/program
( cd domains/program/ ; for n in * ; do echo "define(\`$$n')"; done )

Quoted 1 line

$@

tmp/macro_used_flags.te: macros/program/* macros/program

        ( cd macros/program/ ; for n in * ; do echo "define(\`macro_$$n')";

done ) > $@

So now a policy file that needs dpkg can check for ifdef(dpkg.te' and a policy file that needs the GPG macros to be defines can check for ifdef(gpg_macros.te', ...

---------- Forwarded Message ----------

Subject: Re: addition for xdm.te
Date: Thu, 21 Mar 2002 21:39:10 +0100
From: Russell Coker <[email protected]>
To: Stephen Smalley <[email protected]>
Cc: SE Linux <[email protected]>

Quoted 5 lines · Stephen Smalley
Quoted 3 lines · Russell Coker

I think it makes more sense to have all the xdm policy in the xdm file. Then someone who doesn't use a xdm type program can remove the file and everything else will be fine.

Quoted 7 lines

This isn't as straightforward as it might appear. Consider the xdm-related rules in user_macros.te and netscape_macros.te. We can relocate those rules to xdm.te through the use of type attributes (to cover all user domains and all netscape domains), but you then have a little piece of the netscape policy in the xdm.te file. Perhaps that is more acceptable than having a little piece of the xdm policy in the netscape_macros.te file.

What if you have some shell code such as the following to generate m4 macro definitions:
( cd domains/program/ ; for n in * ; do echo "define(\`$n')"; done )

Then in netscape.te you can have:
ifdef(xdm.te', ...

Or in xdm.te you can have:
ifdef(netscape.te', ...

While we're at it we could use similar m4 code to use those generated macros in file_contexts to make it adapt to the policy files you have installed.

It may be almost as straightforward as it appears! ;)

--
If you send email to me or to a mailing list that I use which has >4 lines of legalistic junk at the end then you are specifically authorizing me to do whatever I wish with the message and all other messages from your domain, by posting the message you agree that your long legalistic sig is void.

-------------------------------------------------------

--
If you send email to me or to a mailing list that I use which has >4 lines of legalistic junk at the end then you are specifically authorizing me to do whatever I wish with the message and all other messages from your domain, by posting the message you agree that your long legalistic sig is void.

Quoted 5 lines

--
You have received this message because you are subscribed to the selinux list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.

Index: policy/Makefile
===================================================================
RCS file: /cvs/lsm/selinux/policy/Makefile,v
retrieving revision 1.17

Makefile +8 -1
diff -u -r1.17 Makefile
@@ -26,7 +26,7 @@
 ifeq ($(MLS),y)
 POLICYFILES += mls
 endif
-POLICYFILES += all.te rbac
+POLICYFILES += macro_used_flags.te program_used_flags.te all.te rbac
 POLICYFILES += users
 POLICYFILES += constraints 
 POLICYFILES += initial_sid_contexts fs_contexts devfs_contexts net_contexts
@@ -61,6 +61,12 @@
 testpolicy.conf: $(TESTPOLICYFILES)
 	m4 -Imacros -s $^ > testpolicy.conf
 
+program_used_flags.te: $(wildcard domains/program/*.te) domains/program
+	( cd domains/program/ ; for n in *.te ; do echo "define(\`$$n')"; done ) > $@
+
+macro_used_flags.te: $(wildcard macros/program/*.te) macros/program
+	( cd macros/program/ ; for n in *.te ; do echo "define(\`$$n')"; done ) > $@
+
 test_all.te: macros/global_macros.te all_types.te all_domains.te test_domains.te
 	cat $^ > $@
 	rm -f all_types.te all_domains.te test_domains.te
@@ -82,6 +88,7 @@
 	rm -f policy policy.conf $(POLICYVER)
 	rm -f all.te all_types.te all_domains.te test_domains.te
 	rm -f test_all.te test_all_domains.te testpolicy testpolicy.conf
+	rm -f program_used_flags.te macro_used_flags.te
 
 relabel:
 	chcon system_u:object_r:policy_config_t $(LOADPATH)
#2 lore raw
Quoted 4 lines · Stephen Smalley

Thanks. I edited it slightly, so I'm using the attached patch relative to our policy Makefile. I added $(wildcard), limited the lists to *.te to avoid picking up extraneous files, and dropped the macro_ prefix, since the macro files already have _macros in the name. I'm also not using

I had also removed the macro_ prefix after sending the message.

Quoted 3 lines

a separate tmp directory, although it doesn't especially matter to me. Is there a strong reason to use a separate tmp directory for the intermediate files?

I use the tmp directory to keep all generated files in one place, and to allow a "rm tmp/*" in the clean rule to clean it all up.

My Makefile is designed to work correctly, if you run "make" twice the second time no work should be done, if you change a source file and then run "make" then it should only re-build the necessary files. My Makefile does this.

I've attached the complete Makefile I use.

Signature · 4 lines
If you send email to me or to a mailing list that I use which has >4 lines
of legalistic junk at the end then you are specifically authorizing me to do
whatever I wish with the message and all other messages from your domain, by
posting the message you agree that your long legalistic sig is void.

#
# Makefile for the security policy.
#
# Targets:
#

# policy - compile the policy configuration.
# install - compile and install the policy configuration.
# load    - compile, install, and load the policy configuration.
#
# The default target is 'policy'.
#

# Set to y if MLS is enabled in the module.
MLS=n

BINDIR = /usr/bin
LOADPOLICY = $(BINDIR)/load_policy
CHECKPOLICY = $(BINDIR)/checkpolicy

POLICYVER := policy.$(shell $(CHECKPOLICY) -V)
INSTALLDIR = /etc/security/selinux
LOADPATH = $(INSTALLDIR)/$(POLICYVER)

POLICYFILES = security_classes initial_sids access_vectors
ifeq ($(MLS),y)
POLICYFILES += mls
endif
POLICYFILES += tmp/macro_used_flags.te tmp/program_used_flags.te tmp/all.te rbac POLICYFILES += users
POLICYFILES += constraints
POLICYFILES += initial_sid_contexts fs_contexts devfs_contexts net_contexts

$(POLICYVER): policy.conf $(CHECKPOLICY)

	$(CHECKPOLICY) -o $@ policy.conf

policy: $(POLICYVER)

install: $(LOADPATH)

policy.conf: $(POLICYFILES) macros/*
m4 -Imacros -s $^ > policy.conf

tmp/program_used_flags.te: domains/program/* domains/program

	( cd domains/program/ ; for n in * ; do echo "define(\`$$n')"; done ) > $@

tmp/macro_used_flags.te: macros/program/* macros/program

	( cd macros/program/ ; for n in * ; do echo "define(\`$$n')"; done ) > $@

$(LOADPATH): $(POLICYVER)

	mkdir -p $(INSTALLDIR)
	install -m 644 -o root -g root $(POLICYVER) $(LOADPATH)

load tmp/load: $(LOADPATH)

	$(BINDIR)/load_policy $(LOADPATH)
	touch tmp/load

relabel: file_contexts tmp/load

	setfiles -m file_contexts `mount | awk '/(ext[23]|reiserfs)/{print $$3}'`

tmp/all.te: macros/global_macros.te tmp/all_types.te tmp/all_domains.te assert.te

	cat $^ > $@

tmp/all_types.te: $(wildcard types/*.te)

	cat $^ > $@

tmp/all_domains.te: $(wildcard domains/*.te domains/program/*.te)

	cat $^ > $@

clean:

	rm -f $(POLICYVER) policy.conf 
	rm -f tmp/*