[PATCH 77/90] Allow matchpathcon to use multiple prefixes and test

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


   This patch looks good to me. acked.

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk/I+6AACgkQrlYvE4MpobONTwCfYxX5SNV2+hHvDy90ljfs3oRL
GZMAn3vAzZnRqJKEL/EG3usgcM+bx1mj
=uFgV
-----END PGP SIGNATURE-----
>From b01f61769e59923fc48b85c0c889d30d29a4874b Mon Sep 17 00:00:00 2001
From: Dan Walsh <dwalsh@xxxxxxxxxx>
Date: Wed, 30 May 2012 16:08:05 -0400
Subject: [PATCH 77/90] Allow matchpathcon to use multiple prefixes and test
 new prefix code in label_init

---
 libselinux/utils/matchpathcon.c |   32 ++++++++++++++++++++------------
 1 file changed, 20 insertions(+), 12 deletions(-)

diff --git a/libselinux/utils/matchpathcon.c b/libselinux/utils/matchpathcon.c
index b1adadd..b0dc01d 100644
--- a/libselinux/utils/matchpathcon.c
+++ b/libselinux/utils/matchpathcon.c
@@ -45,12 +45,15 @@ static int printmatchpathcon(const char *path, int header, int mode)
 
 int main(int argc, char **argv)
 {
-	int i, init = 0;
+	int i;
 	int header = 1, opt;
 	int verify = 0;
 	int notrans = 0;
 	int error = 0;
 	int quiet = 0;
+	const char *prefixes[100];
+	int file=0;
+	int prefix=0;
 
 	if (argc < 2)
 		usage(argv[0]);
@@ -68,13 +71,13 @@ int main(int argc, char **argv)
 			set_matchpathcon_flags(MATCHPATHCON_NOTRANS);
 			break;
 		case 'f':
-			if (init) {
+			if (prefix) {
 				fprintf(stderr,
 					"%s:  -f and -p are exclusive\n",
 					argv[0]);
 				exit(1);
 			}
-			init = 1;
+			file = 1;
 			if (matchpathcon_init(optarg)) {
 				fprintf(stderr,
 					"Error while processing %s:  %s\n",
@@ -84,20 +87,15 @@ int main(int argc, char **argv)
 			}
 			break;
 		case 'p':
-			if (init) {
+			if (file) {
 				fprintf(stderr,
 					"%s:  -f and -p are exclusive\n",
 					argv[0]);
 				exit(1);
 			}
-			init = 1;
-			if (matchpathcon_init_prefix(NULL, optarg)) {
-				fprintf(stderr,
-					"Error while processing %s:  %s\n",
-					optarg,
-					errno ? strerror(errno) : "invalid");
-				exit(1);
-			}
+			prefixes[prefix]=optarg;
+			prefix++;
+			prefixes[prefix]=NULL;
 			break;
 		case 'q':
 			quiet = 1;
@@ -106,6 +104,16 @@ int main(int argc, char **argv)
 			usage(argv[0]);
 		}
 	}
+	if (prefix > 0) {
+		if (matchpathcon_init_prefixes(NULL, prefixes)) {
+			fprintf(stderr,
+				"Error while processing %s:  %s\n",
+				optarg,
+				errno ? strerror(errno) : "invalid");
+			exit(1);
+		}
+	}
+
 	for (i = optind; i < argc; i++) {
 		int rc, mode = 0;
 		struct stat buf;
-- 
1.7.10.2


[Index of Archives]     [Selinux Refpolicy]     [Linux SGX]     [Fedora Users]     [Fedora Desktop]     [Yosemite Photos]     [Yosemite Camping]     [Yosemite Campsites]     [KDE Users]     [Gnome Users]

  Powered by Linux