Skip to contentSkip to conversation

libselinux: allow shell-style wildcarding in X names

PATCH In review Eamon Walsh 2 participants 2 messages Nov 14, 2008 – Nov 15, 2008 SELinux security module

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libselinux: allow shell-style wildcarding in X names

This patch replaces the exact strcmp/single fixed wildcard in the X contexts code with a call to fnmatch(3) which will allow shell-style matching constructions (*, ?, and []) in the x_contexts file, such as:

property XT_SELECTION* system_u:object_r:clipboard_xproperty_t:s0

---

 label_x.c |    5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
libselinux/src/label_x.c +2 -3
index 6a190f5..a9bfaa5 100644
@@ -11,6 +11,7 @@
 #include <ctype.h>
 #include <errno.h>
 #include <limits.h>
+#include <fnmatch.h>
 #include "callbacks.h"
 #include "label_internal.h"
 
@@ -199,9 +200,7 @@ static struct selabel_lookup_rec *lookup(struct selabel_handle *rec,
 	for (i = 0; i < data->nspec; i++) {
 		if (spec_arr[i].type != type)
 			continue;
-		if (!strncmp(spec_arr[i].key, "*", 2))
-			break;
-		if (!strncmp(spec_arr[i].key, key, strlen(key) + 1))
+		if (!fnmatch(spec_arr[i].key, key, 0))
 			break;
 	}
 
Signature · 8 lines
Eamon Walsh <[email protected]>
National Security Agency


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#1 lore raw
Quoted 3 lines · Eamon Walsh

This patch replaces the exact strcmp/single fixed wildcard in the X contexts code with a call to fnmatch(3) which will allow shell-style matching constructions (*, ?, and []) in the x_contexts file,

Most appreciated

joe

Quoted 48 lines

such as:

property XT_SELECTION* system_u:object_r:clipboard_xproperty_t:s0

---

label_x.c | 5 ++---

1 file changed, 2 insertions(+), 3 deletions(-)
libselinux/src/label_x.c +2 -3
index 6a190f5..a9bfaa5 100644
@@ -11,6 +11,7 @@
 #include <ctype.h>
 #include <errno.h>
 #include <limits.h>
+#include <fnmatch.h>
 #include "callbacks.h"
 #include "label_internal.h"
 
@@ -199,9 +200,7 @@ static struct selabel_lookup_rec *lookup(struct  
 selabel_handle *rec,
 	for (i = 0; i < data->nspec; i++) {
 		if (spec_arr[i].type != type)
 			continue;
-		if (!strncmp(spec_arr[i].key, "*", 2))
-			break;
-		if (!strncmp(spec_arr[i].key, key, strlen(key) + 1))
+		if (!fnmatch(spec_arr[i].key, key, 0))
 			break;
 	}
Signature · 10 lines
-- 
Eamon Walsh <[email protected]>
National Security Agency


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] 
 with
the words "unsubscribe selinux" without quotes as the message.

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.