Bug #162542 - When checking permissions inside CCACHE_DIR for compatibility
authorZac Medico <zmedico@gentoo.org>
Tue, 8 Apr 2008 22:46:36 +0000 (22:46 -0000)
committerZac Medico <zmedico@gentoo.org>
Tue, 8 Apr 2008 22:46:36 +0000 (22:46 -0000)
with FEATURES=userpriv, check the permissions on files inside the directory
to decide whether to fix the permissions. (trunk r9759)

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

pym/portage.py

index cac0316b706bfce13d242a4f678171781f3c49bf..ca3445548dc41f739e29b0dbb2ee605430cf35bb 100644 (file)
@@ -4234,12 +4234,34 @@ def prepare_build_dirs(myroot, mysettings, cleanup):
                                        if droppriv:
                                                st = os.stat(mydir)
                                                if st.st_gid != portage_gid or \
-                                                       not stat.S_IMODE(st.st_mode) & dirmode:
+                                                       not dirmode == (stat.S_IMODE(st.st_mode) & dirmode):
                                                        droppriv_fix = True
+                                               if not droppriv_fix:
+                                                       # Check permissions of files in the directory.
+                                                       for filename in os.listdir(mydir):
+                                                               try:
+                                                                       subdir_st = os.lstat(
+                                                                               os.path.join(mydir, filename))
+                                                               except OSError:
+                                                                       continue
+                                                               if subdir_st.st_gid != portage_gid or \
+                                                                       ((stat.S_ISDIR(subdir_st.st_mode) and \
+                                                                       not dirmode == (stat.S_IMODE(subdir_st.st_mode) & dirmode)) or \
+                                                                       (not stat.S_ISDIR(subdir_st.st_mode) and \
+                                                                       not filemode == (stat.S_IMODE(subdir_st.st_mode) & filemode))):
+                                                                       droppriv_fix = True
+                                                                       break
+                                       if droppriv_fix:
+                                               writemsg(colorize("WARN", " * ") + \
+                                                        "Adjusting permissions " + \
+                                                        "for FEATURES=userpriv: '%s'\n" % mydir,
+                                                       noiselevel=-1)
+                                       elif modified:
+                                               writemsg(colorize("WARN", " * ") + \
+                                                        "Adjusting permissions " + \
+                                                        "for FEATURES=%s: '%s'\n" % (myfeature, mydir),
+                                                       noiselevel=-1)
                                        if modified or kwargs["always_recurse"] or droppriv_fix:
-                                               if modified:
-                                                       writemsg("Adjusting permissions recursively: '%s'\n" % mydir,
-                                                               noiselevel=-1)
                                                def onerror(e):
                                                        raise   # The feature is disabled if a single error
                                                                        # occurs during permissions adjustment.