summaryrefslogtreecommitdiffstats
path: root/pym/portage/data.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/data.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/data.py')
-rw-r--r--pym/portage/data.py23
1 files changed, 17 insertions, 6 deletions
diff --git a/pym/portage/data.py b/pym/portage/data.py
index c4d967a1b..b922ff8e9 100644
--- a/pym/portage/data.py
+++ b/pym/portage/data.py
@@ -1,13 +1,14 @@
# data.py -- Calculated/Discovered Data Values
-# Copyright 1998-2011 Gentoo Foundation
+# Copyright 1998-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
-import os, pwd, grp, platform
+import os, pwd, grp, platform, sys
import portage
portage.proxy.lazyimport.lazyimport(globals(),
'portage.output:colorize',
'portage.util:writemsg',
+ 'subprocess'
)
from portage.localization import _
@@ -129,10 +130,20 @@ def _get_global(k):
# Get a list of group IDs for the portage user. Do not use
# grp.getgrall() since it is known to trigger spurious
# SIGPIPE problems with nss_ldap.
- mystatus, myoutput = \
- portage.subprocess_getstatusoutput("id -G %s" % _portage_username)
- if mystatus == os.EX_OK:
- for x in myoutput.split():
+ cmd = ["id", "-G", _portage_username]
+ encoding = portage._encodings['content']
+ if sys.hexversion < 0x3000000 or sys.hexversion >= 0x3020000:
+ # Python 3.1 does not support bytes in Popen args.
+ cmd = [portage._unicode_encode(x,
+ encoding=encoding, errors='strict')
+ for x in cmd]
+ proc = subprocess.Popen(cmd, stdout=subprocess.PIPE,
+ stderr=subprocess.STDOUT)
+ myoutput = proc.communicate()[0]
+ status = proc.wait()
+ if os.WIFEXITED(status) and os.WEXITSTATUS(status) == os.EX_OK:
+ for x in portage._unicode_decode(myoutput,
+ encoding=encoding, errors='strict').split():
try:
v.append(int(x))
except ValueError: