Skip to contentSkip to conversation

selinuxfs to globally disable dontaudit rules

PATCH Applied Eric Paris 5 participants 22 messages Aug 9, 2007 – Aug 23, 2007 SELinux security module

lore
Share & tools
lore

Eric Paris

author
#0 lore raw

PATCH 1/1 selinuxfs to globally disable dontaudit rules

Currently to disable dontaudit rules best you can do it to load the enableaudit.pp base policy. Which still doesn't remove the dontaudit rules from modules. This patch introduces a /selinux interface "allaudit" which ignores dontaudit rules. (I'm open to suggestions for a good name 'enabledisabledontaudit' seemed like a good name to me, but I don't know if everyone would agree)

I decided to use the same security permission as setenforce and as a result did a little bit of code merging in selinuxfs between enforcing and allaudit.

---

security/selinux/avc.c +2 -1
index 0e69adf..bfd979a 100644
@@ -117,6 +117,7 @@ struct avc_callback_node {
 
 /* Exported via selinufs */
 unsigned int avc_cache_threshold = AVC_DEF_CACHE_THRESHOLD;
+unsigned int selinux_allaudit = 0;
 
 #ifdef CONFIG_SECURITY_SELINUX_AVC_STATS
 DEFINE_PER_CPU(struct avc_cache_stats, avc_cache_stats) = { 0 };
@@ -537,7 +538,7 @@ void avc_audit(u32 ssid, u32 tsid,
 	denied = requested & ~avd->allowed;
 	if (denied) {
 		audited = denied;
-		if (!(audited & avd->auditdeny))
+		if (!(audited & avd->auditdeny) && !selinux_allaudit)
 			return;
 	} else if (result) {
 		audited = denied = requested;
security/selinux/include/avc.h +1 -0
index e145f6e..99b31ec 100644
@@ -130,6 +130,7 @@ int avc_add_callback(int (*callback)(u32 event, u32 ssid, u32 tsid,
 /* Exported to selinuxfs */
 int avc_get_hash_stats(char *page);
 extern unsigned int avc_cache_threshold;
+extern unsigned int selinux_allaudit;
 
 #ifdef CONFIG_SECURITY_SELINUX_AVC_STATS
 DECLARE_PER_CPU(struct avc_cache_stats, avc_cache_stats);
security/selinux/selinuxfs.c +72 -13

141 lines not on this page · raw message

--
This message was distributed to subscribers of the selinux mailing 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
Quoted 3 lines · Eric Paris

Currently to disable dontaudit rules best you can do it to load the enableaudit.pp base policy. Which still doesn't remove the dontaudit rules from modules.

Are we sure this can't be done in userspace? Like, mangle all the existing policy and reload it?

Quoted 4 lines

This patch introduces a /selinux interface
"allaudit" which ignores dontaudit rules. (I'm open to suggestions for a good name 'enabledisabledontaudit' seemed like a good name to me, but I don't know if everyone would agree)

'disable_dontaudit'

Quoted 4 lines

I decided to use the same security permission as setenforce and as a result did a little bit of code merging in selinuxfs between enforcing and allaudit.

Please do this in a separate patch.

Signature · 7 lines
James Morris
<[email protected]>

--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#2 lore raw
Quoted 11 lines · James Morris
Quoted 4 lines · Eric Paris

Currently to disable dontaudit rules best you can do it to load the enableaudit.pp base policy. Which still doesn't remove the dontaudit rules from modules.

Are we sure this can't be done in userspace? Like, mangle all the existing policy and reload it?

I agree, the infrastructure is certainly in place to do it, just add something in the sepol_handle that says dontaudits should be discarded, then make an interface in libsemanage that uses that and rebuild the policy.

If noone beats me to it I will see if my conclusions about it being fairly simple are accurate this weekend :)

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.

#3 lore raw
Quoted 9 lines · Joshua Brindle
Quoted 8 lines · James Morris
Quoted 4 lines · Eric Paris

Currently to disable dontaudit rules best you can do it to load the enableaudit.pp base policy. Which still doesn't remove the dontaudit rules from modules.

Quoted 7 lines
Quoted 3 lines

Are we sure this can't be done in userspace? Like, mangle all the existing policy and reload it?

I agree, the infrastructure is certainly in place to do it, just add something in the sepol_handle that says dontaudits should be discarded, then make an interface in libsemanage that uses that and rebuild the policy.

If noone beats me to it I will see if my conclusions about it being fairly simple are accurate this weekend :)

I changed my mind, patch below

it compiles and seems to work after semodule -DB:

[root@scarecrow policy]# sediff -T policy.21.old \; policy.21 | grep -v dontaudit
TE Rules (Added 0, Added New Type 0, Removed 326583, Removed Missing Type 0, Modified 0)
Added TE Rules: 0
Added TE Rules because of new type: 0
Removed TE Rules: 326583
Removed TE Rules because of missing type: 0
Modified TE Rules: 0

include/semanage/handle.h +0 -0
Index: libsemanage/include/semanage/handle.h
===================================================================
@@ -69,6 +69,9 @@
 * 1 for yes, 0 for no (default) */

void semanage_set_create_store(semanage_handle_t * handle, int create_store);

+/* Set whether or not to disable dontaudits upon commit */
+void semanage_set_disable_dontaudit(semanage_handle_t * handle, int disable_dontaudit); +
/* Check whether policy is managed via libsemanage on this system.
* Must be called prior to trying to connect.
* Return 1 if policy is managed via libsemanage on this system,

src/libsemanage.map +0 -0
Index: libsemanage/src/libsemanage.map
===================================================================
@@ -13,6 +13,6 @@
	  semanage_iface_*; semanage_port_*; semanage_context_*;
	  semanage_node_*;
	  semanage_fcontext_*; semanage_access_check; semanage_set_create_store;

- semanage_is_connected;
+ semanage_is_connected; semanage_set_disable_dontaudit;
local: *;
};

src/handle.c +0 -0
Index: libsemanage/src/handle.c
===================================================================
@@ -109,6 +109,14 @@
	return;
}

+void semanage_set_disable_dontaudit(semanage_handle_t * sh, int disable_dontaudit) +{
+ assert(sh != NULL);
+
+ sepol_set_disable_dontaudit(sh->sepolh, disable_dontaudit);
+ return;
+}
+
int semanage_is_connected(semanage_handle_t * sh)

{
	assert(sh != NULL);
include/sepol/handle.h +0 -0
Index: libsepol/include/sepol/handle.h
===================================================================
@@ -7,6 +7,10 @@

/* Create and return a sepol handle. */
sepol_handle_t *sepol_handle_create(void);

+/* Set whether or not to disable dontaudits, 0 is default and does + * not disable dontaudits, 1 disables them */ +void sepol_set_disable_dontaudit(sepol_handle_t * sh, int disable_dontaudit);
+
/* Destroy a sepol handle. */
void sepol_handle_destroy(sepol_handle_t *);

src/handle.h +0 -0
Index: libsepol/src/handle.h
===================================================================
@@ -14,6 +14,9 @@
	void (*msg_callback) (void *varg,
			      sepol_handle_t * handle, const char *fmt, ...);
	void *msg_callback_arg;

+
+ int disable_dontaudit;
+
};

#endif

src/libsepol.map +0 -0
Index: libsepol/src/libsepol.map
===================================================================
@@ -12,5 +12,6 @@
	sepol_policydb_*; sepol_set_policydb_from_file; 
	sepol_policy_kern_*;
	sepol_policy_file_*;

+ sepol_set_disable_dontaudit;
local: *;
};

src/expand.c +0 -0
Index: libsepol/src/expand.c
===================================================================
@@ -1367,6 +1367,8 @@
	} else if (specified & AVRULE_AUDITDENY) {
		spec = AVTAB_AUDITDENY;
	} else if (specified & AVRULE_DONTAUDIT) {
+		if (handle->disable_dontaudit)
+			return EXPAND_RULE_SUCCESS;
		spec = AVTAB_AUDITDENY;
	} else if (specified & AVRULE_NEVERALLOW) {
		spec = AVTAB_NEVERALLOW;
src/handle.c +0 -0
Index: libsepol/src/handle.c
===================================================================
@@ -1,4 +1,5 @@

#include <stdlib.h>
+#include <assert.h>
#include "handle.h"
#include "debug.h"

@@ -13,9 +14,18 @@

	sh->msg_callback = sepol_msg_default_handler;
	sh->msg_callback_arg = NULL;

+ /* by default do not disable dontaudits */
+ sh->disable_dontaudit = 0;
+

	return sh;
}

+void sepol_set_disable_dontaudit(sepol_handle_t * sh, int disable_dontaudit) +{
+ assert(sh !=NULL);
+ sh->disable_dontaudit = disable_dontaudit;
+}
+
void sepol_handle_destroy(sepol_handle_t * sh)

{
	free(sh);
semodule/semodule.c +0 -0
Index: policycoreutils/semodule/semodule.c
===================================================================
@@ -44,6 +44,7 @@

static int no_reload;
static int create_store;
static int build;
+static int disable_dontaudit;

static semanage_handle_t *sh = NULL;
static char *store;
@@ -131,6 +132,7 @@

	printf("  -n,--noreload	   do not reload policy after commit\n");
	printf("  -h,--help        print this message and quit\n");
	printf("  -v,--verbose     be verbose\n");

+ printf(" -D,--disable_dontaudit Remove dontaudits from policy\n");
}

/* Sets the global mode variable to new_mode, but only if no other @@ -173,6 +175,7 @@

		{"reload", 0, NULL, 'R'},
		{"noreload", 0, NULL, 'n'},
		{"build", 0, NULL, 'B'},
+		{"disable_dontaudit", 0, NULL, 'D'},
		{NULL, 0, NULL, 0}
	};
	int i;
@@ -181,7 +184,7 @@
	no_reload = 0;
	create_store = 0;
	while ((i =
-		getopt_long(argc, argv, "s:b:hi:lvqr:u:RnB", opts,
+		getopt_long(argc, argv, "s:b:hi:lvqr:u:RnBD", opts,
			    NULL)) != -1) {
		switch (i) {
		case 'b':
@@ -218,6 +221,9 @@
		case 'B':
			build = 1;
			break;
+		case 'D':
+			disable_dontaudit = 1;
+			break;
		case '?':
		default:{
				usage(argv[0]);
@@ -441,6 +447,8 @@
			semanage_set_reload(sh, 0);
		if (build)
			semanage_set_rebuild(sh, 1);
+		if (disable_dontaudit)
+			semanage_set_disable_dontaudit(sh, 1);
		result = semanage_commit(sh);
	}

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.

#4 lore raw
Quoted 19 lines · Joshua Brindle
Quoted 18 lines · Joshua Brindle
Quoted 12 lines · James Morris
Quoted 4 lines · Eric Paris

Currently to disable dontaudit rules best you can do it to load the enableaudit.pp base policy. Which still doesn't remove the dontaudit rules from modules.

Are we sure this can't be done in userspace? Like, mangle all the existing policy and reload it?

I agree, the infrastructure is certainly in place to do it, just add something in the sepol_handle that says dontaudits should be discarded, then make an interface in libsemanage that uses that and rebuild the policy.

Quoted 7 lines
Quoted 3 lines

If noone beats me to it I will see if my conclusions about it being fairly simple are accurate this weekend :)

I changed my mind, patch below

it compiles and seems to work after semodule -DB:

Hmm...doing it this way means that the "disable_dontaudit" behavior won't persist across subsequent policy changes, so if I e.g. then change a boolean persistently, I'll get back all of the dontaudit rules too.

Is that what you want, or do you want this flag saved in the policy module store and settable/clearable via semanage to be applied to all subsequent policy builds?

Quoted 196 lines

[root@scarecrow policy]# sediff -T policy.21.old \; policy.21 | grep -v dontaudit
TE Rules (Added 0, Added New Type 0, Removed 326583, Removed Missing Type 0, Modified 0)
Added TE Rules: 0
Added TE Rules because of new type: 0
Removed TE Rules: 326583
Removed TE Rules because of missing type: 0
Modified TE Rules: 0

Index: libsemanage/include/semanage/handle.h
===================================================================

include/semanage/handle.h +3 -0
@@ -69,6 +69,9 @@
  * 1 for yes, 0 for no (default) */
 void semanage_set_create_store(semanage_handle_t * handle, int create_store);
 
+/* Set whether or not to disable dontaudits upon commit */
+void semanage_set_disable_dontaudit(semanage_handle_t * handle, int disable_dontaudit);
+
 /* Check whether policy is managed via libsemanage on this system.
  * Must be called prior to trying to connect.
  * Return 1 if policy is managed via libsemanage on this system,

Index: libsemanage/src/libsemanage.map
===================================================================

src/libsemanage.map +1 -1
@@ -13,6 +13,6 @@
 	  semanage_iface_*; semanage_port_*; semanage_context_*;
 	  semanage_node_*;
 	  semanage_fcontext_*; semanage_access_check; semanage_set_create_store;
-	  semanage_is_connected;
+	  semanage_is_connected; semanage_set_disable_dontaudit;
   local: *;
 };

Index: libsemanage/src/handle.c
===================================================================

src/handle.c +8 -0
@@ -109,6 +109,14 @@
 	return;
 }
 
+void semanage_set_disable_dontaudit(semanage_handle_t * sh, int disable_dontaudit)
+{
+	assert(sh != NULL);
+	
+	sepol_set_disable_dontaudit(sh->sepolh, disable_dontaudit);
+	return;
+}
+
 int semanage_is_connected(semanage_handle_t * sh)
 {
 	assert(sh != NULL);

Index: libsepol/include/sepol/handle.h
===================================================================

include/sepol/handle.h +4 -0
@@ -7,6 +7,10 @@
 /* Create and return a sepol handle. */
 sepol_handle_t *sepol_handle_create(void);
 
+/* Set whether or not to disable dontaudits, 0 is default and does 
+ * not disable dontaudits, 1 disables them */
+void sepol_set_disable_dontaudit(sepol_handle_t * sh, int disable_dontaudit);
+
 /* Destroy a sepol handle. */
 void sepol_handle_destroy(sepol_handle_t *);
 

Index: libsepol/src/handle.h
===================================================================

src/handle.h +3 -0
@@ -14,6 +14,9 @@
 	void (*msg_callback) (void *varg,
 			      sepol_handle_t * handle, const char *fmt, ...);
 	void *msg_callback_arg;
+
+	int disable_dontaudit;
+
 };
 
 #endif

Index: libsepol/src/libsepol.map
===================================================================

src/libsepol.map +1 -0
@@ -12,5 +12,6 @@
 	sepol_policydb_*; sepol_set_policydb_from_file; 
 	sepol_policy_kern_*;
 	sepol_policy_file_*;
+	sepol_set_disable_dontaudit;
   local: *;
 };

Index: libsepol/src/expand.c
===================================================================

src/expand.c +2 -0
@@ -1367,6 +1367,8 @@
 	} else if (specified & AVRULE_AUDITDENY) {
 		spec = AVTAB_AUDITDENY;
 	} else if (specified & AVRULE_DONTAUDIT) {
+		if (handle->disable_dontaudit)
+			return EXPAND_RULE_SUCCESS;
 		spec = AVTAB_AUDITDENY;
 	} else if (specified & AVRULE_NEVERALLOW) {
 		spec = AVTAB_NEVERALLOW;

Index: libsepol/src/handle.c
===================================================================

src/handle.c +10 -0
@@ -1,4 +1,5 @@
 #include <stdlib.h>
+#include <assert.h>
 #include "handle.h"
 #include "debug.h"
 
@@ -13,9 +14,18 @@
 	sh->msg_callback = sepol_msg_default_handler;
 	sh->msg_callback_arg = NULL;
 
+	/* by default do not disable dontaudits */
+	sh->disable_dontaudit = 0;
+
 	return sh;
 }
 
+void sepol_set_disable_dontaudit(sepol_handle_t * sh, int disable_dontaudit)
+{
+	assert(sh !=NULL);
+	sh->disable_dontaudit = disable_dontaudit;
+}
+
 void sepol_handle_destroy(sepol_handle_t * sh)
 {
 	free(sh);

Index: policycoreutils/semodule/semodule.c
===================================================================

semodule/semodule.c +9 -1
@@ -44,6 +44,7 @@
 static int no_reload;
 static int create_store;
 static int build;
+static int disable_dontaudit;
 
 static semanage_handle_t *sh = NULL;
 static char *store;
@@ -131,6 +132,7 @@
 	printf("  -n,--noreload	   do not reload policy after commit\n");
 	printf("  -h,--help        print this message and quit\n");
 	printf("  -v,--verbose     be verbose\n");
+	printf("  -D,--disable_dontaudit	Remove dontaudits from policy\n");
 }
 
 /* Sets the global mode variable to new_mode, but only if no other
@@ -173,6 +175,7 @@
 		{"reload", 0, NULL, 'R'},
 		{"noreload", 0, NULL, 'n'},
 		{"build", 0, NULL, 'B'},
+		{"disable_dontaudit", 0, NULL, 'D'},
 		{NULL, 0, NULL, 0}
 	};
 	int i;
@@ -181,7 +184,7 @@
 	no_reload = 0;
 	create_store = 0;
 	while ((i =
-		getopt_long(argc, argv, "s:b:hi:lvqr:u:RnB", opts,
+		getopt_long(argc, argv, "s:b:hi:lvqr:u:RnBD", opts,
 			    NULL)) != -1) {
 		switch (i) {
 		case 'b':
@@ -218,6 +221,9 @@
 		case 'B':
 			build = 1;
 			break;
+		case 'D':
+			disable_dontaudit = 1;
+			break;
 		case '?':
 		default:{
 				usage(argv[0]);
@@ -441,6 +447,8 @@
 			semanage_set_reload(sh, 0);
 		if (build)
 			semanage_set_rebuild(sh, 1);
+		if (disable_dontaudit)
+			semanage_set_disable_dontaudit(sh, 1);
 		result = semanage_commit(sh);
 	}
 
Signature · 8 lines
Stephen Smalley
National Security Agency


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#5 lore raw
Quoted 29 lines · Stephen Smalley
Quoted 17 lines · Joshua Brindle
Quoted 15 lines · Joshua Brindle
Quoted 13 lines · James Morris
Quoted 5 lines · Eric Paris

Currently to disable dontaudit rules best you can do it to load the enableaudit.pp base policy. Which still doesn't remove the dontaudit rules from modules.

Are we sure this can't be done in userspace? Like, mangle all the existing policy and reload it?

Quoted 9 lines
Quoted 5 lines

I agree, the infrastructure is certainly in place to do it, just add something in the sepol_handle that says dontaudits should be discarded, then make an interface in libsemanage that uses that and rebuild the policy.

If noone beats me to it I will see if my conclusions about it being fairly simple are accurate this weekend :)

I changed my mind, patch below

it compiles and seems to work after semodule -DB:

Quoted 9 lines

Hmm...doing it this way means that the "disable_dontaudit" behavior won't persist across subsequent policy changes, so if I e.g. then change a boolean persistently, I'll get back all of the dontaudit rules too.

Is that what you want, or do you want this flag saved in the policy module store and settable/clearable via semanage to be applied to all subsequent policy builds?

This looks great but it needs to survive a policy rebuild as Stephen says.

Quoted 188 lines
Quoted 188 lines

[root@scarecrow policy]# sediff -T policy.21.old \; policy.21 | grep -v dontaudit
TE Rules (Added 0, Added New Type 0, Removed 326583, Removed Missing Type 0, Modified 0)
Added TE Rules: 0
Added TE Rules because of new type: 0
Removed TE Rules: 326583
Removed TE Rules because of missing type: 0
Modified TE Rules: 0

Index: libsemanage/include/semanage/handle.h
===================================================================

include/semanage/handle.h +3 -0
@@ -69,6 +69,9 @@
  * 1 for yes, 0 for no (default) */
 void semanage_set_create_store(semanage_handle_t * handle, int create_store);
 
+/* Set whether or not to disable dontaudits upon commit */
+void semanage_set_disable_dontaudit(semanage_handle_t * handle, int disable_dontaudit);
+
 /* Check whether policy is managed via libsemanage on this system.
  * Must be called prior to trying to connect.
  * Return 1 if policy is managed via libsemanage on this system,

Index: libsemanage/src/libsemanage.map
===================================================================

src/libsemanage.map +1 -1
@@ -13,6 +13,6 @@
 	  semanage_iface_*; semanage_port_*; semanage_context_*;
 	  semanage_node_*;
 	  semanage_fcontext_*; semanage_access_check; semanage_set_create_store;
-	  semanage_is_connected;
+	  semanage_is_connected; semanage_set_disable_dontaudit;
   local: *;
 };

Index: libsemanage/src/handle.c
===================================================================

src/handle.c +8 -0
@@ -109,6 +109,14 @@
 	return;
 }
 
+void semanage_set_disable_dontaudit(semanage_handle_t * sh, int disable_dontaudit)
+{
+	assert(sh != NULL);
+	
+	sepol_set_disable_dontaudit(sh->sepolh, disable_dontaudit);
+	return;
+}
+
 int semanage_is_connected(semanage_handle_t * sh)
 {
 	assert(sh != NULL);

Index: libsepol/include/sepol/handle.h
===================================================================

include/sepol/handle.h +4 -0
@@ -7,6 +7,10 @@
 /* Create and return a sepol handle. */
 sepol_handle_t *sepol_handle_create(void);
 
+/* Set whether or not to disable dontaudits, 0 is default and does 
+ * not disable dontaudits, 1 disables them */
+void sepol_set_disable_dontaudit(sepol_handle_t * sh, int disable_dontaudit);
+
 /* Destroy a sepol handle. */
 void sepol_handle_destroy(sepol_handle_t *);
 

Index: libsepol/src/handle.h
===================================================================

src/handle.h +3 -0
@@ -14,6 +14,9 @@
 	void (*msg_callback) (void *varg,
 			      sepol_handle_t * handle, const char *fmt, ...);
 	void *msg_callback_arg;
+
+	int disable_dontaudit;
+
 };
 
 #endif

Index: libsepol/src/libsepol.map
===================================================================

src/libsepol.map +1 -0
@@ -12,5 +12,6 @@
 	sepol_policydb_*; sepol_set_policydb_from_file; 
 	sepol_policy_kern_*;
 	sepol_policy_file_*;
+	sepol_set_disable_dontaudit;
   local: *;
 };

Index: libsepol/src/expand.c
===================================================================

src/expand.c +2 -0
@@ -1367,6 +1367,8 @@
 	} else if (specified & AVRULE_AUDITDENY) {
 		spec = AVTAB_AUDITDENY;
 	} else if (specified & AVRULE_DONTAUDIT) {
+		if (handle->disable_dontaudit)
+			return EXPAND_RULE_SUCCESS;
 		spec = AVTAB_AUDITDENY;
 	} else if (specified & AVRULE_NEVERALLOW) {
 		spec = AVTAB_NEVERALLOW;

Index: libsepol/src/handle.c
===================================================================

src/handle.c +10 -0
@@ -1,4 +1,5 @@
 #include <stdlib.h>
+#include <assert.h>
 #include "handle.h"
 #include "debug.h"
 
@@ -13,9 +14,18 @@
 	sh->msg_callback = sepol_msg_default_handler;
 	sh->msg_callback_arg = NULL;
 
+	/* by default do not disable dontaudits */
+	sh->disable_dontaudit = 0;
+
 	return sh;
 }
 
+void sepol_set_disable_dontaudit(sepol_handle_t * sh, int disable_dontaudit)
+{
+	assert(sh !=NULL);
+	sh->disable_dontaudit = disable_dontaudit;
+}
+
 void sepol_handle_destroy(sepol_handle_t * sh)
 {
 	free(sh);

Index: policycoreutils/semodule/semodule.c
===================================================================

semodule/semodule.c +7 -1
@@ -44,6 +44,7 @@
 static int no_reload;
 static int create_store;
 static int build;
+static int disable_dontaudit;
 
 static semanage_handle_t *sh = NULL;
 static char *store;
@@ -131,6 +132,7 @@
 	printf("  -n,--noreload	   do not reload policy after commit\n");
 	printf("  -h,--help        print this message and quit\n");
 	printf("  -v,--verbose     be verbose\n");
+	printf("  -D,--disable_dontaudit	Remove dontaudits from policy\n");
 }
 
 /* Sets the global mode variable to new_mode, but only if no other
@@ -173,6 +175,7 @@
 		{"reload", 0, NULL, 'R'},
 		{"noreload", 0, NULL, 'n'},
 		{"build", 0, NULL, 'B'},
+		{"disable_dontaudit", 0, NULL, 'D'},
 		{NULL, 0, NULL, 0}
 	};
 	int i;
@@ -181,7 +184,7 @@
 	no_reload = 0;
 	create_store = 0;
 	while ((i =
-		getopt_long(argc, argv, "s:b:hi:lvqr:u:RnB", opts,
+		getopt_long(argc, argv, "s:b:hi:lvqr:u:RnBD", opts,
 			    NULL)) != -1) {
 		switch (i) {
 		case 'b':
@@ -218,6 +221,9 @@
 		case 'B':
 			build = 1;
 			break;
+		case 'D':
+			disable_dontaudit = 1;
+			break;
 		case '?':
 		default:{
 				usage(argv[0]);
@@ -441,6 +447,8 @@
 			semanage_set_reload(sh, 0);
 		if (build)
 			semanage_set_rebuild(sh, 1);
Quoted 8 lines

semodule/semodule.c line 454

Quoted 8 lines
semodule/semodule.c +2 -0
+		if (disable_dontaudit)
+			semanage_set_disable_dontaudit(sh, 1);
 		result = semanage_commit(sh);
 	}
 

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.

#6 lore raw
Quoted 32 lines · Daniel J Walsh
Quoted 31 lines · Stephen Smalley
Quoted 15 lines · Joshua Brindle
Quoted 13 lines · Joshua Brindle
Quoted 11 lines · James Morris
Quoted 4 lines · Eric Paris

Currently to disable dontaudit rules best you can do it to load the enableaudit.pp base policy. Which still doesn't remove the dontaudit rules from modules.

Are we sure this can't be done in userspace? Like, mangle all the existing policy and reload it?

Quoted 9 lines
Quoted 5 lines

I agree, the infrastructure is certainly in place to do it, just add something in the sepol_handle that says dontaudits should be discarded, then make an interface in libsemanage that uses that and rebuild the policy.

If noone beats me to it I will see if my conclusions about it being fairly simple are accurate this weekend :)

I changed my mind, patch below

it compiles and seems to work after semodule -DB:

Hmm...doing it this way means that the "disable_dontaudit" behavior won't persist across subsequent policy changes, so if I e.g. then change a boolean persistently, I'll get back all of the dontaudit rules too.

Quoted 7 lines
Quoted 5 lines

Is that what you want, or do you want this flag saved in the policy module store and settable/clearable via semanage to be applied to all subsequent policy builds?

This looks great but it needs to survive a policy rebuild as Stephen says.

Hrm... I'm trying to figure out if that is really the behavior we want. The purpose of this was to let someone get some denials from (possibly) dontaudits hiding behavior. After switching dontaudits off the user will generate a module with the rules and insert it. Assuming they exercised enough of the app he won't want the dontaudits off anymore and will happily go about running the app. Are there other use cases where dontaudits should be persistently disabled?

If dontaudits are to be persistently disabled I'd rather do it in the kernel with eric's patch, mainly because eric's will at least only persist until reboot whereas if I added something to libsemanage to make it persist it would last across reboots.

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.

#7 lore raw
Quoted 38 lines · Joshua Brindle
Quoted 37 lines · Daniel J Walsh
Quoted 36 lines · Stephen Smalley
Quoted 15 lines · Joshua Brindle
Quoted 13 lines · Joshua Brindle
Quoted 11 lines · James Morris
Quoted 4 lines · Eric Paris

Currently to disable dontaudit rules best you can do it to load the enableaudit.pp base policy. Which still doesn't remove the dontaudit rules from modules.

Are we sure this can't be done in userspace? Like, mangle all the existing policy and reload it?

Quoted 9 lines
Quoted 5 lines

I agree, the infrastructure is certainly in place to do it, just add something in the sepol_handle that says dontaudits should be discarded, then make an interface in libsemanage that uses that and rebuild the policy.

If noone beats me to it I will see if my conclusions about it being fairly simple are accurate this weekend :)

I changed my mind, patch below

it compiles and seems to work after semodule -DB:

Hmm...doing it this way means that the "disable_dontaudit" behavior won't persist across subsequent policy changes, so if I e.g. then change a boolean persistently, I'll get back all of the dontaudit rules too.

Is that what you want, or do you want this flag saved in the policy module store and settable/clearable via semanage to be applied to all subsequent policy builds?

Quoted 7 lines
Quoted 2 lines

This looks great but it needs to survive a policy rebuild as Stephen says.

Hrm... I'm trying to figure out if that is really the behavior we want. The purpose of this was to let someone get some denials from (possibly) dontaudits hiding behavior. After switching dontaudits off the user will generate a module with the rules and insert it. Assuming they exercised enough of the app he won't want the dontaudits off anymore and will happily go about running the app. Are there other use cases where dontaudits should be persistently disabled?

If dontaudits are to be persistently disabled I'd rather do it in the kernel with eric's patch, mainly because eric's will at least only persist until reboot whereas if I added something to libsemanage to make it persist it would last across reboots.

Actually I was thinking of the case where you would put an setsebool in an init script and you might want to boot with enableaudit and this would replace it, but you wouldn't put a setsebool -P in an init script, so this is not a problem. I would guess we would just have to document that this is to temporarily disable dontaudit rules, until the next time the policy is rebuilt.

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.

#8 lore raw
Quoted 39 lines · Daniel J Walsh
Quoted 38 lines · Joshua Brindle
Quoted 37 lines · Daniel J Walsh
Quoted 36 lines · Stephen Smalley
Quoted 15 lines · Joshua Brindle
Quoted 13 lines · Joshua Brindle
Quoted 11 lines · James Morris
Quoted 4 lines · Eric Paris

Currently to disable dontaudit rules best you can do it to load the enableaudit.pp base policy. Which still doesn't remove the dontaudit rules from modules.

Are we sure this can't be done in userspace? Like, mangle all the existing policy and reload it?

Quoted 9 lines
Quoted 5 lines

I agree, the infrastructure is certainly in place to do it, just add something in the sepol_handle that says dontaudits should be discarded, then make an interface in libsemanage that uses that and rebuild the policy.

If noone beats me to it I will see if my conclusions about it being fairly simple are accurate this weekend :)

I changed my mind, patch below

it compiles and seems to work after semodule -DB:

Hmm...doing it this way means that the "disable_dontaudit" behavior won't persist across subsequent policy changes, so if I e.g. then change a boolean persistently, I'll get back all of the dontaudit rules too.

Is that what you want, or do you want this flag saved in the policy module store and settable/clearable via semanage to be applied to all subsequent policy builds?

Quoted 8 lines
Quoted 7 lines
Quoted 2 lines

This looks great but it needs to survive a policy rebuild as Stephen says.

Hrm... I'm trying to figure out if that is really the behavior we want. The purpose of this was to let someone get some denials from (possibly) dontaudits hiding behavior. After switching dontaudits off the user will generate a module with the rules and insert it. Assuming they exercised enough of the app he won't want the dontaudits off anymore and will happily go about running the app. Are there other use cases where dontaudits should be persistently disabled?

If dontaudits are to be persistently disabled I'd rather do it in the kernel with eric's patch, mainly because eric's will at least only persist until reboot whereas if I added something to libsemanage to make it persist it would last across reboots.

Actually I was thinking of the case where you would put an setsebool in an init script and you might want to boot with enableaudit and this would replace it, but you wouldn't put a setsebool -P in an init script, so this is not a problem. I would guess we would just have to document that this is to temporarily disable dontaudit rules, until the next time the policy is rebuilt.

So is there any consensus on which approach we want to go with? We have:

1) use conditionals, doesn't work with third party modules, could have mistakes where dontaudits aren't in conditionals, etc
2) use the kernel patch from Eric, makes it easier to turn it on and off without rebuilding/reloading policy, faster and some people worried about policy modification would be happier.
3) use my patch and do it from userland, puts the complexity in userspace, modifies the on-disk policy (persistent across reboots if policy isn't rebuild without the option, slower to use, not persistent across any options that rebuild policy such as persistent boolean changes, etc).

I'm split between 2 and 3, both have advantages and disadvantages, anyone else want to ring their opinion in?

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.

#9 lore raw
In reply to Joshua Brindle
Quoted 212 lines · Joshua Brindle
Quoted 13 lines · Joshua Brindle
Quoted 12 lines · James Morris
Quoted 4 lines · Eric Paris

Currently to disable dontaudit rules best you can do it to load the enableaudit.pp base policy. Which still doesn't remove the dontaudit rules from modules.

Are we sure this can't be done in userspace? Like, mangle all the existing policy and reload it?

Quoted 8 lines

I agree, the infrastructure is certainly in place to do it, just add something in the sepol_handle that says dontaudits should be discarded, then make an interface in libsemanage that uses that and rebuild the policy.

If noone beats me to it I will see if my conclusions about it being fairly simple are accurate this weekend :)

I changed my mind, patch below

it compiles and seems to work after semodule -DB:

[root@scarecrow policy]# sediff -T policy.21.old \; policy.21 | grep -v dontaudit
TE Rules (Added 0, Added New Type 0, Removed 326583, Removed Missing Type 0, Modified 0)
Added TE Rules: 0
Added TE Rules because of new type: 0
Removed TE Rules: 326583
Removed TE Rules because of missing type: 0
Modified TE Rules: 0

Index: libsemanage/include/semanage/handle.h
===================================================================

include/semanage/handle.h +3 -0
@@ -69,6 +69,9 @@
  * 1 for yes, 0 for no (default) */
 void semanage_set_create_store(semanage_handle_t * handle, int create_store);
 
+/* Set whether or not to disable dontaudits upon commit */
+void semanage_set_disable_dontaudit(semanage_handle_t * handle, int disable_dontaudit);
+
 /* Check whether policy is managed via libsemanage on this system.
  * Must be called prior to trying to connect.
  * Return 1 if policy is managed via libsemanage on this system,

Index: libsemanage/src/libsemanage.map
===================================================================

src/libsemanage.map +1 -1
@@ -13,6 +13,6 @@
 	  semanage_iface_*; semanage_port_*; semanage_context_*;
 	  semanage_node_*;
 	  semanage_fcontext_*; semanage_access_check; semanage_set_create_store;
-	  semanage_is_connected;
+	  semanage_is_connected; semanage_set_disable_dontaudit;
   local: *;
 };

Index: libsemanage/src/handle.c
===================================================================

src/handle.c +8 -0
@@ -109,6 +109,14 @@
 	return;
 }
 
+void semanage_set_disable_dontaudit(semanage_handle_t * sh, int disable_dontaudit)
+{
+	assert(sh != NULL);
+	
+	sepol_set_disable_dontaudit(sh->sepolh, disable_dontaudit);
+	return;
+}
+
 int semanage_is_connected(semanage_handle_t * sh)
 {
 	assert(sh != NULL);

Index: libsepol/include/sepol/handle.h
===================================================================

include/sepol/handle.h +4 -0
@@ -7,6 +7,10 @@
 /* Create and return a sepol handle. */
 sepol_handle_t *sepol_handle_create(void);
 
+/* Set whether or not to disable dontaudits, 0 is default and does 
+ * not disable dontaudits, 1 disables them */
+void sepol_set_disable_dontaudit(sepol_handle_t * sh, int disable_dontaudit);
+
 /* Destroy a sepol handle. */
 void sepol_handle_destroy(sepol_handle_t *);
 

Index: libsepol/src/handle.h
===================================================================

src/handle.h +3 -0
@@ -14,6 +14,9 @@
 	void (*msg_callback) (void *varg,
 			      sepol_handle_t * handle, const char *fmt, ...);
 	void *msg_callback_arg;
+
+	int disable_dontaudit;
+
 };
 
 #endif

Index: libsepol/src/libsepol.map
===================================================================

src/libsepol.map +1 -0
@@ -12,5 +12,6 @@
 	sepol_policydb_*; sepol_set_policydb_from_file; 
 	sepol_policy_kern_*;
 	sepol_policy_file_*;
+	sepol_set_disable_dontaudit;
   local: *;
 };

Index: libsepol/src/expand.c
===================================================================

src/expand.c +2 -0
@@ -1367,6 +1367,8 @@
 	} else if (specified & AVRULE_AUDITDENY) {
 		spec = AVTAB_AUDITDENY;
 	} else if (specified & AVRULE_DONTAUDIT) {
+		if (handle->disable_dontaudit)
+			return EXPAND_RULE_SUCCESS;
 		spec = AVTAB_AUDITDENY;
 	} else if (specified & AVRULE_NEVERALLOW) {
 		spec = AVTAB_NEVERALLOW;

Index: libsepol/src/handle.c
===================================================================

src/handle.c +10 -0
@@ -1,4 +1,5 @@
 #include <stdlib.h>
+#include <assert.h>
 #include "handle.h"
 #include "debug.h"
 
@@ -13,9 +14,18 @@
 	sh->msg_callback = sepol_msg_default_handler;
 	sh->msg_callback_arg = NULL;
 
+	/* by default do not disable dontaudits */
+	sh->disable_dontaudit = 0;
+
 	return sh;
 }
 
+void sepol_set_disable_dontaudit(sepol_handle_t * sh, int disable_dontaudit)
+{
+	assert(sh !=NULL);
+	sh->disable_dontaudit = disable_dontaudit;
+}
+
 void sepol_handle_destroy(sepol_handle_t * sh)
 {
 	free(sh);

Index: policycoreutils/semodule/semodule.c
===================================================================

semodule/semodule.c +7 -1
@@ -44,6 +44,7 @@
 static int no_reload;
 static int create_store;
 static int build;
+static int disable_dontaudit;
 
 static semanage_handle_t *sh = NULL;
 static char *store;
@@ -131,6 +132,7 @@
 	printf("  -n,--noreload	   do not reload policy after commit\n");
 	printf("  -h,--help        print this message and quit\n");
 	printf("  -v,--verbose     be verbose\n");
+	printf("  -D,--disable_dontaudit	Remove dontaudits from policy\n");
 }
 
 /* Sets the global mode variable to new_mode, but only if no other
@@ -173,6 +175,7 @@
 		{"reload", 0, NULL, 'R'},
 		{"noreload", 0, NULL, 'n'},
 		{"build", 0, NULL, 'B'},
+		{"disable_dontaudit", 0, NULL, 'D'},
 		{NULL, 0, NULL, 0}
 	};
 	int i;
@@ -181,7 +184,7 @@
 	no_reload = 0;
 	create_store = 0;
 	while ((i =
-		getopt_long(argc, argv, "s:b:hi:lvqr:u:RnB", opts,
+		getopt_long(argc, argv, "s:b:hi:lvqr:u:RnBD", opts,
 			    NULL)) != -1) {
 		switch (i) {
 		case 'b':
@@ -218,6 +221,9 @@
 		case 'B':
 			build = 1;
 			break;
+		case 'D':
+			disable_dontaudit = 1;
+			break;
 		case '?':
 		default:{
 				usage(argv[0]);

semodule/semodule.c line 453

Quoted 7 lines
semodule/semodule.c +2 -0
@@ -441,6 +447,8 @@
 			semanage_set_reload(sh, 0);
 		if (build)
 			semanage_set_rebuild(sh, 1);
+		if (disable_dontaudit)
+			semanage_set_disable_dontaudit(sh, 1);
 		result = semanage_commit(sh);
 	}

Merge at will.

Signature · 8 lines
Stephen Smalley
National Security Agency


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#10 lore raw
Quoted 224 lines · Stephen Smalley
Quoted 211 lines · Joshua Brindle
Quoted 11 lines · Joshua Brindle
Quoted 9 lines · James Morris
Quoted 5 lines · Eric Paris

Currently to disable dontaudit rules best you can do it to load the enableaudit.pp base policy. Which still doesn't remove the dontaudit rules from modules.

Quoted 9 lines
Quoted 4 lines

Are we sure this can't be done in userspace? Like, mangle all the existing policy and reload it?

I agree, the infrastructure is certainly in place to do it, just add something in the sepol_handle that says dontaudits should be discarded, then make an interface in libsemanage that uses that and rebuild the policy.

If noone beats me to it I will see if my conclusions about it being fairly simple are accurate this weekend :)

I changed my mind, patch below

it compiles and seems to work after semodule -DB:

[root@scarecrow policy]# sediff -T policy.21.old \; policy.21 | grep -v dontaudit
TE Rules (Added 0, Added New Type 0, Removed 326583, Removed Missing Type 0, Modified 0)
Added TE Rules: 0
Added TE Rules because of new type: 0
Removed TE Rules: 326583
Removed TE Rules because of missing type: 0
Modified TE Rules: 0

Index: libsemanage/include/semanage/handle.h
===================================================================

include/semanage/handle.h +3 -0
@@ -69,6 +69,9 @@
  * 1 for yes, 0 for no (default) */
 void semanage_set_create_store(semanage_handle_t * handle, int create_store);
 
+/* Set whether or not to disable dontaudits upon commit */
+void semanage_set_disable_dontaudit(semanage_handle_t * handle, int disable_dontaudit);
+
 /* Check whether policy is managed via libsemanage on this system.
  * Must be called prior to trying to connect.
  * Return 1 if policy is managed via libsemanage on this system,

Index: libsemanage/src/libsemanage.map
===================================================================

src/libsemanage.map +1 -1
@@ -13,6 +13,6 @@
 	  semanage_iface_*; semanage_port_*; semanage_context_*;
 	  semanage_node_*;
 	  semanage_fcontext_*; semanage_access_check; semanage_set_create_store;
-	  semanage_is_connected;
+	  semanage_is_connected; semanage_set_disable_dontaudit;
   local: *;
 };

Index: libsemanage/src/handle.c
===================================================================

src/handle.c +8 -0
@@ -109,6 +109,14 @@
 	return;
 }
 
+void semanage_set_disable_dontaudit(semanage_handle_t * sh, int disable_dontaudit)
+{
+	assert(sh != NULL);
+	
+	sepol_set_disable_dontaudit(sh->sepolh, disable_dontaudit);
+	return;
+}
+
 int semanage_is_connected(semanage_handle_t * sh)
 {
 	assert(sh != NULL);

Index: libsepol/include/sepol/handle.h
===================================================================

include/sepol/handle.h +4 -0
@@ -7,6 +7,10 @@
 /* Create and return a sepol handle. */
 sepol_handle_t *sepol_handle_create(void);
 
+/* Set whether or not to disable dontaudits, 0 is default and does 
+ * not disable dontaudits, 1 disables them */
+void sepol_set_disable_dontaudit(sepol_handle_t * sh, int disable_dontaudit);
+
 /* Destroy a sepol handle. */
 void sepol_handle_destroy(sepol_handle_t *);
 

Index: libsepol/src/handle.h
===================================================================

src/handle.h +3 -0
@@ -14,6 +14,9 @@
 	void (*msg_callback) (void *varg,
 			      sepol_handle_t * handle, const char *fmt, ...);
 	void *msg_callback_arg;
+
+	int disable_dontaudit;
+
 };
 
 #endif

Index: libsepol/src/libsepol.map
===================================================================

src/libsepol.map +1 -0
@@ -12,5 +12,6 @@
 	sepol_policydb_*; sepol_set_policydb_from_file; 
 	sepol_policy_kern_*;
 	sepol_policy_file_*;
+	sepol_set_disable_dontaudit;
   local: *;
 };

Index: libsepol/src/expand.c
===================================================================

src/expand.c +2 -0
@@ -1367,6 +1367,8 @@
 	} else if (specified & AVRULE_AUDITDENY) {
 		spec = AVTAB_AUDITDENY;
 	} else if (specified & AVRULE_DONTAUDIT) {
+		if (handle->disable_dontaudit)
+			return EXPAND_RULE_SUCCESS;
 		spec = AVTAB_AUDITDENY;
 	} else if (specified & AVRULE_NEVERALLOW) {
 		spec = AVTAB_NEVERALLOW;

Index: libsepol/src/handle.c
===================================================================

src/handle.c +10 -0
@@ -1,4 +1,5 @@
 #include <stdlib.h>
+#include <assert.h>
 #include "handle.h"
 #include "debug.h"
 
@@ -13,9 +14,18 @@
 	sh->msg_callback = sepol_msg_default_handler;
 	sh->msg_callback_arg = NULL;
 
+	/* by default do not disable dontaudits */
+	sh->disable_dontaudit = 0;
+
 	return sh;
 }
 
+void sepol_set_disable_dontaudit(sepol_handle_t * sh, int disable_dontaudit)
+{
+	assert(sh !=NULL);
+	sh->disable_dontaudit = disable_dontaudit;
+}
+
 void sepol_handle_destroy(sepol_handle_t * sh)
 {
 	free(sh);

Index: policycoreutils/semodule/semodule.c
===================================================================

semodule/semodule.c +7 -1
@@ -44,6 +44,7 @@
 static int no_reload;
 static int create_store;
 static int build;
+static int disable_dontaudit;
 
 static semanage_handle_t *sh = NULL;
 static char *store;
@@ -131,6 +132,7 @@
 	printf("  -n,--noreload	   do not reload policy after commit\n");
 	printf("  -h,--help        print this message and quit\n");
 	printf("  -v,--verbose     be verbose\n");
+	printf("  -D,--disable_dontaudit	Remove dontaudits from policy\n");
 }
 
 /* Sets the global mode variable to new_mode, but only if no other
@@ -173,6 +175,7 @@
 		{"reload", 0, NULL, 'R'},
 		{"noreload", 0, NULL, 'n'},
 		{"build", 0, NULL, 'B'},
+		{"disable_dontaudit", 0, NULL, 'D'},
 		{NULL, 0, NULL, 0}
 	};
 	int i;
@@ -181,7 +184,7 @@
 	no_reload = 0;
 	create_store = 0;
 	while ((i =
-		getopt_long(argc, argv, "s:b:hi:lvqr:u:RnB", opts,
+		getopt_long(argc, argv, "s:b:hi:lvqr:u:RnBD", opts,
 			    NULL)) != -1) {
 		switch (i) {
 		case 'b':
@@ -218,6 +221,9 @@
 		case 'B':
 			build = 1;
 			break;
+		case 'D':
+			disable_dontaudit = 1;
+			break;
 		case '?':
 		default:{
 				usage(argv[0]);

semodule/semodule.c line 454

Quoted 8 lines
semodule/semodule.c +2 -0
@@ -441,6 +447,8 @@
 			semanage_set_reload(sh, 0);
 		if (build)
 			semanage_set_rebuild(sh, 1);
+		if (disable_dontaudit)
+			semanage_set_disable_dontaudit(sh, 1);
 		result = semanage_commit(sh);
 	}
 
Quoted 2 lines

Merge at will.

So did we decide that the disadvantages of this approach are fine? The one that bothers me is that rebooting doesn't reset the dontaudit state (like it would with Eric's patch)...

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.

#11 lore raw
Quoted 230 lines · Joshua Brindle
Quoted 229 lines · Stephen Smalley
Quoted 216 lines · Joshua Brindle
Quoted 16 lines · Joshua Brindle
Quoted 4 lines · James Morris

On Thu, 9 Aug 2007, Eric Paris wrote:

Quoted 10 lines
Quoted 5 lines

Currently to disable dontaudit rules best you can do it to load the enableaudit.pp base policy. Which still doesn't remove the dontaudit rules from modules.

Are we sure this can't be done in userspace? Like, mangle all the existing policy and reload it?

Quoted 9 lines

I agree, the infrastructure is certainly in place to do it, just add something in the sepol_handle that says dontaudits should be discarded, then make an interface in libsemanage that uses that and rebuild the policy.

If noone beats me to it I will see if my conclusions about it being fairly simple are accurate this weekend :)

I changed my mind, patch below

it compiles and seems to work after semodule -DB:

[root@scarecrow policy]# sediff -T policy.21.old \; policy.21 | grep -v dontaudit
TE Rules (Added 0, Added New Type 0, Removed 326583, Removed Missing Type 0, Modified 0)
Added TE Rules: 0
Added TE Rules because of new type: 0
Removed TE Rules: 326583
Removed TE Rules because of missing type: 0
Modified TE Rules: 0

Index: libsemanage/include/semanage/handle.h
===================================================================

include/semanage/handle.h +3 -0
@@ -69,6 +69,9 @@
  * 1 for yes, 0 for no (default) */
 void semanage_set_create_store(semanage_handle_t * handle, int create_store);
 
+/* Set whether or not to disable dontaudits upon commit */
+void semanage_set_disable_dontaudit(semanage_handle_t * handle, int disable_dontaudit);
+
 /* Check whether policy is managed via libsemanage on this system.
  * Must be called prior to trying to connect.
  * Return 1 if policy is managed via libsemanage on this system,

Index: libsemanage/src/libsemanage.map
===================================================================

src/libsemanage.map +1 -1
@@ -13,6 +13,6 @@
 	  semanage_iface_*; semanage_port_*; semanage_context_*;
 	  semanage_node_*;
 	  semanage_fcontext_*; semanage_access_check; semanage_set_create_store;
-	  semanage_is_connected;
+	  semanage_is_connected; semanage_set_disable_dontaudit;
   local: *;
 };

Index: libsemanage/src/handle.c
===================================================================

src/handle.c +8 -0
@@ -109,6 +109,14 @@
 	return;
 }
 
+void semanage_set_disable_dontaudit(semanage_handle_t * sh, int disable_dontaudit)
+{
+	assert(sh != NULL);
+	
+	sepol_set_disable_dontaudit(sh->sepolh, disable_dontaudit);
+	return;
+}
+
 int semanage_is_connected(semanage_handle_t * sh)
 {
 	assert(sh != NULL);

Index: libsepol/include/sepol/handle.h
===================================================================

include/sepol/handle.h +4 -0
@@ -7,6 +7,10 @@
 /* Create and return a sepol handle. */
 sepol_handle_t *sepol_handle_create(void);
 
+/* Set whether or not to disable dontaudits, 0 is default and does 
+ * not disable dontaudits, 1 disables them */
+void sepol_set_disable_dontaudit(sepol_handle_t * sh, int disable_dontaudit);
+
 /* Destroy a sepol handle. */
 void sepol_handle_destroy(sepol_handle_t *);
 

Index: libsepol/src/handle.h
===================================================================

src/handle.h +3 -0
@@ -14,6 +14,9 @@
 	void (*msg_callback) (void *varg,
 			      sepol_handle_t * handle, const char *fmt, ...);
 	void *msg_callback_arg;
+
+	int disable_dontaudit;
+
 };
 
 #endif

Index: libsepol/src/libsepol.map
===================================================================

src/libsepol.map +1 -0
@@ -12,5 +12,6 @@
 	sepol_policydb_*; sepol_set_policydb_from_file; 
 	sepol_policy_kern_*;
 	sepol_policy_file_*;
+	sepol_set_disable_dontaudit;
   local: *;
 };

Index: libsepol/src/expand.c
===================================================================

src/expand.c +2 -0
@@ -1367,6 +1367,8 @@
 	} else if (specified & AVRULE_AUDITDENY) {
 		spec = AVTAB_AUDITDENY;
 	} else if (specified & AVRULE_DONTAUDIT) {
+		if (handle->disable_dontaudit)
+			return EXPAND_RULE_SUCCESS;
 		spec = AVTAB_AUDITDENY;
 	} else if (specified & AVRULE_NEVERALLOW) {
 		spec = AVTAB_NEVERALLOW;

Index: libsepol/src/handle.c
===================================================================

src/handle.c +10 -0
@@ -1,4 +1,5 @@
 #include <stdlib.h>
+#include <assert.h>
 #include "handle.h"
 #include "debug.h"
 
@@ -13,9 +14,18 @@
 	sh->msg_callback = sepol_msg_default_handler;
 	sh->msg_callback_arg = NULL;
 
+	/* by default do not disable dontaudits */
+	sh->disable_dontaudit = 0;
+
 	return sh;
 }
 
+void sepol_set_disable_dontaudit(sepol_handle_t * sh, int disable_dontaudit)
+{
+	assert(sh !=NULL);
+	sh->disable_dontaudit = disable_dontaudit;
+}
+
 void sepol_handle_destroy(sepol_handle_t * sh)
 {
 	free(sh);

Index: policycoreutils/semodule/semodule.c
===================================================================

semodule/semodule.c +7 -1
@@ -44,6 +44,7 @@
 static int no_reload;
 static int create_store;
 static int build;
+static int disable_dontaudit;
 
 static semanage_handle_t *sh = NULL;
 static char *store;
@@ -131,6 +132,7 @@
 	printf("  -n,--noreload	   do not reload policy after commit\n");
 	printf("  -h,--help        print this message and quit\n");
 	printf("  -v,--verbose     be verbose\n");
+	printf("  -D,--disable_dontaudit	Remove dontaudits from policy\n");
 }
 
 /* Sets the global mode variable to new_mode, but only if no other
@@ -173,6 +175,7 @@
 		{"reload", 0, NULL, 'R'},
 		{"noreload", 0, NULL, 'n'},
 		{"build", 0, NULL, 'B'},
+		{"disable_dontaudit", 0, NULL, 'D'},
 		{NULL, 0, NULL, 0}
 	};
 	int i;
@@ -181,7 +184,7 @@
 	no_reload = 0;
 	create_store = 0;
 	while ((i =
-		getopt_long(argc, argv, "s:b:hi:lvqr:u:RnB", opts,
+		getopt_long(argc, argv, "s:b:hi:lvqr:u:RnBD", opts,
 			    NULL)) != -1) {
 		switch (i) {
 		case 'b':
@@ -218,6 +221,9 @@
 		case 'B':
 			build = 1;
 			break;
+		case 'D':
+			disable_dontaudit = 1;
+			break;
 		case '?':
 		default:{
 				usage(argv[0]);

semodule/semodule.c line 454

Quoted 8 lines
semodule/semodule.c +2 -0
@@ -441,6 +447,8 @@
 			semanage_set_reload(sh, 0);
 		if (build)
 			semanage_set_rebuild(sh, 1);
+		if (disable_dontaudit)
+			semanage_set_disable_dontaudit(sh, 1);
 		result = semanage_commit(sh);
 	}
 
Quoted 6 lines
Quoted 2 lines

Merge at will.

So did we decide that the disadvantages of this approach are fine? The one that bothers me is that rebooting doesn't reset the dontaudit state (like it would with Eric's patch)...

That could be an advantage - suppose that you want to collect full audit information on the initialization itself. And it isn't different than the old 'make enableaudit load' approach.

Signature · 8 lines
Stephen Smalley
National Security Agency


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#12 lore raw
Quoted 238 lines · Stephen Smalley
Quoted 236 lines · Joshua Brindle
Quoted 234 lines · Stephen Smalley
Quoted 218 lines · Joshua Brindle
Quoted 14 lines · Joshua Brindle
Quoted 11 lines · James Morris
Quoted 6 lines · Eric Paris

Currently to disable dontaudit rules best you can do it to load the enableaudit.pp base policy. Which still doesn't remove the dontaudit rules from modules.

Quoted 11 lines
Quoted 5 lines

Are we sure this can't be done in userspace? Like, mangle all the existing policy and reload it?

I agree, the infrastructure is certainly in place to do it, just add something in the sepol_handle that says dontaudits should be discarded, then make an interface in libsemanage that uses that and rebuild the policy.

If noone beats me to it I will see if my conclusions about it being fairly simple are accurate this weekend :)

I changed my mind, patch below

it compiles and seems to work after semodule -DB:

[root@scarecrow policy]# sediff -T policy.21.old \; policy.21 | grep -v dontaudit
TE Rules (Added 0, Added New Type 0, Removed 326583, Removed Missing Type 0, Modified 0)
Added TE Rules: 0
Added TE Rules because of new type: 0
Removed TE Rules: 326583
Removed TE Rules because of missing type: 0
Modified TE Rules: 0

Index: libsemanage/include/semanage/handle.h
===================================================================

include/semanage/handle.h +3 -0
@@ -69,6 +69,9 @@
  * 1 for yes, 0 for no (default) */
 void semanage_set_create_store(semanage_handle_t * handle, int create_store);
 
+/* Set whether or not to disable dontaudits upon commit */
+void semanage_set_disable_dontaudit(semanage_handle_t * handle, int disable_dontaudit);
+
 /* Check whether policy is managed via libsemanage on this system.
  * Must be called prior to trying to connect.
  * Return 1 if policy is managed via libsemanage on this system,

Index: libsemanage/src/libsemanage.map
===================================================================

src/libsemanage.map +1 -1
@@ -13,6 +13,6 @@
 	  semanage_iface_*; semanage_port_*; semanage_context_*;
 	  semanage_node_*;
 	  semanage_fcontext_*; semanage_access_check; semanage_set_create_store;
-	  semanage_is_connected;
+	  semanage_is_connected; semanage_set_disable_dontaudit;
   local: *;
 };

Index: libsemanage/src/handle.c
===================================================================

src/handle.c +8 -0
@@ -109,6 +109,14 @@
 	return;
 }
 
+void semanage_set_disable_dontaudit(semanage_handle_t * sh, int disable_dontaudit)
+{
+	assert(sh != NULL);
+	
+	sepol_set_disable_dontaudit(sh->sepolh, disable_dontaudit);
+	return;
+}
+
 int semanage_is_connected(semanage_handle_t * sh)
 {
 	assert(sh != NULL);

Index: libsepol/include/sepol/handle.h
===================================================================

include/sepol/handle.h +4 -0
@@ -7,6 +7,10 @@
 /* Create and return a sepol handle. */
 sepol_handle_t *sepol_handle_create(void);
 
+/* Set whether or not to disable dontaudits, 0 is default and does 
+ * not disable dontaudits, 1 disables them */
+void sepol_set_disable_dontaudit(sepol_handle_t * sh, int disable_dontaudit);
+
 /* Destroy a sepol handle. */
 void sepol_handle_destroy(sepol_handle_t *);
 

Index: libsepol/src/handle.h
===================================================================

src/handle.h +3 -0
@@ -14,6 +14,9 @@
 	void (*msg_callback) (void *varg,
 			      sepol_handle_t * handle, const char *fmt, ...);
 	void *msg_callback_arg;
+
+	int disable_dontaudit;
+
 };
 
 #endif

Index: libsepol/src/libsepol.map
===================================================================

src/libsepol.map +1 -0
@@ -12,5 +12,6 @@
 	sepol_policydb_*; sepol_set_policydb_from_file; 
 	sepol_policy_kern_*;
 	sepol_policy_file_*;
+	sepol_set_disable_dontaudit;
   local: *;
 };

Index: libsepol/src/expand.c
===================================================================

src/expand.c +2 -0
@@ -1367,6 +1367,8 @@
 	} else if (specified & AVRULE_AUDITDENY) {
 		spec = AVTAB_AUDITDENY;
 	} else if (specified & AVRULE_DONTAUDIT) {
+		if (handle->disable_dontaudit)
+			return EXPAND_RULE_SUCCESS;
 		spec = AVTAB_AUDITDENY;
 	} else if (specified & AVRULE_NEVERALLOW) {
 		spec = AVTAB_NEVERALLOW;

Index: libsepol/src/handle.c
===================================================================

src/handle.c +10 -0
@@ -1,4 +1,5 @@
 #include <stdlib.h>
+#include <assert.h>
 #include "handle.h"
 #include "debug.h"
 
@@ -13,9 +14,18 @@
 	sh->msg_callback = sepol_msg_default_handler;
 	sh->msg_callback_arg = NULL;
 
+	/* by default do not disable dontaudits */
+	sh->disable_dontaudit = 0;
+
 	return sh;
 }
 
+void sepol_set_disable_dontaudit(sepol_handle_t * sh, int disable_dontaudit)
+{
+	assert(sh !=NULL);
+	sh->disable_dontaudit = disable_dontaudit;
+}
+
 void sepol_handle_destroy(sepol_handle_t * sh)
 {
 	free(sh);

Index: policycoreutils/semodule/semodule.c
===================================================================

semodule/semodule.c +7 -1
@@ -44,6 +44,7 @@
 static int no_reload;
 static int create_store;
 static int build;
+static int disable_dontaudit;
 
 static semanage_handle_t *sh = NULL;
 static char *store;
@@ -131,6 +132,7 @@
 	printf("  -n,--noreload	   do not reload policy after commit\n");
 	printf("  -h,--help        print this message and quit\n");
 	printf("  -v,--verbose     be verbose\n");
+	printf("  -D,--disable_dontaudit	Remove dontaudits from policy\n");
 }
 
 /* Sets the global mode variable to new_mode, but only if no other
@@ -173,6 +175,7 @@
 		{"reload", 0, NULL, 'R'},
 		{"noreload", 0, NULL, 'n'},
 		{"build", 0, NULL, 'B'},
+		{"disable_dontaudit", 0, NULL, 'D'},
 		{NULL, 0, NULL, 0}
 	};
 	int i;
@@ -181,7 +184,7 @@
 	no_reload = 0;
 	create_store = 0;
 	while ((i =
-		getopt_long(argc, argv, "s:b:hi:lvqr:u:RnB", opts,
+		getopt_long(argc, argv, "s:b:hi:lvqr:u:RnBD", opts,
 			    NULL)) != -1) {
 		switch (i) {
 		case 'b':
@@ -218,6 +221,9 @@
 		case 'B':
 			build = 1;
 			break;
+		case 'D':
+			disable_dontaudit = 1;
+			break;
 		case '?':
 		default:{
 				usage(argv[0]);

semodule/semodule.c line 454

Quoted 8 lines
semodule/semodule.c +2 -0
@@ -441,6 +447,8 @@
 			semanage_set_reload(sh, 0);
 		if (build)
 			semanage_set_rebuild(sh, 1);
+		if (disable_dontaudit)
+			semanage_set_disable_dontaudit(sh, 1);
 		result = semanage_commit(sh);
 	}
 

Merge at will.

Quoted 7 lines
Quoted 2 lines

So did we decide that the disadvantages of this approach are fine? The one that bothers me is that rebooting doesn't reset the dontaudit state (like it would with Eric's patch)...

That could be an advantage - suppose that you want to collect full audit information on the initialization itself. And it isn't different than the old 'make enableaudit load' approach.

Good point, ok, I'll merge this in a bit, are there any other pending merges?

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.

#13 lore raw
Quoted 249 lines · Joshua Brindle
Quoted 248 lines · Stephen Smalley
Quoted 245 lines · Joshua Brindle
Quoted 236 lines · Stephen Smalley
Quoted 223 lines · Joshua Brindle
Quoted 20 lines · Joshua Brindle
Quoted 5 lines · James Morris

On Thu, 9 Aug 2007, Eric Paris wrote:

Quoted 12 lines
Quoted 6 lines

Currently to disable dontaudit rules best you can do it to load the enableaudit.pp base policy. Which still doesn't remove the dontaudit rules from modules.

Are we sure this can't be done in userspace? Like, mangle all the existing policy and reload it?

Quoted 10 lines

I agree, the infrastructure is certainly in place to do it, just add something in the sepol_handle that says dontaudits should be discarded, then make an interface in libsemanage that uses that and rebuild the policy.

If noone beats me to it I will see if my conclusions about it being fairly simple are accurate this weekend :)

I changed my mind, patch below

it compiles and seems to work after semodule -DB:

[root@scarecrow policy]# sediff -T policy.21.old \; policy.21 | grep -v dontaudit
TE Rules (Added 0, Added New Type 0, Removed 326583, Removed Missing Type 0, Modified 0)
Added TE Rules: 0
Added TE Rules because of new type: 0
Removed TE Rules: 326583
Removed TE Rules because of missing type: 0
Modified TE Rules: 0

Index: libsemanage/include/semanage/handle.h
===================================================================

include/semanage/handle.h +3 -0
@@ -69,6 +69,9 @@
  * 1 for yes, 0 for no (default) */
 void semanage_set_create_store(semanage_handle_t * handle, int create_store);
 
+/* Set whether or not to disable dontaudits upon commit */
+void semanage_set_disable_dontaudit(semanage_handle_t * handle, int disable_dontaudit);
+
 /* Check whether policy is managed via libsemanage on this system.
  * Must be called prior to trying to connect.
  * Return 1 if policy is managed via libsemanage on this system,

Index: libsemanage/src/libsemanage.map
===================================================================

src/libsemanage.map +1 -1
@@ -13,6 +13,6 @@
 	  semanage_iface_*; semanage_port_*; semanage_context_*;
 	  semanage_node_*;
 	  semanage_fcontext_*; semanage_access_check; semanage_set_create_store;
-	  semanage_is_connected;
+	  semanage_is_connected; semanage_set_disable_dontaudit;
   local: *;
 };

Index: libsemanage/src/handle.c
===================================================================

src/handle.c +8 -0
@@ -109,6 +109,14 @@
 	return;
 }
 
+void semanage_set_disable_dontaudit(semanage_handle_t * sh, int disable_dontaudit)
+{
+	assert(sh != NULL);
+	
+	sepol_set_disable_dontaudit(sh->sepolh, disable_dontaudit);
+	return;
+}
+
 int semanage_is_connected(semanage_handle_t * sh)
 {
 	assert(sh != NULL);

Index: libsepol/include/sepol/handle.h
===================================================================

include/sepol/handle.h +4 -0
@@ -7,6 +7,10 @@
 /* Create and return a sepol handle. */
 sepol_handle_t *sepol_handle_create(void);
 
+/* Set whether or not to disable dontaudits, 0 is default and does 
+ * not disable dontaudits, 1 disables them */
+void sepol_set_disable_dontaudit(sepol_handle_t * sh, int disable_dontaudit);
+
 /* Destroy a sepol handle. */
 void sepol_handle_destroy(sepol_handle_t *);
 

Index: libsepol/src/handle.h
===================================================================

src/handle.h +3 -0
@@ -14,6 +14,9 @@
 	void (*msg_callback) (void *varg,
 			      sepol_handle_t * handle, const char *fmt, ...);
 	void *msg_callback_arg;
+
+	int disable_dontaudit;
+
 };
 
 #endif

Index: libsepol/src/libsepol.map
===================================================================

src/libsepol.map +1 -0
@@ -12,5 +12,6 @@
 	sepol_policydb_*; sepol_set_policydb_from_file; 
 	sepol_policy_kern_*;
 	sepol_policy_file_*;
+	sepol_set_disable_dontaudit;
   local: *;
 };

Index: libsepol/src/expand.c
===================================================================

src/expand.c +2 -0
@@ -1367,6 +1367,8 @@
 	} else if (specified & AVRULE_AUDITDENY) {
 		spec = AVTAB_AUDITDENY;
 	} else if (specified & AVRULE_DONTAUDIT) {
+		if (handle->disable_dontaudit)
+			return EXPAND_RULE_SUCCESS;
 		spec = AVTAB_AUDITDENY;
 	} else if (specified & AVRULE_NEVERALLOW) {
 		spec = AVTAB_NEVERALLOW;

Index: libsepol/src/handle.c
===================================================================

src/handle.c +10 -0
@@ -1,4 +1,5 @@
 #include <stdlib.h>
+#include <assert.h>
 #include "handle.h"
 #include "debug.h"
 
@@ -13,9 +14,18 @@
 	sh->msg_callback = sepol_msg_default_handler;
 	sh->msg_callback_arg = NULL;
 
+	/* by default do not disable dontaudits */
+	sh->disable_dontaudit = 0;
+
 	return sh;
 }
 
+void sepol_set_disable_dontaudit(sepol_handle_t * sh, int disable_dontaudit)
+{
+	assert(sh !=NULL);
+	sh->disable_dontaudit = disable_dontaudit;
+}
+
 void sepol_handle_destroy(sepol_handle_t * sh)
 {
 	free(sh);

Index: policycoreutils/semodule/semodule.c
===================================================================

semodule/semodule.c +7 -1
@@ -44,6 +44,7 @@
 static int no_reload;
 static int create_store;
 static int build;
+static int disable_dontaudit;
 
 static semanage_handle_t *sh = NULL;
 static char *store;
@@ -131,6 +132,7 @@
 	printf("  -n,--noreload	   do not reload policy after commit\n");
 	printf("  -h,--help        print this message and quit\n");
 	printf("  -v,--verbose     be verbose\n");
+	printf("  -D,--disable_dontaudit	Remove dontaudits from policy\n");
 }
 
 /* Sets the global mode variable to new_mode, but only if no other
@@ -173,6 +175,7 @@
 		{"reload", 0, NULL, 'R'},
 		{"noreload", 0, NULL, 'n'},
 		{"build", 0, NULL, 'B'},
+		{"disable_dontaudit", 0, NULL, 'D'},
 		{NULL, 0, NULL, 0}
 	};
 	int i;
@@ -181,7 +184,7 @@
 	no_reload = 0;
 	create_store = 0;
 	while ((i =
-		getopt_long(argc, argv, "s:b:hi:lvqr:u:RnB", opts,
+		getopt_long(argc, argv, "s:b:hi:lvqr:u:RnBD", opts,
 			    NULL)) != -1) {
 		switch (i) {
 		case 'b':
@@ -218,6 +221,9 @@
 		case 'B':
 			build = 1;
 			break;
+		case 'D':
+			disable_dontaudit = 1;
+			break;
 		case '?':
 		default:{
 				usage(argv[0]);

semodule/semodule.c line 454

Quoted 8 lines
semodule/semodule.c +2 -0
@@ -441,6 +447,8 @@
 			semanage_set_reload(sh, 0);
 		if (build)
 			semanage_set_rebuild(sh, 1);
+		if (disable_dontaudit)
+			semanage_set_disable_dontaudit(sh, 1);
 		result = semanage_commit(sh);
 	}
 
Quoted 3 lines

Merge at will.

So did we decide that the disadvantages of this approach are fine? The one that bothers me is that rebooting doesn't reset the dontaudit state (like it would with Eric's patch)...

Quoted 7 lines
Quoted 4 lines

That could be an advantage - suppose that you want to collect full audit information on the initialization itself. And it isn't different than the old 'make enableaudit load' approach.

Good point, ok, I'll merge this in a bit, are there any other pending merges?

Some of Dan's policycoreutils patches are trivial or simple bug fixes. Others are less clear to me.

I was going to test the libsemanage genhomedircon patches, but haven't done so yet. I don't have a problem with them conceptually. Have you verified that they yield no change in output under -targeted and -strict policy? And run them under valgrind?

Eric's handle unknown patches are still outstanding. Dan, if we merged that support, would you use it in building future policies?

Karl's sepolgen bug fix looks fine to merge.

I (or someone) have to rework libsepol in stable and trunk to avoid unaligned accesses (as per the wrong magic number thread). Already did it once for the kernel. Sigh.

Signature · 8 lines
Stephen Smalley
National Security Agency


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#14 lore raw
Quoted 258 lines · Stephen Smalley
Quoted 249 lines · Joshua Brindle
Quoted 248 lines · Stephen Smalley
Quoted 245 lines · Joshua Brindle
Quoted 236 lines · Stephen Smalley
Quoted 223 lines · Joshua Brindle
Quoted 20 lines · Joshua Brindle
Quoted 5 lines · James Morris

On Thu, 9 Aug 2007, Eric Paris wrote:

Quoted 12 lines
Quoted 6 lines

Currently to disable dontaudit rules best you can do it to load the enableaudit.pp base policy. Which still doesn't remove the dontaudit rules from modules.

Are we sure this can't be done in userspace? Like, mangle all the existing policy and reload it?

Quoted 10 lines

I agree, the infrastructure is certainly in place to do it, just add something in the sepol_handle that says dontaudits should be discarded, then make an interface in libsemanage that uses that and rebuild the policy.

If noone beats me to it I will see if my conclusions about it being fairly simple are accurate this weekend :)

I changed my mind, patch below

it compiles and seems to work after semodule -DB:

[root@scarecrow policy]# sediff -T policy.21.old \; policy.21 | grep -v dontaudit
TE Rules (Added 0, Added New Type 0, Removed 326583, Removed Missing Type 0, Modified 0)
Added TE Rules: 0
Added TE Rules because of new type: 0
Removed TE Rules: 326583
Removed TE Rules because of missing type: 0
Modified TE Rules: 0

Index: libsemanage/include/semanage/handle.h
===================================================================

include/semanage/handle.h +3 -0
@@ -69,6 +69,9 @@
  * 1 for yes, 0 for no (default) */
 void semanage_set_create_store(semanage_handle_t * handle, int create_store);
 
+/* Set whether or not to disable dontaudits upon commit */
+void semanage_set_disable_dontaudit(semanage_handle_t * handle, int disable_dontaudit);
+
 /* Check whether policy is managed via libsemanage on this system.
  * Must be called prior to trying to connect.
  * Return 1 if policy is managed via libsemanage on this system,

Index: libsemanage/src/libsemanage.map
===================================================================

src/libsemanage.map +1 -1
@@ -13,6 +13,6 @@
 	  semanage_iface_*; semanage_port_*; semanage_context_*;
 	  semanage_node_*;
 	  semanage_fcontext_*; semanage_access_check; semanage_set_create_store;
-	  semanage_is_connected;
+	  semanage_is_connected; semanage_set_disable_dontaudit;
   local: *;
 };

Index: libsemanage/src/handle.c
===================================================================

src/handle.c +8 -0
@@ -109,6 +109,14 @@
 	return;
 }
 
+void semanage_set_disable_dontaudit(semanage_handle_t * sh, int disable_dontaudit)
+{
+	assert(sh != NULL);
+	
+	sepol_set_disable_dontaudit(sh->sepolh, disable_dontaudit);
+	return;
+}
+
 int semanage_is_connected(semanage_handle_t * sh)
 {
 	assert(sh != NULL);

Index: libsepol/include/sepol/handle.h
===================================================================

include/sepol/handle.h +4 -0
@@ -7,6 +7,10 @@
 /* Create and return a sepol handle. */
 sepol_handle_t *sepol_handle_create(void);
 
+/* Set whether or not to disable dontaudits, 0 is default and does 
+ * not disable dontaudits, 1 disables them */
+void sepol_set_disable_dontaudit(sepol_handle_t * sh, int disable_dontaudit);
+
 /* Destroy a sepol handle. */
 void sepol_handle_destroy(sepol_handle_t *);
 

Index: libsepol/src/handle.h
===================================================================

src/handle.h +3 -0
@@ -14,6 +14,9 @@
 	void (*msg_callback) (void *varg,
 			      sepol_handle_t * handle, const char *fmt, ...);
 	void *msg_callback_arg;
+
+	int disable_dontaudit;
+
 };
 
 #endif

Index: libsepol/src/libsepol.map
===================================================================

src/libsepol.map +1 -0
@@ -12,5 +12,6 @@
 	sepol_policydb_*; sepol_set_policydb_from_file; 
 	sepol_policy_kern_*;
 	sepol_policy_file_*;
+	sepol_set_disable_dontaudit;
   local: *;
 };

Index: libsepol/src/expand.c
===================================================================

src/expand.c +2 -0
@@ -1367,6 +1367,8 @@
 	} else if (specified & AVRULE_AUDITDENY) {
 		spec = AVTAB_AUDITDENY;
 	} else if (specified & AVRULE_DONTAUDIT) {
+		if (handle->disable_dontaudit)
+			return EXPAND_RULE_SUCCESS;
 		spec = AVTAB_AUDITDENY;
 	} else if (specified & AVRULE_NEVERALLOW) {
 		spec = AVTAB_NEVERALLOW;

Index: libsepol/src/handle.c
===================================================================

src/handle.c +10 -0
@@ -1,4 +1,5 @@
 #include <stdlib.h>
+#include <assert.h>
 #include "handle.h"
 #include "debug.h"
 
@@ -13,9 +14,18 @@
 	sh->msg_callback = sepol_msg_default_handler;
 	sh->msg_callback_arg = NULL;
 
+	/* by default do not disable dontaudits */
+	sh->disable_dontaudit = 0;
+
 	return sh;
 }
 
+void sepol_set_disable_dontaudit(sepol_handle_t * sh, int disable_dontaudit)
+{
+	assert(sh !=NULL);
+	sh->disable_dontaudit = disable_dontaudit;
+}
+
 void sepol_handle_destroy(sepol_handle_t * sh)
 {
 	free(sh);

Index: policycoreutils/semodule/semodule.c
===================================================================

semodule/semodule.c +7 -1
@@ -44,6 +44,7 @@
 static int no_reload;
 static int create_store;
 static int build;
+static int disable_dontaudit;
 
 static semanage_handle_t *sh = NULL;
 static char *store;
@@ -131,6 +132,7 @@
 	printf("  -n,--noreload	   do not reload policy after commit\n");
 	printf("  -h,--help        print this message and quit\n");
 	printf("  -v,--verbose     be verbose\n");
+	printf("  -D,--disable_dontaudit	Remove dontaudits from policy\n");
 }
 
 /* Sets the global mode variable to new_mode, but only if no other
@@ -173,6 +175,7 @@
 		{"reload", 0, NULL, 'R'},
 		{"noreload", 0, NULL, 'n'},
 		{"build", 0, NULL, 'B'},
+		{"disable_dontaudit", 0, NULL, 'D'},
 		{NULL, 0, NULL, 0}
 	};
 	int i;
@@ -181,7 +184,7 @@
 	no_reload = 0;
 	create_store = 0;
 	while ((i =
-		getopt_long(argc, argv, "s:b:hi:lvqr:u:RnB", opts,
+		getopt_long(argc, argv, "s:b:hi:lvqr:u:RnBD", opts,
 			    NULL)) != -1) {
 		switch (i) {
 		case 'b':
@@ -218,6 +221,9 @@
 		case 'B':
 			build = 1;
 			break;
+		case 'D':
+			disable_dontaudit = 1;
+			break;
 		case '?':
 		default:{
 				usage(argv[0]);

semodule/semodule.c line 454

Quoted 8 lines
semodule/semodule.c +2 -0
@@ -441,6 +447,8 @@
 			semanage_set_reload(sh, 0);
 		if (build)
 			semanage_set_rebuild(sh, 1);
+		if (disable_dontaudit)
+			semanage_set_disable_dontaudit(sh, 1);
 		result = semanage_commit(sh);
 	}
 
Quoted 3 lines

Merge at will.

So did we decide that the disadvantages of this approach are fine? The one that bothers me is that rebooting doesn't reset the dontaudit state (like it would with Eric's patch)...

Quoted 7 lines
Quoted 4 lines

That could be an advantage - suppose that you want to collect full audit information on the initialization itself. And it isn't different than the old 'make enableaudit load' approach.

Good point, ok, I'll merge this in a bit, are there any other pending merges?

Quoted 7 lines

Some of Dan's policycoreutils patches are trivial or simple bug fixes. Others are less clear to me.

I was going to test the libsemanage genhomedircon patches, but haven't done so yet. I don't have a problem with them conceptually. Have you verified that they yield no change in output under -targeted and -strict policy? And run them under valgrind?

Oh, and what to do about the fact that it won't build anywhere but rawhide (ustr dependency)?

Quoted 9 lines

Eric's handle unknown patches are still outstanding. Dan, if we merged that support, would you use it in building future policies?

Karl's sepolgen bug fix looks fine to merge.

I (or someone) have to rework libsepol in stable and trunk to avoid unaligned accesses (as per the wrong magic number thread). Already did it once for the kernel. Sigh.

Signature · 8 lines
Stephen Smalley
National Security Agency


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#15 lore raw
Quoted 13 lines · Stephen Smalley
Quoted 8 lines

Some of Dan's policycoreutils patches are trivial or simple bug fixes. Others are less clear to me.

I was going to test the libsemanage genhomedircon patches, but haven't done so yet. I don't have a problem with them conceptually. Have you verified that they yield no change in output under -targeted and -strict policy? And run them under valgrind?

Oh, and what to do about the fact that it won't build anywhere but rawhide (ustr dependency)?

We can pull the parts of ustr we need into the library, it is designed to do used that way. This is also trunk though, and we don't guarantee ABI stability in trunk right? The sepolgen dependency of python 2.5 causes similar problems AFAIK.

Quoted 10 lines
Quoted 10 lines

Eric's handle unknown patches are still outstanding. Dan, if we merged that support, would you use it in building future policies?

Karl's sepolgen bug fix looks fine to merge.

I (or someone) have to rework libsepol in stable and trunk to avoid unaligned accesses (as per the wrong magic number thread). Already did it once for the kernel. Sigh.

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.

#16 lore raw
Quoted 10 lines · Joshua Brindle
Quoted 9 lines · Stephen Smalley
Quoted 8 lines

Some of Dan's policycoreutils patches are trivial or simple bug fixes. Others are less clear to me.

I was going to test the libsemanage genhomedircon patches, but haven't done so yet. I don't have a problem with them conceptually. Have you verified that they yield no change in output under -targeted and -strict policy? And run them under valgrind?

Quoted 8 lines
Quoted 4 lines

Oh, and what to do about the fact that it won't build anywhere but rawhide (ustr dependency)?

We can pull the parts of ustr we need into the library, it is designed to do used that way. This is also trunk though, and we don't guarantee ABI stability in trunk right? The sepolgen dependency of python 2.5 causes similar problems AFAIK.

Ok. I just wanted to test on F7, so I just did a yum --enablerepo=development install ustr ustr-devel and then everything was happy.

But the more important issue is that it doesn't work (see other mail). Pity. ENOTEST w/o users added to seusers.

Signature · 8 lines
Stephen Smalley
National Security Agency


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#17 lore raw
In reply to Stephen Smalley
Quoted 256 lines · Stephen Smalley
Quoted 254 lines · Joshua Brindle
Quoted 252 lines · Stephen Smalley
Quoted 249 lines · Joshua Brindle
Quoted 239 lines · Stephen Smalley
Quoted 225 lines · Joshua Brindle
Quoted 23 lines · Joshua Brindle
Quoted 6 lines · James Morris

On Thu, 9 Aug 2007, Eric Paris wrote:

Quoted 13 lines
Quoted 7 lines

Currently to disable dontaudit rules best you can do it to load the enableaudit.pp base policy. Which still doesn't remove the dontaudit rules from modules.

Are we sure this can't be done in userspace? Like, mangle all the existing policy and reload it?

Quoted 7 lines

I agree, the infrastructure is certainly in place to do it, just add something in the sepol_handle that says dontaudits should be discarded, then make an interface in libsemanage that uses that and rebuild the policy.

If noone beats me to it I will see if my conclusions about it being fairly simple are accurate this weekend :)

I changed my mind, patch below

it compiles and seems to work after semodule -DB:

[root@scarecrow policy]# sediff -T policy.21.old \; policy.21 | grep -v dontaudit
TE Rules (Added 0, Added New Type 0, Removed 326583, Removed Missing Type 0, Modified 0)
Added TE Rules: 0
Added TE Rules because of new type: 0
Removed TE Rules: 326583
Removed TE Rules because of missing type: 0
Modified TE Rules: 0

Index: libsemanage/include/semanage/handle.h
===================================================================

include/semanage/handle.h +3 -0
@@ -69,6 +69,9 @@
  * 1 for yes, 0 for no (default) */
 void semanage_set_create_store(semanage_handle_t * handle, int create_store);
 
+/* Set whether or not to disable dontaudits upon commit */
+void semanage_set_disable_dontaudit(semanage_handle_t * handle, int disable_dontaudit);
+
 /* Check whether policy is managed via libsemanage on this system.
  * Must be called prior to trying to connect.
  * Return 1 if policy is managed via libsemanage on this system,

Index: libsemanage/src/libsemanage.map
===================================================================

src/libsemanage.map +1 -1
@@ -13,6 +13,6 @@
 	  semanage_iface_*; semanage_port_*; semanage_context_*;
 	  semanage_node_*;
 	  semanage_fcontext_*; semanage_access_check; semanage_set_create_store;
-	  semanage_is_connected;
+	  semanage_is_connected; semanage_set_disable_dontaudit;
   local: *;
 };

Index: libsemanage/src/handle.c
===================================================================

src/handle.c +8 -0
@@ -109,6 +109,14 @@
 	return;
 }
 
+void semanage_set_disable_dontaudit(semanage_handle_t * sh, int disable_dontaudit)
+{
+	assert(sh != NULL);
+	
+	sepol_set_disable_dontaudit(sh->sepolh, disable_dontaudit);
+	return;
+}
+
 int semanage_is_connected(semanage_handle_t * sh)
 {
 	assert(sh != NULL);

Index: libsepol/include/sepol/handle.h
===================================================================

include/sepol/handle.h +4 -0
@@ -7,6 +7,10 @@
 /* Create and return a sepol handle. */
 sepol_handle_t *sepol_handle_create(void);
 
+/* Set whether or not to disable dontaudits, 0 is default and does 
+ * not disable dontaudits, 1 disables them */
+void sepol_set_disable_dontaudit(sepol_handle_t * sh, int disable_dontaudit);
+
 /* Destroy a sepol handle. */
 void sepol_handle_destroy(sepol_handle_t *);
 

Index: libsepol/src/handle.h
===================================================================

src/handle.h +3 -0
@@ -14,6 +14,9 @@
 	void (*msg_callback) (void *varg,
 			      sepol_handle_t * handle, const char *fmt, ...);
 	void *msg_callback_arg;
+
+	int disable_dontaudit;
+
 };
 
 #endif

Index: libsepol/src/libsepol.map
===================================================================

src/libsepol.map +1 -0
@@ -12,5 +12,6 @@
 	sepol_policydb_*; sepol_set_policydb_from_file; 
 	sepol_policy_kern_*;
 	sepol_policy_file_*;
+	sepol_set_disable_dontaudit;
   local: *;
 };

Index: libsepol/src/expand.c
===================================================================

src/expand.c +2 -0
@@ -1367,6 +1367,8 @@
 	} else if (specified & AVRULE_AUDITDENY) {
 		spec = AVTAB_AUDITDENY;
 	} else if (specified & AVRULE_DONTAUDIT) {
+		if (handle->disable_dontaudit)
+			return EXPAND_RULE_SUCCESS;
 		spec = AVTAB_AUDITDENY;
 	} else if (specified & AVRULE_NEVERALLOW) {
 		spec = AVTAB_NEVERALLOW;

Index: libsepol/src/handle.c
===================================================================

src/handle.c +10 -0
@@ -1,4 +1,5 @@
 #include <stdlib.h>
+#include <assert.h>
 #include "handle.h"
 #include "debug.h"
 
@@ -13,9 +14,18 @@
 	sh->msg_callback = sepol_msg_default_handler;
 	sh->msg_callback_arg = NULL;
 
+	/* by default do not disable dontaudits */
+	sh->disable_dontaudit = 0;
+
 	return sh;
 }
 
+void sepol_set_disable_dontaudit(sepol_handle_t * sh, int disable_dontaudit)
+{
+	assert(sh !=NULL);
+	sh->disable_dontaudit = disable_dontaudit;
+}
+
 void sepol_handle_destroy(sepol_handle_t * sh)
 {
 	free(sh);

Index: policycoreutils/semodule/semodule.c
===================================================================

semodule/semodule.c +7 -1
@@ -44,6 +44,7 @@
 static int no_reload;
 static int create_store;
 static int build;
+static int disable_dontaudit;
 
 static semanage_handle_t *sh = NULL;
 static char *store;
@@ -131,6 +132,7 @@
 	printf("  -n,--noreload	   do not reload policy after commit\n");
 	printf("  -h,--help        print this message and quit\n");
 	printf("  -v,--verbose     be verbose\n");
+	printf("  -D,--disable_dontaudit	Remove dontaudits from policy\n");
 }
 
 /* Sets the global mode variable to new_mode, but only if no other
@@ -173,6 +175,7 @@
 		{"reload", 0, NULL, 'R'},
 		{"noreload", 0, NULL, 'n'},
 		{"build", 0, NULL, 'B'},
+		{"disable_dontaudit", 0, NULL, 'D'},
 		{NULL, 0, NULL, 0}
 	};
 	int i;
@@ -181,7 +184,7 @@
 	no_reload = 0;
 	create_store = 0;
 	while ((i =
-		getopt_long(argc, argv, "s:b:hi:lvqr:u:RnB", opts,
+		getopt_long(argc, argv, "s:b:hi:lvqr:u:RnBD", opts,
 			    NULL)) != -1) {
 		switch (i) {
 		case 'b':
@@ -218,6 +221,9 @@
 		case 'B':
 			build = 1;
 			break;
+		case 'D':
+			disable_dontaudit = 1;
+			break;
 		case '?':
 		default:{
 				usage(argv[0]);

semodule/semodule.c line 454

Quoted 8 lines
semodule/semodule.c +2 -0
@@ -441,6 +447,8 @@
 			semanage_set_reload(sh, 0);
 		if (build)
 			semanage_set_rebuild(sh, 1);
+		if (disable_dontaudit)
+			semanage_set_disable_dontaudit(sh, 1);
 		result = semanage_commit(sh);
 	}
 
Quoted 4 lines

Merge at will.

So did we decide that the disadvantages of this approach are fine? The one that bothers me is that rebooting doesn't reset the dontaudit state (like it would with Eric's patch)...

Quoted 9 lines
Quoted 7 lines
Quoted 5 lines

That could be an advantage - suppose that you want to collect full audit information on the initialization itself. And it isn't different than the old 'make enableaudit load' approach.

Good point, ok, I'll merge this in a bit, are there any other pending merges?

Merged into libsepol 2.0.6, libsemanage 2.0.4 and policycoreutils 2.0.23

Quoted 4 lines

Some of Dan's policycoreutils patches are trivial or simple bug fixes. Others are less clear to me.

I'll wait until there is a complete patch

Quoted 6 lines

I was going to test the libsemanage genhomedircon patches, but haven't done so yet. I don't have a problem with them conceptually. Have you verified that they yield no change in output under -targeted and -strict policy? And run them under valgrind?

targeted yields a change (pointed out in the initial email) which was the result of a bug in genhomedircon, its been valgrinded, I'm having strict tested now.

Quoted 4 lines

Eric's handle unknown patches are still outstanding. Dan, if we merged that support, would you use it in building future policies?

So we are going forward with this patch?

Quoted 3 lines

Karl's sepolgen bug fix looks fine to merge.

merged.

Quoted 5 lines

I (or someone) have to rework libsepol in stable and trunk to avoid unaligned accesses (as per the wrong magic number thread). Already did it once for the kernel. Sigh.

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.

#18 lore raw

I would like to get these patches into policycoreutils.

Submitted before, but here we go.

Change run_tty and open_init_pty to 755 instead of 555. Some audit tools are reporting this as a problem. And I see no real value of 555. for these to.

Simple bugfix for chcat

Fixes to make sure fixfiles reports errors and handles strange regexes.

Speed enhancement for genhomedircon to only compile regex's once.

I reverted sepolgen-ifgen from sbin to bin, but I doubt many/anyone will run it as non root, but I guess you never no.

run_init/Makefile +2 -2
diff --exclude-from=exclude --exclude=sepolgen-1.0.8 --exclude=gui --exclude=po -N -u -r nsapolicycoreutils/run_init/Makefile policycoreutils-2.0.22/run_init/Makefile
@@ -34,8 +34,8 @@
 install: all
 	test -d $(SBINDIR)      || install -m 755 -d $(SBINDIR)
 	test -d $(MANDIR)/man1 || install -m 755 -d $(MANDIR)/man1
-	install -m 555 run_init $(SBINDIR)
-	install -m 555 open_init_pty $(SBINDIR)
+	install -m 755 run_init $(SBINDIR)
+	install -m 755 open_init_pty $(SBINDIR)
 	install -m 644 run_init.8 $(MANDIR)/man8/
 	install -m 644 open_init_pty.8 $(MANDIR)/man8/
 ifeq (${PAMH}, /usr/include/security/pam_appl.h)
scripts/chcat +2 -2
diff --exclude-from=exclude --exclude=sepolgen-1.0.8 --exclude=gui --exclude=po -N -u -r nsapolicycoreutils/scripts/chcat policycoreutils-2.0.22/scripts/chcat
@@ -77,7 +77,7 @@
             
         if len(cats) > 0:
             new_serange = "%s-%s:%s" % (serange[0], top[0], ",".join(cats))
-        else
+        else:
             new_serange = "%s-%s" % (serange[0], top[0])
             
         if add_ind:
@@ -155,7 +155,7 @@
 
         if len(cats) > 0:
             new_serange = "%s-%s:%s" % (serange[0], top[0], ",".join(cats))
-        else
+        else:
             new_serange = "%s-%s" % (serange[0], top[0])
             
         if add_ind:
scripts/fixfiles +2 -1
diff --exclude-from=exclude --exclude=sepolgen-1.0.8 --exclude=gui --exclude=po -N -u -r nsapolicycoreutils/scripts/fixfiles policycoreutils-2.0.22/scripts/fixfiles
@@ -88,7 +88,7 @@
                   esac; \
                fi; \
             done | \
-	while read pattern ; do find $pattern \
+	while read pattern ; do sh -c "find $pattern" \
 		      ! \( -fstype ext2 -o -fstype ext3 -o -fstype jfs -o -fstype xfs \) -prune  -o \
 		      \( -wholename /home -o -wholename /root -o -wholename /tmp -wholename /dev \) -prune -o -print; \
 		      done 2> /dev/null | \
@@ -108,6 +108,7 @@
 
 rpmlist() {
 rpm -q --qf '[%{FILESTATES} %{FILENAMES}\n]' "$1" | grep '^0 ' | cut -f2- -d ' '
+[ ${PIPESTATUS[0]} != 0 ] && echo "$1 not found" >/dev/stderr
 }
 
 # 
scripts/genhomedircon +17 -13
diff --exclude-from=exclude --exclude=sepolgen-1.0.8 --exclude=gui --exclude=po -N -u -r nsapolicycoreutils/scripts/genhomedircon policycoreutils-2.0.22/scripts/genhomedircon
@@ -139,7 +139,22 @@
 		self.default_user = "user_u"
 		self.default_prefix = "user"
 		self.users = self.getUsers()
+		fd = open(self.getFileContextFile())
+		self.fclines=[]
+		for i in fd.readlines():
+		    try:
+			    regex = i.split()[0]
+			    #match a trailing .+
+			    regex = re.sub("\.+$", "", regex)
+			    regex = re.sub("\.\*$", "", regex)
+			    regex = re.sub("\(\/\.\*\)\?", "", regex)
+			    regex = regex + "/*$"
+			    self.fclines.append(re.compile(regex))
+		    except:
+			    continue
 
+		fd.close()
+		
 	def getFileContextDir(self):
 		return self.selinuxdir+self.type+self.filecontextdir
 
@@ -289,20 +304,9 @@
 		return ret+"\n"
 
 	def checkExists(self, home):
-		fd = open(self.getFileContextFile())
-		for i in  fd.readlines():
-                    if len(i) == 0:
-			    continue
+		for i in self.fclines:
 		    try:
-			    regex = i.split()[0]
-			    #match a trailing .+
-			    regex = re.sub("\.+$", "", regex)
-			    regex = re.sub("\.\*$", "", regex)
-			    #strip a (/.*)? which matches anything trailing to a /*$ which matches trailing /'s
-			    
-			    regex = re.sub("\(\/\.\*\)\?", "", regex)
-			    regex = regex + "/*$"
-			    if re.search(regex,home, 0):
+			    if i.match(home):
 				    return 1
 		    except:
 			    continue
semanage/semanage +4 -1
diff --exclude-from=exclude --exclude=sepolgen-1.0.8 --exclude=gui --exclude=po -N -u -r nsapolicycoreutils/semanage/semanage policycoreutils-2.0.22/semanage/semanage
@@ -34,7 +34,10 @@
 sys.stdout = codecs.getwriter(locale.getpreferredencoding())(sys.__stdout__, 'replace')
 
 try:
-       gettext.install(PROGNAME, localedir="/usr/share/locale", unicode=1)
+       gettext.install(PROGNAME,
+                       localedir="/usr/share/locale",
+                       unicode=False,
+                       codeset = 'utf-8')
 except IOError:
        import __builtin__
        __builtin__.__dict__['_'] = unicode
#19 lore raw
Quoted 5 lines · Daniel J Walsh

I would like to get these patches into policycoreutils.

Submitted before, but here we go.

Quoted 8 lines

Change run_tty and open_init_pty to 755 instead of 555. Some audit tools are reporting this as a problem. And I see no real value of 555. for these to.

Simple bugfix for chcat

Fixes to make sure fixfiles reports errors and handles strange regexes.

Speed enhancement for genhomedircon to only compile regex's once.

The current plan is to change to a genhomedircon based on C in libsemanage. Have you looked at those patches to see if they suffer the same problem you are fixing here?

Quoted 2 lines

I reverted sepolgen-ifgen from sbin to bin, but I doubt many/anyone will run it as non root, but I guess you never no.

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.

#20 lore raw
Quoted 8 lines · Joshua Brindle
Quoted 7 lines · Daniel J Walsh

I would like to get these patches into policycoreutils.

Submitted before, but here we go.

Change run_tty and open_init_pty to 755 instead of 555. Some audit tools are reporting this as a problem. And I see no real value of 555. for these to.

Quoted 7 lines
Quoted 6 lines

Simple bugfix for chcat

Fixes to make sure fixfiles reports errors and handles strange regexes.

Speed enhancement for genhomedircon to only compile regex's once.

The current plan is to change to a genhomedircon based on C in libsemanage. Have you looked at those patches to see if they suffer the same problem you are fixing here?

No.

Quoted 5 lines
Quoted 3 lines

I reverted sepolgen-ifgen from sbin to bin, but I doubt many/anyone will run it as non root, but I guess you never no.

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.

#21 lore raw
In reply to Daniel J Walsh
Quoted 4 lines · Daniel J Walsh

I would like to get these patches into policycoreutils.

Submitted before, but here we go.

In the future, please post one patch per message.

Quoted 9 lines

Change run_tty and open_init_pty to 755 instead of 555. Some audit tools are reporting this as a problem. And I see no real value of 555. for these to.

Simple bugfix for chcat

Fixes to make sure fixfiles reports errors and handles strange regexes.

Speed enhancement for genhomedircon to only compile regex's once.

I merged these to trunk, and the chcat bug fix to stable, but then the libsemanage genhomedircon patch series removes genhomedircon altogether. So you can extract the genhomedircon script with this enhancement from the history, but you won't see any genhomedircon script at all on the head.

Quoted 2 lines

I reverted sepolgen-ifgen from sbin to bin, but I doubt many/anyone will run it as non root, but I guess you never no.

I actually dislike having things in sbin because normal user paths don't include it (even after su, unless you do a 'su -'). Regardless, the real issue is providing stability - changing paths after it has already been out there for a little while is harmful.

Quoted 121 lines

plain text document attachment (diff)
diff --exclude-from=exclude --exclude=sepolgen-1.0.8 --exclude=gui --exclude=po -N -u -r nsapolicycoreutils/run_init/Makefile policycoreutils-2.0.22/run_init/Makefile

run_init/Makefile +2 -2
@@ -34,8 +34,8 @@
 install: all
 	test -d $(SBINDIR)      || install -m 755 -d $(SBINDIR)
 	test -d $(MANDIR)/man1 || install -m 755 -d $(MANDIR)/man1
-	install -m 555 run_init $(SBINDIR)
-	install -m 555 open_init_pty $(SBINDIR)
+	install -m 755 run_init $(SBINDIR)
+	install -m 755 open_init_pty $(SBINDIR)
 	install -m 644 run_init.8 $(MANDIR)/man8/
 	install -m 644 open_init_pty.8 $(MANDIR)/man8/
 ifeq (${PAMH}, /usr/include/security/pam_appl.h)

diff --exclude-from=exclude --exclude=sepolgen-1.0.8 --exclude=gui --exclude=po -N -u -r nsapolicycoreutils/scripts/chcat policycoreutils-2.0.22/scripts/chcat

scripts/chcat +2 -2
@@ -77,7 +77,7 @@
 
         if len(cats) > 0:
             new_serange = "%s-%s:%s" % (serange[0], top[0], ",".join(cats))
-        else
+        else:
             new_serange = "%s-%s" % (serange[0], top[0])
 
         if add_ind:
@@ -155,7 +155,7 @@
 
         if len(cats) > 0:
             new_serange = "%s-%s:%s" % (serange[0], top[0], ",".join(cats))
-        else
+        else:
             new_serange = "%s-%s" % (serange[0], top[0])
 
         if add_ind:

diff --exclude-from=exclude --exclude=sepolgen-1.0.8 --exclude=gui --exclude=po -N -u -r nsapolicycoreutils/scripts/fixfiles policycoreutils-2.0.22/scripts/fixfiles

scripts/fixfiles +2 -1
@@ -88,7 +88,7 @@
                   esac; \
                fi; \
             done | \
-	while read pattern ; do find $pattern \
+	while read pattern ; do sh -c "find $pattern" \
 		      ! \( -fstype ext2 -o -fstype ext3 -o -fstype jfs -o -fstype xfs \) -prune  -o \
 		      \( -wholename /home -o -wholename /root -o -wholename /tmp -wholename /dev \) -prune -o -print; \
 		      done 2> /dev/null | \
@@ -108,6 +108,7 @@
 
 rpmlist() {
 rpm -q --qf '[%{FILESTATES} %{FILENAMES}\n]' "$1" | grep '^0 ' | cut -f2- -d ' '
+[ ${PIPESTATUS[0]} != 0 ] && echo "$1 not found" >/dev/stderr
 }
 
 # 

diff --exclude-from=exclude --exclude=sepolgen-1.0.8 --exclude=gui --exclude=po -N -u -r nsapolicycoreutils/scripts/genhomedircon policycoreutils-2.0.22/scripts/genhomedircon

scripts/genhomedircon +17 -13
@@ -139,7 +139,22 @@
 		self.default_user = "user_u"
 		self.default_prefix = "user"
 		self.users = self.getUsers()
+		fd = open(self.getFileContextFile())
+		self.fclines=[]
+		for i in fd.readlines():
+		    try:
+			    regex = i.split()[0]
+			    #match a trailing .+
+			    regex = re.sub("\.+$", "", regex)
+			    regex = re.sub("\.\*$", "", regex)
+			    regex = re.sub("\(\/\.\*\)\?", "", regex)
+			    regex = regex + "/*$"
+			    self.fclines.append(re.compile(regex))
+		    except:
+			    continue
 
+		fd.close()
+		
 	def getFileContextDir(self):
 		return self.selinuxdir+self.type+self.filecontextdir
 
@@ -289,20 +304,9 @@
 		return ret+"\n"
 
 	def checkExists(self, home):
-		fd = open(self.getFileContextFile())
-		for i in  fd.readlines():
-                    if len(i) == 0:
-			    continue
+		for i in self.fclines:
 		    try:
-			    regex = i.split()[0]
-			    #match a trailing .+
-			    regex = re.sub("\.+$", "", regex)
-			    regex = re.sub("\.\*$", "", regex)
-			    #strip a (/.*)? which matches anything trailing to a /*$ which matches trailing /'s
-			    
-			    regex = re.sub("\(\/\.\*\)\?", "", regex)
-			    regex = regex + "/*$"
-			    if re.search(regex,home, 0):
+			    if i.match(home):
 				    return 1
 		    except:
 			    continue

diff --exclude-from=exclude --exclude=sepolgen-1.0.8 --exclude=gui --exclude=po -N -u -r nsapolicycoreutils/semanage/semanage policycoreutils-2.0.22/semanage/semanage

semanage/semanage +4 -1
@@ -34,7 +34,10 @@
 sys.stdout = codecs.getwriter(locale.getpreferredencoding())(sys.__stdout__, 'replace')
 
 try:
-       gettext.install(PROGNAME, localedir="/usr/share/locale", unicode=1)
+       gettext.install(PROGNAME,
+                       localedir="/usr/share/locale",
+                       unicode=False,
+                       codeset = 'utf-8')
 except IOError:
        import __builtin__
        __builtin__.__dict__['_'] = unicode
Signature · 8 lines
Stephen Smalley
National Security Agency


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.