|
|
@ -4,6 +4,7 @@ starting new contexts via SSH. Its size is also restricted, since it must be
|
|
|
|
sent to any context that will be used to establish additional child contexts.
|
|
|
|
sent to any context that will be used to establish additional child contexts.
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import commands
|
|
|
|
import errno
|
|
|
|
import errno
|
|
|
|
import getpass
|
|
|
|
import getpass
|
|
|
|
import imp
|
|
|
|
import imp
|
|
|
@ -55,6 +56,15 @@ def get_child_modules(path, fullname):
|
|
|
|
return ['%s.%s' % (fullname, name) for _, name, _ in it]
|
|
|
|
return ['%s.%s' % (fullname, name) for _, name, _ in it]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def format_cmdline(args):
|
|
|
|
|
|
|
|
return ' '.join(
|
|
|
|
|
|
|
|
commands.mkarg(arg).strip()
|
|
|
|
|
|
|
|
if any(s in arg for s in (" '\"$")) else
|
|
|
|
|
|
|
|
arg
|
|
|
|
|
|
|
|
for arg in args
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def create_child(*args):
|
|
|
|
def create_child(*args):
|
|
|
|
"""Create a child process whose stdin/stdout is connected to a socket,
|
|
|
|
"""Create a child process whose stdin/stdout is connected to a socket,
|
|
|
|
returning `(pid, socket_obj)`."""
|
|
|
|
returning `(pid, socket_obj)`."""
|
|
|
@ -69,8 +79,8 @@ def create_child(*args):
|
|
|
|
raise SystemExit
|
|
|
|
raise SystemExit
|
|
|
|
|
|
|
|
|
|
|
|
childfp.close()
|
|
|
|
childfp.close()
|
|
|
|
LOG.debug('create_child() child %d fd %d, parent %d, args %r',
|
|
|
|
LOG.debug('create_child() child %d fd %d, parent %d, cmd: %s',
|
|
|
|
pid, parentfp.fileno(), os.getpid(), args)
|
|
|
|
pid, parentfp.fileno(), os.getpid(), format_cmdline(args))
|
|
|
|
return pid, os.dup(parentfp.fileno())
|
|
|
|
return pid, os.dup(parentfp.fileno())
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -141,8 +151,8 @@ def tty_create_child(*args):
|
|
|
|
raise SystemExit
|
|
|
|
raise SystemExit
|
|
|
|
|
|
|
|
|
|
|
|
os.close(slave_fd)
|
|
|
|
os.close(slave_fd)
|
|
|
|
LOG.debug('tty_create_child() child %d fd %d, parent %d, args %r',
|
|
|
|
LOG.debug('tty_create_child() child %d fd %d, parent %d, cmd: %s',
|
|
|
|
pid, master_fd, os.getpid(), args)
|
|
|
|
pid, master_fd, os.getpid(), format_cmdline(args))
|
|
|
|
return pid, master_fd
|
|
|
|
return pid, master_fd
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|