All of lore.kernel.org
 help / color / mirror / Atom feed
* [SEMANAGE] Flip traversal order for llist iterate/list operations
@ 2005-12-27  2:45 Ivan Gyurdiev
  0 siblings, 0 replies; only message in thread
From: Ivan Gyurdiev @ 2005-12-27  2:45 UTC (permalink / raw)
  To: selinux, Stephen Smalley

[-- Attachment #1: Type: text/plain, Size: 1033 bytes --]

This patch flips the order for the linked list traversal in 
iterate()/list().
This is an implementation fix, which makes ports added later take 
precedence over ports added earlier.
That's because ports are added to the policydb in the iterate() order.

I'm not quite happy with this - I want the property above to be 
guaranteed in the specification of add() - things added later should 
take precedence over things added earlier (if ordering is a factor). To 
do that, I want the specification for iterate()/list() to guarantee 
traversal in the order things were added in (which is something that 
you'd usually expect iterate() to do). This is now true for anything 
backed in a file. It's also true for libsepol users. It's true trivially 
for libsepol booleans, because you can't add new libsepol booleans. 
However, it is *not* true for libsepol interfaces, and ports, where the 
list is traversed backwards. There iterate() works exactly the opposite 
way. It's a singly linked list, unfortunately. (the ocontext list..)




[-- Attachment #2: libsemanage12.llist_traversal_order.diff --]
[-- Type: text/x-patch, Size: 829 bytes --]

diff -Naurp --exclude-from excludes old/libsemanage/src/database_llist.c new/libsemanage/src/database_llist.c
--- old/libsemanage/src/database_llist.c	2005-12-23 01:01:49.000000000 -0500
+++ new/libsemanage/src/database_llist.c	2005-12-26 19:35:16.000000000 -0500
@@ -237,7 +237,7 @@ hidden int dbase_llist_iterate(
 	int rc;
 	cache_entry_t* ptr;
 
-	for (ptr = dbase->cache; ptr != NULL; ptr = ptr->next) {
+	for (ptr = dbase->cache_tail; ptr != NULL; ptr = ptr->prev) {
 
 		rc = fn(ptr->data, arg);
 		if (rc < 0) 
@@ -307,7 +307,7 @@ hidden int dbase_llist_list(
 		if (tmp_records == NULL)
 			goto omem;
 
-		for (ptr = dbase->cache; ptr != NULL; ptr = ptr->next) {
+		for (ptr = dbase->cache_tail; ptr != NULL; ptr = ptr->prev) {
 			if (dbase->rtable->clone(handle, 
 				ptr->data, &tmp_records[i]) < 0)
 				goto err;

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2005-12-27  2:45 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-12-27  2:45 [SEMANAGE] Flip traversal order for llist iterate/list operations Ivan Gyurdiev

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.