From 7e81db0eb85755947619b6baa69049a7a726fa62 Mon Sep 17 00:00:00 2001 From: Dan Walsh Date: Tue, 29 Nov 2011 09:44:27 -0500 Subject: [PATCH] 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 Acked-by: Dan Walsh --- libselinux/src/selinuxswig_python.i | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libselinux/src/selinuxswig_python.i b/libselinux/src/selinuxswig_python.i index daf83147..359bd02c 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)