diff options
author | Clark Williams <williams@redhat.com> | 2010-08-09 17:23:13 -0500 |
---|---|---|
committer | Clark Williams <williams@redhat.com> | 2010-08-12 15:06:13 -0500 |
commit | 6da80b5d6b467489492673001005321f5b506cb1 (patch) | |
tree | 79840c152fb70e5772d2ef1e6a4eed90f85b08a5 /py/mock/util.py | |
parent | 59020475e4b76f324298a6c719b55f7435d33ac9 (diff) | |
download | mock-6da80b5d6b467489492673001005321f5b506cb1.tar.gz mock-6da80b5d6b467489492673001005321f5b506cb1.tar.xz mock-6da80b5d6b467489492673001005321f5b506cb1.zip |
pass selinux status to mock.util.rmtree() function (BZ# 614440)
Pass in boolean 'selinux' via keyword arguments that tells
rmtree whether to do retry logic with selinux attributes
Signed-off-by: Clark Williams <williams@redhat.com>
Diffstat (limited to 'py/mock/util.py')
-rw-r--r-- | py/mock/util.py | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/py/mock/util.py b/py/mock/util.py index 764ed04..1752262 100644 --- a/py/mock/util.py +++ b/py/mock/util.py @@ -17,6 +17,7 @@ import select import shutil import subprocess import time +import errno # our imports import mock.exception @@ -72,6 +73,10 @@ decorate(traceLog()) def rmtree(path, *args, **kargs): """version os shutil.rmtree that ignores no-such-file-or-directory errors, and tries harder if it finds immutable files""" + do_selinux_ops = False + if kargs.has_key('selinux'): + do_selinux_ops = kargs['selinux'] + del kargs['selinux'] tryAgain = 1 failedFilename = None getLog().debug("remove tree: %s" % path) @@ -80,9 +85,9 @@ def rmtree(path, *args, **kargs): try: shutil.rmtree(path, *args, **kargs) except OSError, e: - if e.errno == 2: # no such file or directory + if e.errno == errno.ENOENT: # no such file or directory pass - elif e.errno==1 or e.errno==13: + elif do_selinux_ops and (e.errno==errno.EPERM or e.errno==errno.EACCES): tryAgain = 1 if failedFilename == e.filename: raise |