[Yum-devel] [PATCH 1/2] Ignore EACCES on yumdb stat calls, which shouldn't happen. But ignore is nicer than traceback. BZ 719467

James Antill james at and.org
Fri Jul 8 19:02:10 UTC 2011


---
 yum/misc.py    |   10 ++++++----
 yum/rpmsack.py |    2 +-
 2 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/yum/misc.py b/yum/misc.py
index 2f6ddfe..37c572b 100644
--- a/yum/misc.py
+++ b/yum/misc.py
@@ -940,14 +940,16 @@ def unlink_f(filename):
         if e.errno != errno.ENOENT:
             raise
 
-def stat_f(filename):
+def stat_f(filename, ignore_EACCES=False):
     """ Call os.stat(), but don't die if the file isn't there. Returns None. """
     try:
         return os.stat(filename)
     except OSError, e:
-        if e.errno not in (errno.ENOENT, errno.ENOTDIR):
-            raise
-        return None
+        if e.errno in (errno.ENOENT, errno.ENOTDIR):
+            return None
+        if ignore_EACCES and e.errno == errno.EACCES:
+            return None
+        raise
 
 def _getloginuid():
     """ Get the audit-uid/login-uid, if available. None is returned if there
diff --git a/yum/rpmsack.py b/yum/rpmsack.py
index e289a7a..ed9cabf 100644
--- a/yum/rpmsack.py
+++ b/yum/rpmsack.py
@@ -1753,7 +1753,7 @@ class RPMDBAdditionalDataPackage(object):
         if attr.endswith('.tmp'):
             raise AttributeError, "%s has no attribute %s" % (self, attr)
 
-        info = misc.stat_f(fn)
+        info = misc.stat_f(fn, ignore_EACCES=True)
         if info is None:
             raise AttributeError, "%s has no attribute %s" % (self, attr)
 
-- 
1.7.5.4



More information about the Yum-devel mailing list