Revert some changes which are causing the wrong policy version file to be created

This commit is contained in:
Dan Walsh 2013-02-14 07:58:54 -05:00
parent 1021fcbc45
commit 518c1aa0ae
2 changed files with 4 additions and 74 deletions

View File

@ -1,73 +0,0 @@
diff --git a/libsemanage/src/handle.c b/libsemanage/src/handle.c
index 7fcd2b4..6aa9057 100644
--- a/libsemanage/src/handle.c
+++ b/libsemanage/src/handle.c
@@ -52,6 +52,26 @@ static char *private_usersconf_path = NULL;
static char *private_netfilter_context_path = NULL;
static char *private_policy_root = NULL;
+static char *get_policy_path(void) {
+ char *dup_path = NULL;
+ int max = security_policyvers();
+ if (max < 0)
+ max = sepol_policy_kern_vers_max();
+
+ char *policy_path = selinux_binary_policy_path_min_max(0, &max);
+ if (policy_path) {
+ dup_path = strdup(policy_path);
+ free(policy_path);
+ } else {
+ /* No Policy installed so just do max */
+ int ret = asprintf(&policy_path, "%s.%d", selinux_binary_policy_path(), sepol_policy_kern_vers_max());
+ if (ret > 0)
+ dup_path = strdup(policy_path);
+ free(policy_path);
+ }
+ return dup_path;
+}
+
void semanage_free_root() {
free(private_selinux_path); private_selinux_path = NULL;
free(private_semanage_conf_path); private_semanage_conf_path = NULL;
@@ -91,9 +111,15 @@ int semanage_set_root(const char *path) {
goto error;
}
- if ( asprintf(&private_binary_policy_path, "%s/%s", path, selinux_binary_policy_path()) < 0 ) {
+ char *policy_path = get_policy_path();
+ if (! policy_path)
+ goto error;
+
+ if ( asprintf(&private_binary_policy_path, "%s/%s", path, policy_path) < 0 ) {
+ free(policy_path);
goto error;
}
+ free(policy_path);
if ( asprintf(&private_usersconf_path, "%s/%s", path, selinux_usersconf_path()) < 0 ) {
goto error;
@@ -147,7 +173,9 @@ const char *semanage_binary_policy_path() {
// printf("private_binary_policy_path %s\n", private_binary_policy_path);
if (private_binary_policy_path)
return private_binary_policy_path;
- return selinux_binary_policy_path();
+
+ private_binary_policy_path = get_policy_path();
+ return private_binary_policy_path;
}
const char *semanage_usersconf_path() {
diff --git a/libsemanage/src/semanage_store.c b/libsemanage/src/semanage_store.c
index 57ef49f..7ddaff9 100644
--- a/libsemanage/src/semanage_store.c
+++ b/libsemanage/src/semanage_store.c
@@ -1134,8 +1134,7 @@ static int semanage_install_active(semanage_handle_t * sh)
if (asprintf(&storepath, "%s%s", semanage_selinux_path(), sh->conf->store_path) < 0)
return retval;
- snprintf(store_pol, PATH_MAX, "%s%s.%d", storepath,
- running_policy, sh->conf->policyvers);
+ snprintf(store_pol, PATH_MAX, "%s%s", storepath, running_policy);
if (semanage_copy_file(active_kernel, store_pol, sh->conf->file_mode) ==
-1) {
ERR(sh, "Could not copy %s to %s.", active_kernel, store_pol);

View File

@ -10,7 +10,7 @@
Summary: SELinux binary policy manipulation library
Name: libsemanage
Version: 2.1.10
Release: 1%{?dist}
Release: 2%{?dist}
License: LGPLv2+
Group: System Environment/Libraries
Source: libsemanage-%{version}.tgz
@ -181,6 +181,9 @@ rm -rf ${RPM_BUILD_ROOT}
%endif # if with_python3
%changelog
* Thu Feb 14 2013 Dan Walsh <dwalsh@redhat.com> - 2.1.10-2
- Revert some changes which are causing the wrong policy version file to be created
* Thu Feb 7 2013 Dan Walsh <dwalsh@redhat.com> - 2.1.10-1
- Update to upstream
* Add sefcontext_compile to compile regex everytime policy is rebuilt