From: Ivan Gyurdiev <ivg2@cornell.edu>
To: selinux@tycho.nsa.gov, Stephen Smalley <sds@tycho.nsa.gov>
Subject: [SEMANAGE] Flip traversal order for llist iterate/list operations
Date: Mon, 26 Dec 2005 21:45:46 -0500 [thread overview]
Message-ID: <43B0AADA.5090300@cornell.edu> (raw)
[-- 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;
reply other threads:[~2005-12-27 2:45 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=43B0AADA.5090300@cornell.edu \
--to=ivg2@cornell.edu \
--cc=sds@tycho.nsa.gov \
--cc=selinux@tycho.nsa.gov \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.