Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
nemu3
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
nemu3
Commits
83e3de74
Commit
83e3de74
authored
Oct 18, 2010
by
Alina Quereilhac
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Attemp to connect to main namespace xserver from a child namespace: minor changes.
parent
936dcd46
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
11 deletions
+17
-11
src/netns/protocol.py
src/netns/protocol.py
+4
-3
src/netns/subprocess_.py
src/netns/subprocess_.py
+11
-6
test/test_x11.py
test/test_x11.py
+2
-2
No files found.
src/netns/protocol.py
View file @
83e3de74
...
@@ -506,14 +506,14 @@ class Client(object):
...
@@ -506,14 +506,14 @@ class Client(object):
except
:
except
:
return
None
return
None
def
_send_x11_fd
(
self
):
def
_send_x11_fd
(
self
):
fd
=
self
.
_create_x_socket
()
fd
=
self
.
_create_x_socket
()
if
fd
is
not
None
:
if
fd
is
not
None
:
self
.
_send_fd
(
'X11'
,
fd
.
fileno
())
self
.
_send_fd
(
'X11'
,
fd
.
fileno
())
def
spawn
(
self
,
argv
,
executable
=
None
,
def
spawn
(
self
,
argv
,
executable
=
None
,
stdin
=
None
,
stdout
=
None
,
stderr
=
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
"""Start a subprocess in the slave; the interface resembles
subprocess.Popen, but with less functionality. In particular
subprocess.Popen, but with less functionality. In particular
stdin/stdout/stderr can only be None or a open file descriptor.
stdin/stdout/stderr can only be None or a open file descriptor.
...
@@ -552,6 +552,7 @@ class Client(object):
...
@@ -552,6 +552,7 @@ class Client(object):
if
stderr
!=
None
:
if
stderr
!=
None
:
self
.
_send_fd
(
"SERR"
,
stderr
)
self
.
_send_fd
(
"SERR"
,
stderr
)
if
X
==
True
:
self
.
_send_x11_fd
()
self
.
_send_x11_fd
()
except
:
except
:
self
.
_send_cmd
(
"PROC"
,
"ABRT"
)
self
.
_send_cmd
(
"PROC"
,
"ABRT"
)
...
...
src/netns/subprocess_.py
View file @
83e3de74
...
@@ -18,7 +18,7 @@ class Subprocess(object):
...
@@ -18,7 +18,7 @@ class Subprocess(object):
default_user
=
None
default_user
=
None
def
__init__
(
self
,
node
,
argv
,
executable
=
None
,
def
__init__
(
self
,
node
,
argv
,
executable
=
None
,
stdin
=
None
,
stdout
=
None
,
stderr
=
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
self
.
_slave
=
node
.
_slave
"""Forks and execs a program, with stdio redirection and user
"""Forks and execs a program, with stdio redirection and user
switching.
switching.
...
@@ -33,6 +33,8 @@ class Subprocess(object):
...
@@ -33,6 +33,8 @@ class Subprocess(object):
numerical UID is given, a reverse lookup is performed to find the user
numerical UID is given, a reverse lookup is performed to find the user
name and then set correctly the groups.
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
To run the program in a different directory than the current one, it
should be set in `cwd'.
should be set in `cwd'.
...
@@ -64,7 +66,7 @@ class Subprocess(object):
...
@@ -64,7 +66,7 @@ class Subprocess(object):
# happens in another process!
# happens in another process!
self
.
_pid
=
self
.
_slave
.
spawn
(
argv
,
executable
=
executable
,
self
.
_pid
=
self
.
_slave
.
spawn
(
argv
,
executable
=
executable
,
stdin
=
stdin
,
stdout
=
stdout
,
stderr
=
stderr
,
stdin
=
stdin
,
stdout
=
stdout
,
stderr
=
stderr
,
cwd
=
cwd
,
env
=
env
,
user
=
user
)
cwd
=
cwd
,
env
=
env
,
user
=
user
,
X
=
X
)
node
.
_add_subprocess
(
self
)
node
.
_add_subprocess
(
self
)
...
@@ -130,7 +132,7 @@ class Popen(Subprocess):
...
@@ -130,7 +132,7 @@ class Popen(Subprocess):
def
__init__
(
self
,
node
,
argv
,
executable
=
None
,
def
__init__
(
self
,
node
,
argv
,
executable
=
None
,
stdin
=
None
,
stdout
=
None
,
stderr
=
None
,
bufsize
=
0
,
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.
"""As in Subprocess, `node' specifies the netns Node to run in.
The `stdin', `stdout', and `stderr' parameters also accept the special
The `stdin', `stdout', and `stderr' parameters also accept the special
...
@@ -164,7 +166,7 @@ class Popen(Subprocess):
...
@@ -164,7 +166,7 @@ class Popen(Subprocess):
super
(
Popen
,
self
).
__init__
(
node
,
argv
,
executable
=
executable
,
super
(
Popen
,
self
).
__init__
(
node
,
argv
,
executable
=
executable
,
stdin
=
fdmap
[
'stdin'
],
stdout
=
fdmap
[
'stdout'
],
stdin
=
fdmap
[
'stdin'
],
stdout
=
fdmap
[
'stdout'
],
stderr
=
fdmap
[
'stderr'
],
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
# Close pipes, they have been dup()ed to the child
for
k
,
v
in
fdmap
.
items
():
for
k
,
v
in
fdmap
.
items
():
...
@@ -303,6 +305,9 @@ def spawn(executable, argv = None, cwd = None, env = None, close_fds = False,
...
@@ -303,6 +305,9 @@ def spawn(executable, argv = None, cwd = None, env = None, close_fds = False,
if
env
is
None
:
if
env
is
None
:
env
=
{}
env
=
{}
env
[
'DISPLAY'
]
=
'unix:0'
env
[
'DISPLAY'
]
=
'unix:0'
if
'NETNS_LD_PRELOAD'
in
os
.
environ
:
env
[
'LD_PRELOAD'
]
=
os
.
environ
[
'NETNS_LD_PRELOAD'
]
else
:
env
[
'LD_PRELOAD'
]
=
'src/lib/libconnectwrapper.so'
env
[
'LD_PRELOAD'
]
=
'src/lib/libconnectwrapper.so'
env
[
'NETNS_X11_FD'
]
=
str
(
x11
)
env
[
'NETNS_X11_FD'
]
=
str
(
x11
)
...
...
test/test_x11.py
View file @
83e3de74
...
@@ -3,10 +3,10 @@
...
@@ -3,10 +3,10 @@
import
netns
import
netns
import
os
import
os
netns
.
environ
.
set_log_level
(
netns
.
environ
.
LOG_DEBUG
)
#
netns.environ.set_log_level(netns.environ.LOG_DEBUG)
n
=
netns
.
Node
()
n
=
netns
.
Node
()
err
=
file
(
'/tmp/out_y'
,
'wb'
)
err
=
file
(
'/tmp/out_y'
,
'wb'
)
a
=
n
.
Popen
([
'xterm'
],
stderr
=
err
)
a
=
n
.
Popen
([
'xterm'
],
stderr
=
err
,
X
=
True
)
a
.
wait
()
a
.
wait
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment