[PATCH 70/77] policycoreutils: setfiles: Fix process_glob to handle

[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.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk5X5MYACgkQrlYvE4MpobPmDwCgyWKa0vdULxI60x1aUXspb2ge
qKoAoJ+3LlaiBW7c1qOee80Wb7Tn6g15
=FXot
-----END PGP SIGNATURE-----
>From ec33f673756ce7e9ba0844ddbaf7ade2e3747d2a Mon Sep 17 00:00:00 2001
From: Dan Walsh <dwalsh@xxxxxxxxxx>
Date: Tue, 23 Aug 2011 14:46:37 -0400
Subject: [PATCH 70/77] policycoreutils: setfiles: Fix process_glob to handle
 error situations properly

Rather than error when a glob does not match return success as this is
not a problem.

Signed-off-by: Eric Paris <eparis@xxxxxxxxxx>
---
 policycoreutils/setfiles/restore.c |   26 ++++++++++++++------------
 1 files changed, 14 insertions(+), 12 deletions(-)

diff --git a/policycoreutils/setfiles/restore.c b/policycoreutils/setfiles/restore.c
index 66cb950..5bcb44a 100644
--- a/policycoreutils/setfiles/restore.c
+++ b/policycoreutils/setfiles/restore.c
@@ -373,19 +373,21 @@ int process_glob(char *name, int recurse) {
 	int errors;
 	memset(&globbuf, 0, sizeof(globbuf));
 	errors = glob(name, GLOB_TILDE | GLOB_PERIOD, NULL, &globbuf);
-	if (errors)
-		errors = process_one_realpath(name, recurse);
-	else {
-		for (i = 0; i < globbuf.gl_pathc; i++) {
-			int len = strlen(globbuf.gl_pathv[i]) -2;
-			if (len > 0 && strcmp(&globbuf.gl_pathv[i][len--], "/.") == 0)
-				continue;
-			if (len > 0 && strcmp(&globbuf.gl_pathv[i][len], "/..") == 0)
-				continue;
-			errors |= process_one_realpath(globbuf.gl_pathv[i], recurse);
-		}
-		globfree(&globbuf);
+	if (errors == GLOB_NOMATCH)
+		return 0;
+
+	if (errors) 
+		return errors;
+
+	for (i = 0; i < globbuf.gl_pathc; i++) {
+		int len = strlen(globbuf.gl_pathv[i]) -2;
+		if (len > 0 && strcmp(&globbuf.gl_pathv[i][len--], "/.") == 0)
+			continue;
+		if (len > 0 && strcmp(&globbuf.gl_pathv[i][len], "/..") == 0)
+			continue;
+		errors |= process_one_realpath(globbuf.gl_pathv[i], recurse);
 	}
+	globfree(&globbuf);
 	return errors;
 }
 
-- 
1.7.6


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

  Powered by Linux