summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2006-09-09 23:11:59 +0000
committerZac Medico <zmedico@gentoo.org>2006-09-09 23:11:59 +0000
commit3ba3548665d60542ae6b8cd856240f55f3ed58ad (patch)
tree96b4f47a00efdfe2003f471f2c884e4687bcb74a
parent159d8a41a2137fde5e3cb8e8d8e6f8bb79c3bf90 (diff)
downloadportage-3ba3548665d60542ae6b8cd856240f55f3ed58ad.tar.gz
portage-3ba3548665d60542ae6b8cd856240f55f3ed58ad.tar.bz2
portage-3ba3548665d60542ae6b8cd856240f55f3ed58ad.zip
For bug #80846, prevent false collisions caused by symlinks. Thanks to Thomas Bettler <bettlertho@sis.unibe.ch> for the initial patch.
svn path=/main/trunk/; revision=4431
-rw-r--r--pym/portage.py14
1 files changed, 13 insertions, 1 deletions
diff --git a/pym/portage.py b/pym/portage.py
index a39e16ee4..14183f22b 100644
--- a/pym/portage.py
+++ b/pym/portage.py
@@ -5574,6 +5574,7 @@ class dblink:
self.updateprotect = protect_obj.updateprotect
self.isprotected = protect_obj.isprotected
self.contentscache=[]
+ self._contents_inodes = None
def lockdb(self):
if self.lock_num == 0:
@@ -5856,13 +5857,24 @@ class dblink:
destfile = normalize_path(
os.path.join(destroot, filename.lstrip(os.path.sep)))
try:
- os.lstat(destfile) # lexists requires >=python-2.4
+ mylstat = os.lstat(destfile)
except OSError:
return True
pkgfiles = self.getcontents()
if pkgfiles and filename in pkgfiles:
return True
+ if pkgfiles:
+ if self._contents_inodes is None:
+ self._contents_inodes = set()
+ for x in pkgfiles:
+ try:
+ lstat = os.lstat(x)
+ self._contents_inodes.add((lstat.st_dev, lstat.st_ino))
+ except OSError:
+ pass
+ if (mylstat.st_dev, mylstat.st_ino) in self._contents_inodes:
+ return True
return False