Make config._init_dirs() preserver /tmp and /var/tmp permissions if
authorZac Medico <zmedico@gentoo.org>
Tue, 27 May 2008 07:56:26 +0000 (07:56 -0000)
committerZac Medico <zmedico@gentoo.org>
Tue, 27 May 2008 07:56:26 +0000 (07:56 -0000)
those directories already exist. This gives freedom to the user to
adjust permissions to suit their taste. (trunk r10451:10453)

svn path=/main/branches/2.1.2/; revision=10454

pym/portage.py

index b126fac3e40df482a4f9e23f9134a022064ead13..1bbd323534868384da38dd478ffceb6f34987831 100644 (file)
@@ -1776,16 +1776,23 @@ class config:
                if not os.access(self["ROOT"], os.W_OK):
                        return
 
+               #                                     gid, mode, mask, preserve_perms
                dir_mode_map = {
-                       "tmp"             :(-1,          01777, 0),
-                       "var/tmp"         :(-1,          01777, 0),
-                       "var/lib/portage" :(portage_gid, 02750, 02),
-                       "var/cache/edb"   :(portage_gid,  0755, 02)
+                       "tmp"             : (                      -1, 01777,  0,  True),
+                       "var/tmp"         : (                      -1, 01777,  0,  True),
+                       PRIVATE_PATH      : (             portage_gid, 02750, 02,  False),
+                       CACHE_PATH.lstrip(os.path.sep) : (portage_gid,  0755, 02,  False)
                }
 
-               for mypath, (gid, mode, modemask) in dir_mode_map.iteritems():
+               for mypath, (gid, mode, modemask, preserve_perms) \
+                       in dir_mode_map.iteritems():
+                       mydir = os.path.join(self["ROOT"], mypath)
+                       if preserve_perms and os.path.isdir(mydir):
+                               # Only adjust permissions on some directories if
+                               # they don't exist yet. This gives freedom to the
+                               # user to adjust permissions to suit their taste.
+                               continue
                        try:
-                               mydir = os.path.join(self["ROOT"], mypath)
                                portage_util.ensure_dirs(mydir, gid=gid, mode=mode, mask=modemask)
                        except portage_exception.PortageException, e:
                                writemsg("!!! Directory initialization failed: '%s'\n" % mydir,