[PATCH 35/48] libselinux: selinuxswig_python.i: don't make syscall

[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/

iEYEARECAAYFAk7dHUIACgkQrlYvE4MpobPMeACaAsc9zD+5Rtj/XxkfrAdOHqw3
G6oAoI4AZwL5kMg0+IKYMZEMLHZZ7V94
=ijAa
-----END PGP SIGNATURE-----
>From b6907a4749667ca7e5bc64c548f802f5f98e32b4 Mon Sep 17 00:00:00 2001
From: Dan Walsh <dwalsh@xxxxxxxxxx>
Date: Tue, 29 Nov 2011 09:44:27 -0500
Subject: [PATCH 35/48] libselinux: selinuxswig_python.i: don't make syscall
 if it won't change anything

Add a check to restorecon, to not change a context if the context on disk matches

Signed-off-by: Eric Paris <eparis@xxxxxxxxxx>
---
 libselinux/src/selinuxswig_python.i |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

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)
-- 
1.7.7.4


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

  Powered by Linux