summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2013-08-11 15:00:30 -0700
committerZac Medico <zmedico@gentoo.org>2013-08-11 15:00:30 -0700
commit538a9a7a71e3359e78445577e2bb9fcc3a53dbba (patch)
tree1f0285707f4877f5ccb9651d4f3180eb90808f3f
parentrepoman: change preserve_old_lib msg, bug #480244 (diff)
downloadportage-538a9a7a71e3359e78445577e2bb9fcc3a53dbba.tar.gz
portage-538a9a7a71e3359e78445577e2bb9fcc3a53dbba.tar.bz2
portage-538a9a7a71e3359e78445577e2bb9fcc3a53dbba.zip
Cast uid/gid proxies to int for Python 3.4.
See http://hg.python.org/cpython/rev/f871f8662509.
-rw-r--r--pym/portage/__init__.py18
-rw-r--r--pym/portage/cache/fs_template.py5
-rw-r--r--pym/portage/data.py2
-rw-r--r--pym/portage/locks.py7
-rw-r--r--pym/portage/package/ebuild/doebuild.py6
-rw-r--r--pym/portage/process.py6
-rw-r--r--pym/portage/util/__init__.py4
7 files changed, 22 insertions, 26 deletions
diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py
index 13a34e695..75d0d6437 100644
--- a/pym/portage/__init__.py
+++ b/pym/portage/__init__.py
@@ -279,23 +279,6 @@ class _unicode_func_wrapper(object):
return rval
-class _chown_func_wrapper(_unicode_func_wrapper):
- """
- Compatibility workaround for Python 2.7.3 in Fedora 18, which throws
- "TypeError: group id must be integer" if we try to pass an ObjectProxy
- instance into chown.
- """
-
- def _process_args(self, args, kwargs):
-
- wrapped_args, wrapped_kwargs = \
- _unicode_func_wrapper._process_args(self, args, kwargs)
-
- for i in (1, 2):
- wrapped_args[i] = int(wrapped_args[i])
-
- return (wrapped_args, wrapped_kwargs)
-
class _unicode_module_wrapper(object):
"""
Wraps a module and wraps all functions with _unicode_func_wrapper.
@@ -339,7 +322,6 @@ class _unicode_module_wrapper(object):
import os as _os
_os_overrides = {
- id(_os.chown) : _chown_func_wrapper(_os.chown),
id(_os.fdopen) : _os.fdopen,
id(_os.popen) : _os.popen,
id(_os.read) : _os.read,
diff --git a/pym/portage/cache/fs_template.py b/pym/portage/cache/fs_template.py
index 8f0636ed0..0567c72b9 100644
--- a/pym/portage/cache/fs_template.py
+++ b/pym/portage/cache/fs_template.py
@@ -1,4 +1,4 @@
-# Copyright 2005-2012 Gentoo Foundation
+# Copyright 2005-2013 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# Author(s): Brian Harring (ferringb@gentoo.org)
@@ -25,7 +25,8 @@ class FsBased(template.database):
for x, y in (("gid", -1), ("perms", -1)):
if x in config:
- setattr(self, "_"+x, config[x])
+ # Since Python 3.4, chown requires int type (no proxies).
+ setattr(self, "_" + x, int(config[x]))
del config[x]
else:
setattr(self, "_"+x, y)
diff --git a/pym/portage/data.py b/pym/portage/data.py
index caf4752ac..44104c273 100644
--- a/pym/portage/data.py
+++ b/pym/portage/data.py
@@ -32,7 +32,7 @@ if not lchown:
" exist. Please rebuild python.\n"), noiselevel=-1)
lchown()
-lchown = portage._chown_func_wrapper(lchown)
+lchown = portage._unicode_func_wrapper(lchown)
def portage_group_warning():
warn_prefix = colorize("BAD", "*** WARNING *** ")
diff --git a/pym/portage/locks.py b/pym/portage/locks.py
index 71bce305a..87aaf94a2 100644
--- a/pym/portage/locks.py
+++ b/pym/portage/locks.py
@@ -17,7 +17,6 @@ import portage
from portage import os, _encodings, _unicode_decode
from portage.exception import DirectoryNotFound, FileNotFound, \
InvalidData, TryAgain, OperationNotPermitted, PermissionDenied
-from portage.data import portage_gid
from portage.util import writemsg
from portage.localization import _
@@ -64,6 +63,9 @@ def lockfile(mypath, wantnewlockfile=0, unlinkfile=0,
if not mypath:
raise InvalidData(_("Empty path given"))
+ # Since Python 3.4, chown requires int type (no proxies).
+ portage_gid = int(portage.data.portage_gid)
+
# Support for file object or integer file descriptor parameters is
# deprecated due to ambiguity in whether or not it's safe to close
# the file descriptor, making it prone to "Bad file descriptor" errors
@@ -372,6 +374,9 @@ def hardlink_lockfile(lockfilename, max_wait=DeprecationWarning,
preexisting = os.path.exists(lockfilename)
myhardlock = hardlock_name(lockfilename)
+ # Since Python 3.4, chown requires int type (no proxies).
+ portage_gid = int(portage.data.portage_gid)
+
# myhardlock must not exist prior to our link() call, and we can
# safely unlink it since its file name is unique to our PID
try:
diff --git a/pym/portage/package/ebuild/doebuild.py b/pym/portage/package/ebuild/doebuild.py
index 667280ecd..1cf5dc6ae 100644
--- a/pym/portage/package/ebuild/doebuild.py
+++ b/pym/portage/package/ebuild/doebuild.py
@@ -1459,8 +1459,10 @@ def spawn(mystring, mysettings, debug=0, free=0, droppriv=0, sesandbox=0, fakero
"umask": 0o02
})
if "userpriv" in features and "userpriv" not in mysettings["PORTAGE_RESTRICT"].split() and secpass >= 2:
- portage_build_uid = portage_uid
- portage_build_gid = portage_gid
+ # Since Python 3.4, getpwuid and getgrgid
+ # require int type (no proxies).
+ portage_build_uid = int(portage_uid)
+ portage_build_gid = int(portage_gid)
if "PORTAGE_BUILD_USER" not in mysettings:
user = None
diff --git a/pym/portage/process.py b/pym/portage/process.py
index 92f2aba0c..5f6a172e0 100644
--- a/pym/portage/process.py
+++ b/pym/portage/process.py
@@ -417,11 +417,13 @@ def _exec(binary, mycommand, opt_name, fd_pipes, env, gid, groups, uid, umask,
# Set requested process permissions.
if gid:
- os.setgid(gid)
+ # Cast proxies to int, in case it matters.
+ os.setgid(int(gid))
if groups:
os.setgroups(groups)
if uid:
- os.setuid(uid)
+ # Cast proxies to int, in case it matters.
+ os.setuid(int(uid))
if umask:
os.umask(umask)
if pre_exec:
diff --git a/pym/portage/util/__init__.py b/pym/portage/util/__init__.py
index 546262e68..92a218793 100644
--- a/pym/portage/util/__init__.py
+++ b/pym/portage/util/__init__.py
@@ -1014,6 +1014,10 @@ def apply_permissions(filename, uid=-1, gid=-1, mode=-1, mask=-1,
modified = False
+ # Since Python 3.4, chown requires int type (no proxies).
+ uid = int(uid)
+ gid = int(gid)
+
if stat_cached is None:
try:
if follow_links: