mirror of
https://gitlab.com/apparmor/apparmor
synced 2025-08-30 13:58:22 +00:00
move X server search code into classes
This commit is contained in:
@@ -20,18 +20,19 @@ import time
|
|||||||
|
|
||||||
def check_requirements(binary):
|
def check_requirements(binary):
|
||||||
'''Verify necessary software is installed'''
|
'''Verify necessary software is installed'''
|
||||||
exes = ['Xephyr',
|
exes = ['xset', # for detecting free X display
|
||||||
'matchbox-window-manager',
|
|
||||||
'xset', # for detecting free X display
|
|
||||||
'aa-easyprof', # for templates
|
'aa-easyprof', # for templates
|
||||||
|
'aa-exec', # for changing profile
|
||||||
'sudo', # eventually get rid of this
|
'sudo', # eventually get rid of this
|
||||||
binary]
|
binary]
|
||||||
|
|
||||||
for e in exes:
|
for e in exes:
|
||||||
debug("Searching for '%s'" % e)
|
debug("Searching for '%s'" % e)
|
||||||
rc, report = cmd(['which', e])
|
rc, report = cmd(['which', e])
|
||||||
if rc != 0:
|
if rc != 0:
|
||||||
error("Could not find '%s'" % e, do_exit=False)
|
error("Could not find '%s'" % e, do_exit=False)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def parse_args(args=None, parser=None):
|
def parse_args(args=None, parser=None):
|
||||||
@@ -65,7 +66,8 @@ def parse_args(args=None, parser=None):
|
|||||||
if my_opt.withx:
|
if my_opt.withx:
|
||||||
if my_opt.xserver.lower() != 'xpra' and \
|
if my_opt.xserver.lower() != 'xpra' and \
|
||||||
my_opt.xserver.lower() != 'xephyr':
|
my_opt.xserver.lower() != 'xephyr':
|
||||||
error("Invalid server '%s'. Use 'xpra' or 'xephyr'")
|
error("Invalid server '%s'. Use 'xpra' or 'xephyr'" % \
|
||||||
|
my_opt.xserver)
|
||||||
my_opt.template = "sandbox-x"
|
my_opt.template = "sandbox-x"
|
||||||
else:
|
else:
|
||||||
my_opt.template = "sandbox"
|
my_opt.template = "sandbox"
|
||||||
@@ -113,7 +115,6 @@ def aa_exec(command, opt):
|
|||||||
def run_sandbox(command, opt):
|
def run_sandbox(command, opt):
|
||||||
'''Run application'''
|
'''Run application'''
|
||||||
# aa-exec
|
# aa-exec
|
||||||
#opt.template = "sandbox-x"
|
|
||||||
rc, report = aa_exec(command, opt)
|
rc, report = aa_exec(command, opt)
|
||||||
return rc, report
|
return rc, report
|
||||||
|
|
||||||
@@ -156,6 +157,12 @@ class SandboxXserver():
|
|||||||
|
|
||||||
class SandboxXephyr(SandboxXserver):
|
class SandboxXephyr(SandboxXserver):
|
||||||
def start(self):
|
def start(self):
|
||||||
|
for e in ['Xephyr', 'matchbox-window-manager']:
|
||||||
|
debug("Searching for '%s'" % e)
|
||||||
|
rc, report = cmd(['which', e])
|
||||||
|
if rc != 0:
|
||||||
|
raise AppArmorException("Could not find '%s'" % e)
|
||||||
|
|
||||||
'''Start a Xephyr server'''
|
'''Start a Xephyr server'''
|
||||||
listener_x = os.fork()
|
listener_x = os.fork()
|
||||||
if listener_x == 0:
|
if listener_x == 0:
|
||||||
@@ -213,6 +220,12 @@ class SandboxXpra(SandboxXserver):
|
|||||||
SandboxXserver.cleanup(self)
|
SandboxXserver.cleanup(self)
|
||||||
|
|
||||||
def start(self):
|
def start(self):
|
||||||
|
for e in ['xpra']:
|
||||||
|
debug("Searching for '%s'" % e)
|
||||||
|
rc, report = cmd(['which', e])
|
||||||
|
if rc != 0:
|
||||||
|
raise AppArmorException("Could not find '%s'" % e)
|
||||||
|
|
||||||
listener_x = os.fork()
|
listener_x = os.fork()
|
||||||
if listener_x == 0:
|
if listener_x == 0:
|
||||||
x_args = ['--no-daemon',
|
x_args = ['--no-daemon',
|
||||||
|
Reference in New Issue
Block a user