All of lore.kernel.org
 help / color / mirror / Atom feed
* [SEMANAGE] Fix fcontext comparator
@ 2006-01-06 16:30 Ivan Gyurdiev
  2006-01-09 14:12 ` Stephen Smalley
  0 siblings, 1 reply; 2+ messages in thread
From: Ivan Gyurdiev @ 2006-01-06 16:30 UTC (permalink / raw)
  To: Daniel J Walsh; +Cc: SELinux List, Stephen Smalley

[-- 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)
 

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [SEMANAGE] Fix fcontext comparator
  2006-01-06 16:30 [SEMANAGE] Fix fcontext comparator Ivan Gyurdiev
@ 2006-01-09 14:12 ` Stephen Smalley
  0 siblings, 0 replies; 2+ messages in thread
From: Stephen Smalley @ 2006-01-09 14:12 UTC (permalink / raw)
  To: Ivan Gyurdiev; +Cc: Daniel J Walsh, SELinux List

On Fri, 2006-01-06 at 11:30 -0500, Ivan Gyurdiev wrote:
> 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.

Merged as of libsemanage 1.5.11.

-- 
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 majordomo@tycho.nsa.gov with
the words "unsubscribe selinux" without quotes as the message.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2006-01-09 14:12 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-01-06 16:30 [SEMANAGE] Fix fcontext comparator Ivan Gyurdiev
2006-01-09 14:12 ` Stephen Smalley

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.