[libselinux] Change python binding for restorecon to check if the context matches. If it does do not reset

Daniel J Walsh dwalsh at fedoraproject.org
Tue Nov 29 14:48:05 UTC 2011


commit 0921286973d896b7022a6f84c71e7c366ac86325
Author: Dan Walsh <dwalsh at redhat.com>
Date:   Tue Nov 29 09:47:57 2011 -0500

    Change python binding for restorecon to check if the context matches.
    If it does do not reset

 libselinux-rhat.patch |   16 ++++++++++++++++
 libselinux.spec       |    7 ++++++-
 2 files changed, 22 insertions(+), 1 deletions(-)
---
diff --git a/libselinux-rhat.patch b/libselinux-rhat.patch
index 2c5ee11..3c5d55c 100644
--- a/libselinux-rhat.patch
+++ b/libselinux-rhat.patch
@@ -275,3 +275,19 @@ index 710396a..9a3fc14 100644
      hidden_proto(matchpathcon_init_prefix)
      hidden_proto(selinux_users_path)
      hidden_proto(selinux_usersconf_path);
+diff --git a/libselinux/src/selinuxswig_python.i b/libselinux/src/selinuxswig_python.i
+index daf8314..359bd02 100644
+--- a/libselinux/src/selinuxswig_python.i
++++ b/libselinux/src/selinuxswig_python.i
+@@ -22,7 +22,10 @@ def restorecon(path, recursive=False):
+         status, context = matchpathcon(path, mode)
+ 
+     if status == 0:
+-        lsetfilecon(path, context)
++        status, oldcontext = lgetfilecon(path)
++        if context != oldcontext:
++            lsetfilecon(path, context)
++
+         if recursive:
+             os.path.walk(path, lambda arg, dirname, fnames:
+                              map(restorecon, [os.path.join(dirname, fname)
diff --git a/libselinux.spec b/libselinux.spec
index 8c386b4..0d2a9a5 100644
--- a/libselinux.spec
+++ b/libselinux.spec
@@ -7,7 +7,7 @@
 Summary: SELinux library and simple utilities
 Name: libselinux
 Version: 2.1.7
-Release: 1%{?dist}
+Release: 2%{?dist}
 License: Public Domain
 Group: System Environment/Libraries
 Source: %{name}-%{version}.tgz
@@ -231,7 +231,12 @@ rm -rf %{buildroot}
 %{ruby_sitearch}/selinux.so
 
 %changelog
+* Tue Nov 29 2011 Dan Walsh <dwalsh at redhat.com> - 2.1.7-2
+- Change python binding for restorecon to check if the context matches.
+- If it does do not reset
+
 * Fri Nov 4 2011 Dan Walsh <dwalsh at redhat.com> - 2.1.7-1
+- Upgrade to upstream
 	* Makefiles: syntax, convert all ${VAR} to $(VAR)
 	* load_policy: handle selinux=0 and /sys/fs/selinux not exist
 	* regenerate .pc on VERSION change


More information about the scm-commits mailing list