[Yum-devel] [PATCH 2/2] Override the umask settings for mkdir() too. Second part of BZ 719467.

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


---
 yum/rpmsack.py |   17 ++++++++++++++---
 1 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/yum/rpmsack.py b/yum/rpmsack.py
index ed9cabf..9717912 100644
--- a/yum/rpmsack.py
+++ b/yum/rpmsack.py
@@ -48,6 +48,17 @@ def _open_no_umask(*args):
 
     return ret
 
+def _makedirs_no_umask(*args):
+    """ Annoying people like to set umask's for root, which screws everything
+        up for user readable stuff. """
+    oumask = os.umask(022)
+    try:
+        ret = os.makedirs(*args)
+    finally:
+        os.umask(oumask)
+
+    return ret
+
 def _iopen(*args):
     """ IOError wrapper BS for open, stupid exceptions. """
     try:
@@ -1088,7 +1099,7 @@ class RPMDBPackageSack(PackageSackBase):
                 return
 
             try:
-                os.makedirs(self._cachedir)
+                _makedirs_no_umask(self._cachedir)
             except (IOError, OSError), e:
                 return
 
@@ -1562,7 +1573,7 @@ class RPMDBAdditionalData(object):
         self._packages = {} # pkgid = dir
         if not os.path.exists(self.conf.db_path):
             try:
-                os.makedirs(self.conf.db_path)
+                _makedirs_no_umask(self.conf.db_path)
             except (IOError, OSError), e:
                 # some sort of useful thing here? A warning?
                 return
@@ -1708,7 +1719,7 @@ class RPMDBAdditionalDataPackage(object):
     def _write(self, attr, value):
         # check for self._conf.writable before going on?
         if not os.path.exists(self._mydir):
-            os.makedirs(self._mydir)
+            _makedirs_no_umask(self._mydir)
 
         attr = _sanitize(attr)
         if attr in self._read_cached_data:
-- 
1.7.5.4



More information about the Yum-devel mailing list