fetch: don't apply permissions to symlinks
authorZac Medico <zmedico@gentoo.org>
Thu, 22 Dec 2011 19:10:18 +0000 (11:10 -0800)
committerZac Medico <zmedico@gentoo.org>
Thu, 22 Dec 2011 19:10:18 +0000 (11:10 -0800)
We don't want to modify anything outside of the primary DISTDIR,
and symlinks typically point to PORTAGE_RO_DISTDIRS. This will
fix bug #395705.

pym/portage/package/ebuild/fetch.py

index 70743bfb21f342079479131c0ab2e0a5796c087f..c67f3c4f410982972bce1034c7a9d7fd586328f8 100644 (file)
@@ -633,7 +633,10 @@ def fetch(myuris, mysettings, listonly=0, fetchonly=0,
                                match, mystat = _check_distfile(
                                        myfile_path, pruned_digests, eout)
                                if match:
-                                       if distdir_writable:
+                                       # Skip permission adjustment for symlinks, since we don't
+                                       # want to modify anything outside of the primary DISTDIR,
+                                       # and symlinks typically point to PORTAGE_RO_DISTDIRS.
+                                       if distdir_writable and not os.path.islink(myfile_path):
                                                try:
                                                        apply_secpass_permissions(myfile_path,
                                                                gid=portage_gid, mode=0o664, mask=0o2,
@@ -747,14 +750,18 @@ def fetch(myuris, mysettings, listonly=0, fetchonly=0,
                                                raise
                                        del e
                                else:
-                                       try:
-                                               apply_secpass_permissions(
-                                                       myfile_path, gid=portage_gid, mode=0o664, mask=0o2,
-                                                       stat_cached=mystat)
-                                       except PortageException as e:
-                                               if not os.access(myfile_path, os.R_OK):
-                                                       writemsg(_("!!! Failed to adjust permissions:"
-                                                               " %s\n") % str(e), noiselevel=-1)
+                                       # Skip permission adjustment for symlinks, since we don't
+                                       # want to modify anything outside of the primary DISTDIR,
+                                       # and symlinks typically point to PORTAGE_RO_DISTDIRS.
+                                       if not os.path.islink(myfile_path):
+                                               try:
+                                                       apply_secpass_permissions(myfile_path,
+                                                               gid=portage_gid, mode=0o664, mask=0o2,
+                                                               stat_cached=mystat)
+                                               except PortageException as e:
+                                                       if not os.access(myfile_path, os.R_OK):
+                                                               writemsg(_("!!! Failed to adjust permissions:"
+                                                                       " %s\n") % (e,), noiselevel=-1)
 
                                        # If the file is empty then it's obviously invalid. Remove
                                        # the empty file and try to download if possible.