summaryrefslogtreecommitdiffstats
path: root/pym/portage/process.py
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2010-10-22 03:09:55 -0700
committerZac Medico <zmedico@gentoo.org>2010-10-22 03:09:55 -0700
commit292a277974fe1223bfa956243ac1a2bde1e20c42 (patch)
tree0c79b154a176a1aee8928e6702fc43b34a7e1b44 /pym/portage/process.py
parent1f001546a5ebd6fec50ce2d3ff07eace373acbf9 (diff)
downloadportage-292a277974fe1223bfa956243ac1a2bde1e20c42.tar.gz
portage-292a277974fe1223bfa956243ac1a2bde1e20c42.tar.bz2
portage-292a277974fe1223bfa956243ac1a2bde1e20c42.zip
EbuildFetcher: close uneeded fds in subprocess
Diffstat (limited to 'pym/portage/process.py')
-rw-r--r--pym/portage/process.py35
1 files changed, 19 insertions, 16 deletions
diff --git a/pym/portage/process.py b/pym/portage/process.py
index 37b482a0e..e4d1d9523 100644
--- a/pym/portage/process.py
+++ b/pym/portage/process.py
@@ -352,7 +352,25 @@ def _exec(binary, mycommand, opt_name, fd_pipes, env, gid, groups, uid, umask,
# Quiet killing of subprocesses by SIGPIPE (see bug #309001).
signal.signal(signal.SIGPIPE, signal.SIG_DFL)
- # Set up the command's pipes.
+ _setup_pipes(fd_pipes)
+
+ # Set requested process permissions.
+ if gid:
+ os.setgid(gid)
+ if groups:
+ os.setgroups(groups)
+ if uid:
+ os.setuid(uid)
+ if umask:
+ os.umask(umask)
+ if pre_exec:
+ pre_exec()
+
+ # And switch to the new process.
+ os.execve(binary, myargs, env)
+
+def _setup_pipes(fd_pipes):
+ """Setup pipes for a forked process."""
my_fds = {}
# To protect from cases where direct assignment could
# clobber needed fds ({1:2, 2:1}) we first dupe the fds
@@ -371,21 +389,6 @@ def _exec(binary, mycommand, opt_name, fd_pipes, env, gid, groups, uid, umask,
except OSError:
pass
- # Set requested process permissions.
- if gid:
- os.setgid(gid)
- if groups:
- os.setgroups(groups)
- if uid:
- os.setuid(uid)
- if umask:
- os.umask(umask)
- if pre_exec:
- pre_exec()
-
- # And switch to the new process.
- os.execve(binary, myargs, env)
-
def find_binary(binary):
"""
Given a binary name, find the binary in PATH