2016-10-01 20:57:09 +02:00
|
|
|
#! /usr/bin/python3
|
2012-05-09 11:33:36 -07:00
|
|
|
# ------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# Copyright (C) 2012 Canonical Ltd.
|
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or
|
|
|
|
# modify it under the terms of version 2 of the GNU General Public
|
|
|
|
# License published by the Free Software Foundation.
|
|
|
|
#
|
|
|
|
# ------------------------------------------------------------------
|
|
|
|
|
|
|
|
import apparmor.sandbox
|
2014-01-17 00:09:23 -08:00
|
|
|
from apparmor.common import error
|
2012-05-10 01:17:56 -07:00
|
|
|
import optparse
|
2012-05-09 11:33:36 -07:00
|
|
|
import sys
|
|
|
|
|
2015-07-06 22:02:34 +02:00
|
|
|
# setup exception handling
|
|
|
|
from apparmor.fail import enable_aa_exception_handler
|
|
|
|
enable_aa_exception_handler()
|
|
|
|
|
2012-05-09 11:33:36 -07:00
|
|
|
if __name__ == "__main__":
|
|
|
|
argv = sys.argv
|
2012-05-10 01:17:56 -07:00
|
|
|
parser = optparse.OptionParser()
|
|
|
|
apparmor.easyprof.add_parser_policy_args(parser)
|
|
|
|
(opt, args) = apparmor.sandbox.parse_args(sys.argv, parser)
|
2012-05-09 11:33:36 -07:00
|
|
|
|
|
|
|
if len(args) < 1:
|
|
|
|
error("Must specify binary")
|
|
|
|
|
2012-05-10 01:17:56 -07:00
|
|
|
binary = args[0]
|
|
|
|
if not apparmor.sandbox.check_requirements(binary):
|
2012-05-09 11:33:36 -07:00
|
|
|
sys.exit(1)
|
|
|
|
|
|
|
|
if opt.withx:
|
2012-05-10 01:17:56 -07:00
|
|
|
rc, report = apparmor.sandbox.run_xsandbox(args, opt)
|
2012-05-09 11:33:36 -07:00
|
|
|
else:
|
2012-05-10 01:17:56 -07:00
|
|
|
rc, report = apparmor.sandbox.run_sandbox(args, opt)
|
|
|
|
|
2012-08-23 17:12:14 -05:00
|
|
|
apparmor.common.msg(report)
|
2012-05-10 01:17:56 -07:00
|
|
|
sys.exit(rc)
|