All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ivan Gyurdiev <ivg2@cornell.edu>
To: Daniel J Walsh <dwalsh@redhat.com>
Cc: SELinux List <SELinux@tycho.nsa.gov>,
	Stephen Smalley <sds@tycho.nsa.gov>
Subject: [SEMANAGE] Fix fcontext comparator
Date: Fri, 06 Jan 2006 11:30:05 -0500	[thread overview]
Message-ID: <43BE9B0D.409@cornell.edu> (raw)

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

The comparator for fcontext is wrong.
This should fix the problem Dan is having with the fcontext exists 
function - let me know if it works.




[-- Attachment #2: libsemanage.fix_fcontext_comparator.diff --]
[-- Type: text/x-patch, Size: 1270 bytes --]

diff -Naurp --exclude ports_local.c --exclude-from excludes old/libsemanage/src/fcontext_record.c new/libsemanage/src/fcontext_record.c
--- old/libsemanage/src/fcontext_record.c	2006-01-06 09:36:30.000000000 -0500
+++ new/libsemanage/src/fcontext_record.c	2006-01-06 11:27:40.000000000 -0500
@@ -81,8 +81,18 @@ int semanage_fcontext_compare(
 	const semanage_fcontext_t* fcontext, 
 	const semanage_fcontext_key_t* key) {
 
-	return strcmp(fcontext->expr, key->expr) && 
-		(fcontext->type == key->type);
+	int rv = strcmp(fcontext->expr, key->expr);
+	if (rv != 0)
+		return rv;
+	else {
+		if (fcontext->type < key->type)	
+			return -1;
+	
+		else if (key->type < fcontext->type)
+			return 1;
+	
+		else return 0;
+	}
 }
 hidden_def(semanage_fcontext_compare)
 
@@ -90,8 +100,18 @@ int semanage_fcontext_compare2(
 	const semanage_fcontext_t* fcontext,
 	const semanage_fcontext_t* fcontext2) {
 
-	return strcmp(fcontext->expr, fcontext2->expr) &&
-		(fcontext->type == fcontext2->type);
+	int rv = strcmp(fcontext->expr, fcontext2->expr);
+	if (rv != 0)
+		return rv;
+	else {
+		if (fcontext->type < fcontext2->type)
+			return -1;
+
+		else if (fcontext2->type < fcontext->type)
+			return 1;
+
+		else return 0;
+	}
 }
 hidden_def(semanage_fcontext_compare2)
 

             reply	other threads:[~2006-01-06 16:30 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-01-06 16:30 Ivan Gyurdiev [this message]
2006-01-09 14:12 ` [SEMANAGE] Fix fcontext comparator Stephen Smalley

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=43BE9B0D.409@cornell.edu \
    --to=ivg2@cornell.edu \
    --cc=SELinux@tycho.nsa.gov \
    --cc=dwalsh@redhat.com \
    --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.