b150c9d
diff -up setools-3.3.7/libqpol/src/util.c.current setools-3.3.7/libqpol/src/util.c
b150c9d
--- setools-3.3.7/libqpol/src/util.c.current	2010-04-23 12:22:08.000000000 -0400
b150c9d
+++ setools-3.3.7/libqpol/src/util.c	2012-02-16 12:01:33.030434514 -0500
b150c9d
@@ -84,75 +84,12 @@ static int get_binpol_version(const char
b150c9d
 
b150c9d
 static int search_policy_binary_file(char **path)
b150c9d
 {
b150c9d
-	const char *binary_path;
b150c9d
-	if ((binary_path = selinux_binary_policy_path()) == NULL) {
b150c9d
-		return -1;
b150c9d
+	const char *binary_path = selinux_current_policy_path();
b150c9d
+	if (binary_path) {
b150c9d
+		*path = strdup(binary_path);
b150c9d
+		if (*path) return 0;
b150c9d
 	}
b150c9d
-
b150c9d
-	int expected_version = -1, latest_version = -1;
b150c9d
-#ifdef LIBSELINUX
b150c9d
-	/* if the system has SELinux enabled, prefer the policy whose
b150c9d
-	   name matches the current policy version */
b150c9d
-	if ((expected_version = security_policyvers()) < 0) {
b150c9d
-		return -1;
b150c9d
-	}
b150c9d
-#endif
b150c9d
-
b150c9d
-	glob_t glob_buf;
b150c9d
-	struct stat fs;
b150c9d
-	int rt, error = 0, retval = -1;
b150c9d
-	size_t i;
b150c9d
-	char *pattern = NULL;
b150c9d
-	if (asprintf(&pattern, "%s.*", binary_path) < 0) {
b150c9d
-		return -1;
b150c9d
-	}
b150c9d
-	glob_buf.gl_offs = 1;
b150c9d
-	glob_buf.gl_pathc = 0;
b150c9d
-	rt = glob(pattern, GLOB_DOOFFS, NULL, &glob_buf);
b150c9d
-	if (rt != 0 && rt != GLOB_NOMATCH) {
b150c9d
-		errno = EIO;
b150c9d
-		return -1;
b150c9d
-	}
b150c9d
-
b150c9d
-	for (i = 0; i < glob_buf.gl_pathc; i++) {
b150c9d
-		char *p = glob_buf.gl_pathv[i + glob_buf.gl_offs];
b150c9d
-		if (stat(p, &fs) != 0) {
b150c9d
-			error = errno;
b150c9d
-			goto cleanup;
b150c9d
-		}
b150c9d
-		if (S_ISDIR(fs.st_mode))
b150c9d
-			continue;
b150c9d
-
b150c9d
-		if ((rt = get_binpol_version(p)) < 0) {
b150c9d
-			error = errno;
b150c9d
-			goto cleanup;
b150c9d
-		}
b150c9d
-
b150c9d
-		if (rt > latest_version || rt == expected_version) {
b150c9d
-			free(*path);
b150c9d
-			if ((*path = strdup(p)) == NULL) {
b150c9d
-				error = errno;
b150c9d
-				goto cleanup;
b150c9d
-			}
b150c9d
-			if (rt == expected_version) {
b150c9d
-				break;
b150c9d
-			}
b150c9d
-			latest_version = rt;
b150c9d
-		}
b150c9d
-	}
b150c9d
-
b150c9d
-	if (*path == NULL) {
b150c9d
-		retval = 1;
b150c9d
-	} else {
b150c9d
-		retval = 0;
b150c9d
-	}
b150c9d
-      cleanup:
b150c9d
-	free(pattern);
b150c9d
-	globfree(&glob_buf);
b150c9d
-	if (retval == -1) {
b150c9d
-		errno = error;
b150c9d
-	}
b150c9d
-	return retval;
b150c9d
+	return -1;
b150c9d
 }
b150c9d
 
b150c9d
 int qpol_default_policy_find(char **path)