Commit 83e3de74 authored by Alina Quereilhac's avatar Alina Quereilhac

Attemp to connect to main namespace xserver from a child namespace: minor changes.

parent 936dcd46
......@@ -505,15 +505,15 @@ class Client(object):
return fd
except:
return None
def _send_x11_fd(self):
fd = self._create_x_socket()
if fd is not None:
self._send_fd('X11', fd.fileno())
def spawn(self, argv, executable = None,
stdin = None, stdout = None, stderr = None,
cwd = None, env = None, user = None):
cwd = None, env = None, user = None, X = False):
"""Start a subprocess in the slave; the interface resembles
subprocess.Popen, but with less functionality. In particular
stdin/stdout/stderr can only be None or a open file descriptor.
......@@ -552,7 +552,8 @@ class Client(object):
if stderr != None:
self._send_fd("SERR", stderr)
self._send_x11_fd()
if X == True:
self._send_x11_fd()
except:
self._send_cmd("PROC", "ABRT")
self._read_and_check_reply()
......
......@@ -18,7 +18,7 @@ class Subprocess(object):
default_user = None
def __init__(self, node, argv, executable = None,
stdin = None, stdout = None, stderr = None,
shell = False, cwd = None, env = None, user = None):
shell = False, cwd = None, env = None, user = None, X = False):
self._slave = node._slave
"""Forks and execs a program, with stdio redirection and user
switching.
......@@ -33,6 +33,8 @@ class Subprocess(object):
numerical UID is given, a reverse lookup is performed to find the user
name and then set correctly the groups.
The `X` parameter indicates if the subprocess will use the x11 server
To run the program in a different directory than the current one, it
should be set in `cwd'.
......@@ -64,7 +66,7 @@ class Subprocess(object):
# happens in another process!
self._pid = self._slave.spawn(argv, executable = executable,
stdin = stdin, stdout = stdout, stderr = stderr,
cwd = cwd, env = env, user = user)
cwd = cwd, env = env, user = user, X=X)
node._add_subprocess(self)
......@@ -130,7 +132,7 @@ class Popen(Subprocess):
def __init__(self, node, argv, executable = None,
stdin = None, stdout = None, stderr = None, bufsize = 0,
shell = False, cwd = None, env = None, user = None):
shell = False, cwd = None, env = None, user = None, X = False):
"""As in Subprocess, `node' specifies the netns Node to run in.
The `stdin', `stdout', and `stderr' parameters also accept the special
......@@ -164,7 +166,7 @@ class Popen(Subprocess):
super(Popen, self).__init__(node, argv, executable = executable,
stdin = fdmap['stdin'], stdout = fdmap['stdout'],
stderr = fdmap['stderr'],
shell = shell, cwd = cwd, env = env, user = user)
shell = shell, cwd = cwd, env = env, user = user, X = X)
# Close pipes, they have been dup()ed to the child
for k, v in fdmap.items():
......@@ -303,8 +305,11 @@ def spawn(executable, argv = None, cwd = None, env = None, close_fds = False,
if env is None:
env = {}
env['DISPLAY'] = 'unix:0'
env['LD_PRELOAD'] = 'src/lib/libconnectwrapper.so'
env['NETNS_X11_FD'] = str(x11)
if 'NETNS_LD_PRELOAD' in os.environ:
env['LD_PRELOAD'] = os.environ['NETNS_LD_PRELOAD']
else:
env['LD_PRELOAD'] = 'src/lib/libconnectwrapper.so'
env['NETNS_X11_FD'] = str(x11)
try:
# Set up stdio piping
......
......@@ -3,10 +3,10 @@
import netns
import os
netns.environ.set_log_level(netns.environ.LOG_DEBUG)
#netns.environ.set_log_level(netns.environ.LOG_DEBUG)
n = netns.Node()
err = file('/tmp/out_y', 'wb')
a = n.Popen(['xterm'], stderr = err)
a = n.Popen(['xterm'], stderr = err, X = True)
a.wait()
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment