binarytree: copy g+rw from PKGDIR to files v2.2.0_alpha171
authorZac Medico <zmedico@gentoo.org>
Mon, 1 Apr 2013 17:25:34 +0000 (10:25 -0700)
committerZac Medico <zmedico@gentoo.org>
Mon, 1 Apr 2013 17:25:34 +0000 (10:25 -0700)
pym/portage/dbapi/bintree.py

index 875e955151c3a2e733c17ab2cacefb15c91763d2..01dbad18aec692ac1265704c8d17443f0be97c97 100644 (file)
@@ -563,6 +563,20 @@ class binarytree(object):
                        if not os.path.isdir(path):
                                raise
 
+       def _file_permissions(self, path):
+               try:
+                       pkgdir_st = os.stat(self.pkgdir)
+               except OSError:
+                       pass
+               else:
+                       pkgdir_gid = pkgdir_st.st_gid
+                       pkgdir_grp_mode = 0o0060 & pkgdir_st.st_mode
+                       try:
+                               portage.util.apply_permissions(path, gid=pkgdir_gid,
+                                       mode=pkgdir_grp_mode, mask=0)
+                       except PortageException:
+                               pass
+
        def _move_to_all(self, cpv):
                """If the file exists, move it.  Whether or not it exists, update state
                for future getname() calls."""
@@ -1075,6 +1089,10 @@ class binarytree(object):
                                if not samefile:
                                        self._ensure_dir(os.path.dirname(new_filename))
                                        _movefile(filename, new_filename, mysettings=self.settings)
+                               full_path = new_filename
+
+                       self._file_permissions(full_path)
+
                        if self._all_directory and \
                                self.getname(cpv).split(os.path.sep)[-2] == "All":
                                self._create_symlink(cpv)
@@ -1147,6 +1165,7 @@ class binarytree(object):
                        f.close()
                        if f_close is not None:
                                f_close.close()
+                       self._file_permissions(fname)
                        # some seconds might have elapsed since TIMESTAMP
                        os.utime(fname, (atime, mtime))