Skip to contentSkip to conversation

Build the SELinux testsuite on systems using the Reference Policy

PATCH Superseded Guido Trentalancia 2 participants 11 messages Aug 24, 2016 – Sep 1, 2016 SELinux security module

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Build the SELinux testsuite on systems using the Reference Policy

Fix the Makefile in the policy subdirectory of the SELinux testsuite so that it builds correctly on the standard Reference Policy which does not have the same booleans available on Red Hat.

---
 policy/Makefile |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
policy/Makefile +2 -2
@@ -68,7 +68,7 @@ load_rhel: all
 
 load_general: all
 	# General policy load
-	/usr/sbin/setsebool allow_domain_fd_use=0
+	/usr/sbin/getsebool -a | grep -q allow_domain_fd_use && /usr/sbin/setsebool allow_domain_fd_use=0
 	$(SEMODULE) -i test_policy/test_policy.pp
 
 unload_rhel:
@@ -77,7 +77,7 @@ unload_rhel:
 
 unload_general:
 	# General policy unload
-	/usr/sbin/setsebool allow_domain_fd_use=1
+	/usr/sbin/getsebool -a | grep -q allow_domain_fd_use && /usr/sbin/setsebool allow_domain_fd_use=1
 	$(SEMODULE) -r test_policy
 
 clean:
#1 lore raw

PATCH v2 1/1 Build the SELinux testsuite on systems using the Reference Policy

Fix the Makefile in the policy subdirectory of the SELinux testsuite so that it builds correctly on the standard Reference Policy which does not have the same booleans available on Red Hat.

---
 policy/Makefile |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
policy/Makefile +2 -2
@@ -68,7 +68,7 @@ load_rhel: all
 
 load_general: all
 	# General policy load
-	/usr/sbin/setsebool allow_domain_fd_use=0
+	/usr/sbin/getsebool -a | grep -q allow_domain_fd_use && /usr/sbin/setsebool allow_domain_fd_use=0 || :
 	$(SEMODULE) -i test_policy/test_policy.pp
 
 unload_rhel:
@@ -77,7 +77,7 @@ unload_rhel:
 
 unload_general:
 	# General policy unload
-	/usr/sbin/setsebool allow_domain_fd_use=1
+	/usr/sbin/getsebool -a | grep -q allow_domain_fd_use && /usr/sbin/setsebool allow_domain_fd_use=1 || :
 	$(SEMODULE) -r test_policy
 
 clean:
#2 lore raw
Quoted 12 lines · Guido Trentalancia

Fix the Makefile in the policy subdirectory of the SELinux testsuite so that it builds correctly on the standard Reference Policy which does not have the same booleans available on Red Hat.

---
 policy/Makefile |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

policy/Makefile load_rhel: all · line 72

Quoted 6 lines
policy/Makefile +1 -1
@@ -68,7 +68,7 @@ load_rhel: all
 
 load_general: all
 	# General policy load
-	/usr/sbin/setsebool allow_domain_fd_use=0
+	/usr/sbin/getsebool -a | grep -q allow_domain_fd_use && /usr/sbin/setsebool allow_domain_fd_use=0 || :
 	$(SEMODULE) -i test_policy/test_policy.pp

Just test the result of getsebool allow_domain_fd_use.
No need to dump them all and grep for the one you want. Also, the above didn't work anyway on Fedora because the boolean has been renamed and getsebool -a lists the new names (the old names can still be passed to getsebool and setsebool because of the booleans.subs_dist mapping).

Quoted 11 lines
policy/Makefile +1 -1
 unload_rhel:
@@ -77,7 +77,7 @@ unload_rhel:
 
 unload_general:
 	# General policy unload
-	/usr/sbin/setsebool allow_domain_fd_use=1
+	/usr/sbin/getsebool -a | grep -q allow_domain_fd_use && /usr/sbin/setsebool allow_domain_fd_use=1 || :
 	$(SEMODULE) -r test_policy
 
 clean:
#3 lore raw

PATCH v3 1/1 Build the SELinux testsuite on systems using the Reference Policy

Fix the Makefile in the policy subdirectory of the SELinux testsuite so that it builds correctly on the standard Reference Policy which does not have the same booleans available on Red Hat.

---
 policy/Makefile |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
policy/Makefile +2 -2
@@ -68,7 +69,7 @@ load_rhel: all
 
 load_general: all
 	# General policy load
-	/usr/sbin/setsebool allow_domain_fd_use=0
+	/usr/sbin/getsebool allow_domain_fd_use > /dev/null && /usr/sbin/setsebool allow_domain_fd_use=0 || :
 	$(SEMODULE) -i test_policy/test_policy.pp
 
 unload_rhel:
@@ -77,7 +78,7 @@ unload_rhel:
 
 unload_general:
 	# General policy unload
-	/usr/sbin/setsebool allow_domain_fd_use=1
+	/usr/sbin/getsebool allow_domain_fd_use > /dev/null && /usr/sbin/setsebool allow_domain_fd_use=1 || :
 	$(SEMODULE) -r test_policy
 
 clean:
#4 lore raw
Quoted 12 lines · Guido Trentalancia

Fix the Makefile in the policy subdirectory of the SELinux testsuite so that it builds correctly on the standard Reference Policy which does not have the same booleans available on Red Hat.

---
 policy/Makefile |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

policy/Makefile load_rhel: all · line 73

Quoted 6 lines
policy/Makefile +1 -1
@@ -68,7 +69,7 @@ load_rhel: all
 
 load_general: all
 	# General policy load
-	/usr/sbin/setsebool allow_domain_fd_use=0
+	/usr/sbin/getsebool allow_domain_fd_use > /dev/null && /usr/sbin/setsebool allow_domain_fd_use=0 || :
 	$(SEMODULE) -i test_policy/test_policy.pp

Don't you need 2>&1 as well to suppress error output when the boolean does not exist?

Quoted 12 lines
policy/Makefile +1 -1
 unload_rhel:
@@ -77,7 +78,7 @@ unload_rhel:
 
 unload_general:
 	# General policy unload
-	/usr/sbin/setsebool allow_domain_fd_use=1
+	/usr/sbin/getsebool allow_domain_fd_use > /dev/null && /usr/sbin/setsebool allow_domain_fd_use=1 || :
 	$(SEMODULE) -r test_policy
 
 clean:
#5 lore raw

PATCH v4 1/1 Build the SELinux testsuite on systems using the Reference Policy

Fix the Makefile in the policy subdirectory of the SELinux testsuite so that it builds correctly on the standard Reference Policy which does not have the same booleans available on Red Hat.

---
 policy/Makefile |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
policy/Makefile +2 -2
@@ -68,7 +69,7 @@ load_rhel: all
 
 load_general: all
 	# General policy load
-	/usr/sbin/setsebool allow_domain_fd_use=0
+	/usr/sbin/getsebool allow_domain_fd_use > /dev/null 2&>1 && /usr/sbin/setsebool allow_domain_fd_use=0 || :
 	$(SEMODULE) -i test_policy/test_policy.pp
 
 unload_rhel:
@@ -77,7 +78,7 @@ unload_rhel:
 
 unload_general:
 	# General policy unload
-	/usr/sbin/setsebool allow_domain_fd_use=1
+	/usr/sbin/getsebool allow_domain_fd_use > /dev/null 2&>1 && /usr/sbin/setsebool allow_domain_fd_use=1 || :
 	$(SEMODULE) -r test_policy
 
 clean:
#6 lore raw
Quoted 12 lines · Guido Trentalancia

Fix the Makefile in the policy subdirectory of the SELinux testsuite so that it builds correctly on the standard Reference Policy which does not have the same booleans available on Red Hat.

---
 policy/Makefile |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

policy/Makefile load_rhel: all · line 72

Quoted 5 lines
policy/Makefile +1 -1
@@ -68,7 +69,7 @@ load_rhel: all
 
 load_general: all
 	# General policy load
-	/usr/sbin/setsebool allow_domain_fd_use=0
+	/usr/sbin/getsebool allow_domain_fd_use > /dev/null 2&>1 && /usr/sbin/setsebool allow_domain_fd_use=0 || :

Hmm...doesn't seem to be executing the setsebool command now; boolean is left unchanged and the corresponding tests fail.

Quoted 13 lines
policy/Makefile +1 -1
 	$(SEMODULE) -i test_policy/test_policy.pp
 
 unload_rhel:
@@ -77,7 +78,7 @@ unload_rhel:
 
 unload_general:
 	# General policy unload
-	/usr/sbin/setsebool allow_domain_fd_use=1
+	/usr/sbin/getsebool allow_domain_fd_use > /dev/null 2&>1 && /usr/sbin/setsebool allow_domain_fd_use=1 || :
 	$(SEMODULE) -r test_policy
 
 clean:
#7 lore raw

PATCH v5 1/1 Build the SELinux testsuite on systems using the Reference Policy

Sorry about that ! I did not test it properly because I was hitting a problem with the policy...

The following one should work, although it's slightly noisy...

Fix the Makefile in the policy subdirectory of the SELinux testsuite so that it builds correctly on the standard Reference Policy which does not have the same booleans available on Red Hat.

Previous versions were not working within the Makefile.

---
 policy/Makefile |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
policy/Makefile +2 -2
@@ -68,7 +69,7 @@ load_rhel: all
 
 load_general: all
 	# General policy load
-	/usr/sbin/setsebool allow_domain_fd_use=0
+	@-/usr/sbin/setsebool allow_domain_fd_use=0
 	$(SEMODULE) -i test_policy/test_policy.pp
 
 unload_rhel:
@@ -77,7 +78,7 @@ unload_rhel:
 
 unload_general:
 	# General policy unload
-	/usr/sbin/setsebool allow_domain_fd_use=1
+	@-/usr/sbin/setsebool allow_domain_fd_use=1
 	$(SEMODULE) -r test_policy
 
 clean:
#8 lore raw
Quoted 5 lines · Guido Trentalancia

Sorry about that ! I did not test it properly because I was hitting a problem with the policy...

The following one should work, although it's slightly noisy...

Quoted 7 lines

Fix the Makefile in the policy subdirectory of the SELinux testsuite so that it builds correctly on the standard Reference Policy which does not have the same booleans available on Red Hat.

Previous versions were not working within the Makefile.

Thanks, applied.

Quoted 30 lines
---
 policy/Makefile |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
policy/Makefile +2 -2
@@ -68,7 +69,7 @@ load_rhel: all
 
 load_general: all
 	# General policy load
-	/usr/sbin/setsebool allow_domain_fd_use=0
+	@-/usr/sbin/setsebool allow_domain_fd_use=0
 	$(SEMODULE) -i test_policy/test_policy.pp
 
 unload_rhel:
@@ -77,7 +78,7 @@ unload_rhel:
 
 unload_general:
 	# General policy unload
-	/usr/sbin/setsebool allow_domain_fd_use=1
+	@-/usr/sbin/setsebool allow_domain_fd_use=1
 	$(SEMODULE) -r test_policy
 
 clean:

_______________________________________________
Selinux mailing list
[email protected]
To unsubscribe, send email to [email protected].
To get help, send an email containing "help" to [email protected].

#9 lore raw

Hello Stephen.

Thanks very much for applying the patch.

Guido

Quoted 48 lines · Stephen Smalley
Quoted 7 lines · Guido Trentalancia

Sorry about that ! I did not test it properly because I was hitting a
problem with the policy...

The following one should work, although it's slightly noisy...

Quoted 8 lines

Fix the Makefile in the policy subdirectory of the SELinux testsuite
so that it builds correctly on the standard Reference Policy which does not have the same booleans available on Red Hat.

Previous versions were not working within the Makefile.

Thanks, applied.

Quoted 28 lines

---
 policy/Makefile |    4 ++--

 1 file changed, 2 insertions(+), 2 deletions(-)

--- selinux-testsuite-git-23082016-orig/policy/Makefile 2016
-08-23 20:50:08.527633728 +0200
+++ selinux-testsuite-git-23082016/policy/Makefile 2016-08-
26 20:33:01.677418513 +0200

(quoted diff) +0 -0
@@ -68,7 +69,7 @@ load_rhel: all


 load_general: all
  # General policy load

policy/Makefile +1 -1
-	/usr/sbin/setsebool allow_domain_fd_use=0
+	@-/usr/sbin/setsebool allow_domain_fd_use=0

  $(SEMODULE) -i test_policy/test_policy.pp

 unload_rhel:

(quoted diff) +0 -0
@@ -77,7 +78,7 @@ unload_rhel:


 unload_general:
  # General policy unload

policy/Makefile +1 -1
-	/usr/sbin/setsebool allow_domain_fd_use=1
+	@-/usr/sbin/setsebool allow_domain_fd_use=1

  $(SEMODULE) -r test_policy

 clean:

#10 lore raw

PATCH v2 1/1 Build the SELinux testsuite on systems using the Reference Policy

In reply to Guido Trentalancia

Fix the Makefile in the policy subdirectory of the SELinux testsuite so that it builds correctly on the standard Reference Policy which does not have the same booleans available on Red Hat.

---
 policy/Makefile |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
policy/Makefile +2 -2
@@ -68,7 +68,7 @@ load_rhel: all
 
 load_general: all
 	# General policy load
-	/usr/sbin/setsebool allow_domain_fd_use=0
+	/usr/sbin/getsebool -a | grep -q allow_domain_fd_use && /usr/sbin/setsebool allow_domain_fd_use=0 || :
 	$(SEMODULE) -i test_policy/test_policy.pp
 
 unload_rhel:
@@ -77,7 +77,7 @@ unload_rhel:
 
 unload_general:
 	# General policy unload
-	/usr/sbin/setsebool allow_domain_fd_use=1
+	/usr/sbin/getsebool -a | grep -q allow_domain_fd_use && /usr/sbin/setsebool allow_domain_fd_use=1 || :
 	$(SEMODULE) -r test_policy
 
 clean: