Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/rainbow
diff options
context:
space:
mode:
authorMichael Stone <michael@laptop.org>2009-03-11 04:37:18 (GMT)
committer Michael Stone <michael@laptop.org>2009-03-11 05:05:19 (GMT)
commit21bc400eb8723e489916201f40243cdb3edbb587 (patch)
tree0b32cd726426d4467b40177c47ee19670ab9870f /rainbow
parent9ca6ebd0894f314e314fa5ba72541d6b55834bab (diff)
Create Xephyrs.
Diffstat (limited to 'rainbow')
-rw-r--r--rainbow/rainbow/inject.py30
1 files changed, 28 insertions, 2 deletions
diff --git a/rainbow/rainbow/inject.py b/rainbow/rainbow/inject.py
index c94d2ef..2d15ada 100644
--- a/rainbow/rainbow/inject.py
+++ b/rainbow/rainbow/inject.py
@@ -194,7 +194,9 @@ def check_cwd(uid, gid, cwd):
def check_spool(spool, owner_uid, owner_gid):
make_dirs(spool, 0, 0, 0755)
spool_dirs = ('uid_pool', 'gid_pool', 'uid_to_gid', 'bundle_id_to_gid',
- 'uid_to_instance_dir', 'gid_to_data_dir', 'uid_to_home_dir')
+ 'uid_to_instance_dir', 'gid_to_data_dir', 'uid_to_home_dir',
+ 'xephyr_display_pool', 'uid_to_xephyr_cookie',
+ 'uid_to_xephyr_display', 'uid_to_xephyr_auth')
for frag in spool_dirs:
make_dirs(join(spool, frag), 0, 0, 0755)
ck = Checker(join(spool, frag), owner_uid, owner_gid)
@@ -219,6 +221,28 @@ def configure_groups(groups, gid, pset):
if pset.has_permission("serial"): groups.append(getgrnam("uucp").gr_gid)
return list(set(groups))
+def configure_xephyr(log, spool, owner_gid, uid, env, safe_fds):
+ # XXX: MUST CHECK RETURN VALUES on subprocesses!!!!!
+ # XXX: I shouldn't be running these subprocesses as uid 0.
+ # XXX: Must get env, fds right!!!!
+ cookie = Popen(["mcookie"], stdout=PIPE).communicate()[0]
+ symlink(cookie, join(spool, 'uid_to_xephyr_cookie', str(uid)))
+ display = reserve_elt(join(spool, 'xephyr_display_pool'), 100, 10000, 2, 'displays')
+ symlink(str(display), join(spool, 'uid_to_xephyr_display', str(uid)))
+
+ fd, name = mkstemp(prefix='tmp', dir=join(spool, 'uid_to_xephyr_auth'))
+ os.close(fd)
+ Popen(["xauth", "-f", name], stdin=PIPE).communicate("add :%d . %s\n" % (display, cookie))
+ auth_path = join(spool, 'uid_to_xephyr_auth', str(uid))
+ rename(name, auth_path)
+ chmod(auth_path, 0640)
+ chown(auth_path, 0, owner_gid)
+
+ Popen(["Xephyr", "-screen", "800x600x24", "-auth", auth_path, "-reset", "-terminate", ":%d" % display])
+
+ newenv = {'DISPLAY' : ':%d' % display, 'XAUTHORITY' : auth_path}
+ return newenv
+
def inject(log, spool, env, argv, cwd, pset, safe_fds, owner_uid, owner_gid,
groups, data_id, assistant):
# Note: exceptions are intended to bubble up to the caller and should
@@ -241,7 +265,9 @@ def inject(log, spool, env, argv, cwd, pset, safe_fds, owner_uid, owner_gid,
check_home(uid, gid, home)
groups = configure_groups(groups, gid, pset)
- env_updates = run_assistant(log, assistant, env, owner_uid, owner_gid, uid, groups)
+ env_updates = configure_xephyr(log, spool, owner_gid, uid, env, safe_fds)
+ if env_updates: env.update(env_updates)
+ env_updates = run_assistant(log, assistant, env, owner_uid, owner_gid, uid, groups, safe_fds)
if env_updates: env.update(env_updates)
mount_fsen(log, home)