All of lore.kernel.org
 help / color / mirror / Atom feed
* Fixes for libselinux/matchpathcon
@ 2009-04-01 14:19 Daniel J Walsh
  2009-05-07 18:18 ` Chad Sellers
  0 siblings, 1 reply; 3+ messages in thread
From: Daniel J Walsh @ 2009-04-01 14:19 UTC (permalink / raw)
  To: SE Linux

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

Removing trailing / if given to matchpathcon.

If matchpathcon returns ENOENT, we return <<none>>

[-- Attachment #2: matchpathcon.patch --]
[-- Type: text/plain, Size: 825 bytes --]

--- nsalibselinux/utils/matchpathcon.c	2009-03-06 14:41:45.000000000 -0500
+++ libselinux-2.0.79/utils/matchpathcon.c	2009-03-27 10:09:31.000000000 -0400
@@ -22,9 +22,13 @@
 	char *buf;
 	int rc = matchpathcon(path, mode, &buf);
 	if (rc < 0) {
-		fprintf(stderr, "matchpathcon(%s) failed: %s\n", path,
-			strerror(errno));
-		return 1;
+		if (errno == ENOENT) {
+			buf=strdup("<<none>>");
+		} else {
+			fprintf(stderr, "matchpathcon(%s) failed: %s\n", path,
+				strerror(errno));
+			return 1;
+		}
 	}
 	if (header)
 		printf("%s\t%s\n", path, buf);
@@ -101,6 +105,11 @@
 	for (i = optind; i < argc; i++) {
 		int mode = 0;
 		struct stat buf;
+		int len = strlen(argv[i]);
+		if (len > 1  && argv[i][len - 1 ] == '/') {
+			argv[i][len - 1 ] = '\0';
+		}
+
 		if (lstat(argv[i], &buf) == 0)
 			mode = buf.st_mode;
 

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

end of thread, other threads:[~2009-05-07 18:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-04-01 14:19 Fixes for libselinux/matchpathcon Daniel J Walsh
2009-05-07 18:18 ` Chad Sellers
2009-05-07 18:29   ` Daniel J Walsh

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.