All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ivan Gyurdiev <ivg2@cornell.edu>
To: SELinux List <SELinux@tycho.nsa.gov>
Cc: Stephen Smalley <sds@tycho.nsa.gov>
Subject: [SEMANAGE][SEPOL] Support ordering of records in compare function
Date: Fri, 23 Dec 2005 01:57:15 -0500	[thread overview]
Message-ID: <43AB9FCB.70403@cornell.edu> (raw)

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

This patch changes the compare functions for user/boolean/iface/seuser 
(and a fixme for ports), to support ordering of records (by returning 
-1, 1, or 0, and not just 0 or -1). This is necessary to sort records in 
a reasonable amount of time, which I need to do to support a join operation.


[-- Attachment #2: libsemanage4.libsepol.ordering.diff --]
[-- Type: text/x-patch, Size: 3217 bytes --]

diff -Naurp --exclude-from excludes old/libsemanage/src/database.h new/libsemanage/src/database.h
--- old/libsemanage/src/database.h	2005-11-04 15:37:49.000000000 -0500
+++ new/libsemanage/src/database.h	2005-12-23 01:48:17.000000000 -0500
@@ -37,7 +37,9 @@ typedef struct record_table {
 	void (*key_free) (
 		record_key_t* key);
 
-	/* Return 0 if record can be matched against key, and 1 otherwise */
+	/* Return 0 if the record matches the key, 
+	 * -1 if the key represents a record that should
+	 * be ordered before this record, and 1 if vice-versa */
 	int (*compare) (
 		record_t* rec, 
 		record_key_t* key);
diff -Naurp --exclude-from excludes old/libsemanage/src/seuser_record.c new/libsemanage/src/seuser_record.c
--- old/libsemanage/src/seuser_record.c	2005-12-23 01:01:49.000000000 -0500
+++ new/libsemanage/src/seuser_record.c	2005-12-23 01:49:55.000000000 -0500
@@ -90,10 +90,8 @@ hidden_def(semanage_seuser_key_free)
 int semanage_seuser_compare(
 	semanage_seuser_t* seuser,
 	semanage_seuser_key_t* key) {
-	
-	if (!strcmp(seuser->name, key->name))
-		return 0;
-	return 1;
+
+	return strcmp(seuser->name, key->name);	
 }
 hidden_def(semanage_seuser_compare)
 
diff -Naurp --exclude-from excludes old/libsepol/src/boolean_record.c new/libsepol/src/boolean_record.c
--- old/libsepol/src/boolean_record.c	2005-11-01 17:32:58.000000000 -0500
+++ new/libsepol/src/boolean_record.c	2005-12-23 01:44:42.000000000 -0500
@@ -68,10 +68,8 @@ void sepol_bool_key_free(sepol_bool_key_
 int sepol_bool_compare(
 	sepol_bool_t* boolean,
 	sepol_bool_key_t* key) {
-	
-	if (!strcmp(boolean->name, key->name))
-		return 0;
-	return 1;
+
+	return strcmp(boolean->name, key->name);
 }
 
 /* Name */
diff -Naurp --exclude-from excludes old/libsepol/src/iface_record.c new/libsepol/src/iface_record.c
--- old/libsepol/src/iface_record.c	2005-11-01 17:32:59.000000000 -0500
+++ new/libsepol/src/iface_record.c	2005-12-23 01:45:04.000000000 -0500
@@ -73,10 +73,8 @@ void sepol_iface_key_free(sepol_iface_ke
 int sepol_iface_compare(
 	sepol_iface_t* iface, 
 	sepol_iface_key_t* key) {
-	
-	if (!strcmp(iface->name, key->name)) 
-		return 0;
-	return 1;
+
+	return strcmp(iface->name, key->name);
 }
 
 /* Create */
diff -Naurp --exclude-from excludes old/libsepol/src/port_record.c new/libsepol/src/port_record.c
--- old/libsepol/src/port_record.c	2005-11-01 17:32:59.000000000 -0500
+++ new/libsepol/src/port_record.c	2005-12-23 01:45:57.000000000 -0500
@@ -84,6 +84,8 @@ int sepol_port_compare(
 	sepol_port_t* port, 
 	sepol_port_key_t* key) {
 
+	/* FIXME: needs to support ordering of ports (-1, 0, 1) */
+
 	if ((port->low <= key->low) && 
 	    (port->high >= key->high) &&
 	    (port->proto == key->proto))
diff -Naurp --exclude-from excludes old/libsepol/src/user_record.c new/libsepol/src/user_record.c
--- old/libsepol/src/user_record.c	2005-12-05 15:00:37.000000000 -0500
+++ new/libsepol/src/user_record.c	2005-12-23 01:44:24.000000000 -0500
@@ -78,10 +78,8 @@ void sepol_user_key_free(sepol_user_key_
 int sepol_user_compare(
 	sepol_user_t* user,
 	sepol_user_key_t* key) {
-	
-	if (!strcmp(user->name, key->name))
-		return 0;
-	return 1;
+
+	return strcmp(user->name, key->name);
 }
 
 /* Name */

                 reply	other threads:[~2005-12-23  6:57 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=43AB9FCB.70403@cornell.edu \
    --to=ivg2@cornell.edu \
    --cc=SELinux@tycho.nsa.gov \
    --cc=sds@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.