summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2011-09-06 11:34:57 -0700
committerZac Medico <zmedico@gentoo.org>2011-09-06 11:34:57 -0700
commiteab5a6ee1abff1fbf142cf1558ba940b6d4b270a (patch)
tree3ff8163bd01c976f106cb372869fb7fbfdd75059
parent8ce21665b856e24815274240011a4aa81826113a (diff)
downloadportage-eab5a6ee1abff1fbf142cf1558ba940b6d4b270a.tar.gz
portage-eab5a6ee1abff1fbf142cf1558ba940b6d4b270a.tar.bz2
portage-eab5a6ee1abff1fbf142cf1558ba940b6d4b270a.zip
merge: avoid abssymlink readlink call
This will avoid the "OSError: [Errno 2] No such file or directory" that is triggered inside abssymlink if the merge encoding is not ascii or utf_8, as shown in bug #382021.
-rw-r--r--pym/portage/__init__.py7
-rw-r--r--pym/portage/dbapi/vartree.py7
2 files changed, 11 insertions, 3 deletions
diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py
index 901ea2c96..d73ea6d5e 100644
--- a/pym/portage/__init__.py
+++ b/pym/portage/__init__.py
@@ -391,9 +391,12 @@ def getcwd():
return "/"
getcwd()
-def abssymlink(symlink):
+def abssymlink(symlink, target=None):
"This reads symlinks, resolving the relative symlinks, and returning the absolute."
- mylink=os.readlink(symlink)
+ if target is None:
+ mylink = target
+ else:
+ mylink = os.readlink(symlink)
if mylink[0] != '/':
mydir=os.path.dirname(symlink)
mylink=mydir+"/"+mylink
diff --git a/pym/portage/dbapi/vartree.py b/pym/portage/dbapi/vartree.py
index bafe13885..4d0a6dd4c 100644
--- a/pym/portage/dbapi/vartree.py
+++ b/pym/portage/dbapi/vartree.py
@@ -4013,7 +4013,12 @@ class dblink(object):
os.unlink(mysrc)
os.symlink(myto, mysrc)
- myabsto = abssymlink(mysrc)
+ # Pass in the symlink target in order to bypass the
+ # os.readlink() call inside abssymlink(), since that
+ # call is unsafe if the merge encoding is not ascii
+ # or utf_8 (see bug #382021).
+ myabsto = abssymlink(mysrc, target=myto)
+
if myabsto.startswith(srcroot):
myabsto = myabsto[len(srcroot):]
myabsto = myabsto.lstrip(sep)