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