[Yum-devel] [PATCH] make sure we behave correctly if we cannot get the cachedir setup

Seth Vidal skvidal at fedoraproject.org
Wed Dec 9 20:14:15 UTC 2009


if someone sets the perms on the tmpdir/cachedir VERY wrong make sure
we emit an error and do something sensible about it.

rh bug: https://bugzilla.redhat.com/show_bug.cgi?id=543768
---
 yum/__init__.py |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/yum/__init__.py b/yum/__init__.py
index 9613378..220be09 100644
--- a/yum/__init__.py
+++ b/yum/__init__.py
@@ -4168,8 +4168,12 @@ class YumBase(depsolve.Depsolve):
 
         if not force and os.geteuid() == 0:
             return True # We are root, not forced, so happy with the global dir.
-
-        cachedir = misc.getCacheDir(tmpdir, reuse)
+        try:
+            cachedir = misc.getCacheDir(tmpdir, reuse)
+        except (IOError, OSError), e:
+            self.logger.critical(_('Could not set cachedir: %s') % str(e))
+            cachedir = None
+            
         if cachedir is None:
             return False # Tried, but failed, to get a "user" cachedir
 
-- 
1.6.5.2



More information about the Yum-devel mailing list