def chainload(target_dir): """Load and execute the selected version of an application. This function replaces the currently-running executable with the equivalent executable from the given target directory. On platforms that support it, this also locks the target directory so that it will not be removed by any simultaneously-running instances of the application. """ try: lock_version_dir(target_dir) except EnvironmentError: # If the bootstrap file is missing, the version is being uninstalled. # Our only option is to re-execute ourself and find the new version. if exists(dirname(target_dir)): bsfile = pathjoin(target_dir, ESKY_CONTROL_DIR) bsfile = pathjoin(bsfile, "bootstrap-manifest.txt") if not exists(bsfile): execv(sys.executable, list(sys.argv)) return raise else: # If all goes well, we can actually launch the target version. _chainload(target_dir)
def execute_command(): pipe_fd = posix.pipe() pid = posix.fork() if pid == 0: cmdline = ["lsblk"] if check_fs_val.get() or check_UUID_val.get(): cmdline.append("-o") col = "+" if check_fs_val.get(): col += "fstype" if check_fs_val.get() and check_UUID_val.get(): col += "," if check_UUID_val.get(): col += "UUID" cmdline.append(col) posix.dup2(pipe_fd[1], 1) posix.close(pipe_fd[0]) posix.close(pipe_fd[1]) posix.execv("/bin/lsblk", cmdline) quit() else: posix.close(pipe_fd[1]) ret = bytearray() readbytes = posix.read(pipe_fd[0], 1000) while readbytes != b"": ret += readbytes readbytes = posix.read(pipe_fd[0], 1000) posix.close(pipe_fd[0]) posix.wait() return str(ret, sys.stdout.encoding)
def chainload(target_dir): """Load and execute the selected version of an application. This function replaces the currently-running executable with the equivalent executable from the given target directory. On platforms that support it, this also locks the target directory so that it will not be removed by any simultaneously-running instances of the application. """ try: lock_version_dir(target_dir) except EnvironmentError: # If the bootstrap file is missing, the version is being uninstalled. # Our only option is to re-execute ourself and find the new version. if exists(dirname(target_dir)): bsfile = pathjoin(target_dir,ESKY_CONTROL_DIR) bsfile = pathjoin(bsfile,"bootstrap-manifest.txt") if not exists(bsfile): execv(sys.executable,list(sys.argv)) return raise else: # If all goes well, we can actually launch the target version. _chainload(target_dir)
def _chainload(target_dir): """Default implementation of the chainload() function. Specific freezer modules may provide a more efficient, reliable or otherwise better version of this function. """ exc_type,exc_value,traceback = None,None,None for target_exe in get_exe_locations(target_dir): try: execv(target_exe,[target_exe] + sys.argv[1:]) except EnvironmentError: exc_type,exc_value,traceback = sys.exc_info() if exc_value.errno != errno.ENOENT: raise else: if exc_value is not None: raise exc_type,exc_value,traceback
def _chainload(target_dir): """Default implementation of the chainload() function. Specific freezer modules may provide a more efficient, reliable or otherwise better version of this function. """ exc_type, exc_value, traceback = None, None, None for target_exe in get_exe_locations(target_dir): verify(target_exe) try: execv(target_exe, [target_exe] + sys.argv[1:]) return except EnvironmentError, exc_value: # Careful, RPython lacks a usable exc_info() function. exc_type, _, traceback = sys.exc_info() if not __rpython__: if exc_value.errno != errno.ENOENT: raise else: if exists(target_exe): raise
def _chainload(target_dir): """Default implementation of the chainload() function. Specific freezer modules may provide a more efficient, reliable or otherwise better version of this function. """ exc_type,exc_value,traceback = None,None,None for target_exe in get_exe_locations(target_dir): verify(target_exe) try: execv(target_exe,[target_exe] + sys.argv[1:]) return except EnvironmentError, exc_value: # Careful, RPython lacks a usable exc_info() function. exc_type,_,traceback = sys.exc_info() if not __rpython__: if exc_value.errno != errno.ENOENT: raise else: if exists(target_exe): raise
import posix posix.execv('/bin/cat', ['/bin/cat', __file__])
maxMinorVersion = -1 cellAppMgrBinaryPath = None for binaryPath in binaryPaths: matches = re.search("\.([0-9]+)$", binaryPath) if not matches: continue try: minorVersion = int(matches.groups()[0]) if minorVersion > maxMinorVersion: maxMinorVersion = minorVersion cellAppMgrBinaryPath = binaryPath except ValueError: continue if cellAppMgrBinaryPath is None: syslog.syslog("Could not find binary for version %d" % versionNumber) sys.exit(1) syslog.syslog("Binary chosen: %s" % cellAppMgrBinaryPath) posix.execv( cellAppMgrBinaryPath, args + [ "-remoteService", "%d:%d:%d:%d" % (fd, remoteUID, remotePID, remoteViewerPort), syslogPrefix ]) main() # End of file
import posix import sys from ck.clickhouse import lookup posix.execv(lookup.binary_file(), sys.argv)
hostname = "" elif re.match("^.*\.(edu|com|org)$", host): hostname = host else: hostname = "" good_port(); arguments = [sys.argv[0]] if hostname != "": arguments.append("-h") arguments.append(hostname) for arg in sys.argv[1:]: arguments.append(arg) posix.execv(execprg, arguments) print text sys.exit() # General proxy request m = re.match("^GET\s+http://(?P<host>[^/ ]*)(?P<uri>/?[^ ]*)\s+HTTP", g, re.IGNORECASE) if m: host = m.group('host') uri = m.group('uri') if uri == "": uri = "/" if is_ipaddr(host): eat_input() time.sleep(10)
hostname = "" elif re.match("^.*\.(edu|com|org)$", host): hostname = host else: hostname = "" good_port() arguments = [sys.argv[0]] if hostname != "": arguments.append("-h") arguments.append(hostname) for arg in sys.argv[1:]: arguments.append(arg) posix.execv(execprg, arguments) print text sys.exit() # General proxy request m = re.match("^GET\s+http://(?P<host>[^/ ]*)(?P<uri>/?[^ ]*)\s+HTTP", g, re.IGNORECASE) if m: host = m.group('host') uri = m.group('uri') if uri == "": uri = "/" if is_ipaddr(host): eat_input() time.sleep(10)