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@redhat.com> Acked-by: Dan Walsh <dwalsh@redhat.com>
This commit is contained in:
parent
79bcfa7286
commit
7e81db0eb8
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue