summaryrefslogtreecommitdiffstats
path: root/pym/portage/checksum.py
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2012-09-11 23:24:44 -0700
committerZac Medico <zmedico@gentoo.org>2012-09-11 23:24:44 -0700
commit09de8dc47ec48af2276dfa098dd5e1d3d09ddbdd (patch)
treeb3426b3ae1071f15fa20d9ef99a9eae73562b521 /pym/portage/checksum.py
parent5614fa2d7cef0b509136fd00c52a8436d41a3647 (diff)
downloadportage-09de8dc47ec48af2276dfa098dd5e1d3d09ddbdd.tar.gz
portage-09de8dc47ec48af2276dfa098dd5e1d3d09ddbdd.tar.bz2
portage-09de8dc47ec48af2276dfa098dd5e1d3d09ddbdd.zip
Replace getstatusoutput with unicode safe Popen.
This fixes potential issues similar to those reported in bug #310789.
Diffstat (limited to 'pym/portage/checksum.py')
-rw-r--r--pym/portage/checksum.py17
1 files changed, 13 insertions, 4 deletions
diff --git a/pym/portage/checksum.py b/pym/portage/checksum.py
index 144e6336f..30a9234e1 100644
--- a/pym/portage/checksum.py
+++ b/pym/portage/checksum.py
@@ -10,6 +10,8 @@ from portage import _encodings
from portage import _unicode_encode
import errno
import stat
+import sys
+import subprocess
import tempfile
#dict of all available hash functions
@@ -163,11 +165,18 @@ hashfunc_map["size"] = getsize
prelink_capable = False
if os.path.exists(PRELINK_BINARY):
- results = portage.subprocess_getstatusoutput(
- "%s --version > /dev/null 2>&1" % (PRELINK_BINARY,))
- if (results[0] >> 8) == 0:
+ cmd = [PRELINK_BINARY, "--version"]
+ if sys.hexversion < 0x3000000 or sys.hexversion >= 0x3020000:
+ # Python 3.1 does not support bytes in Popen args.
+ cmd = [_unicode_encode(x, encoding=_encodings['fs'], errors='strict')
+ for x in cmd]
+ proc = subprocess.Popen(cmd, stdout=subprocess.PIPE,
+ stderr=subprocess.STDOUT)
+ proc.communicate()
+ status = proc.wait()
+ if os.WIFEXITED(status) and os.WEXITSTATUS(status) == os.EX_OK:
prelink_capable=1
- del results
+ del cmd, proc, status
def is_prelinkable_elf(filename):
f = _open_file(filename)