mirror of
https://gitlab.com/apparmor/apparmor.git
synced 2025-03-04 16:35:02 +01:00

As discussed a while ago, switch the utils (including their tests) to use python3 by default. While on it, drop usage of "env" to always get the system python3 instead of a random one that happens to live somewhere in $PATH. In practise, this patch doesn't change much - AFAIK openSUSE, Debian and Ubuntu already patch aa-* to use python3. Also add a note to README to officially deprecate Python 2.x. (I won't break Python 2.x support intentionally - unless some future change gives me a very good reason to finally drop Python 2.x support.) Acked-by: Seth Arnold <seth.arnold@canonical.com> (since 2016-08-23, but the commit had to wait for the FileRule series because it touches test-file.py)
40 lines
1.1 KiB
Python
Executable file
40 lines
1.1 KiB
Python
Executable file
#! /usr/bin/python3
|
|
# ------------------------------------------------------------------
|
|
#
|
|
# 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
|
|
from apparmor.common import error
|
|
import optparse
|
|
import sys
|
|
|
|
# setup exception handling
|
|
from apparmor.fail import enable_aa_exception_handler
|
|
enable_aa_exception_handler()
|
|
|
|
if __name__ == "__main__":
|
|
argv = sys.argv
|
|
parser = optparse.OptionParser()
|
|
apparmor.easyprof.add_parser_policy_args(parser)
|
|
(opt, args) = apparmor.sandbox.parse_args(sys.argv, parser)
|
|
|
|
if len(args) < 1:
|
|
error("Must specify binary")
|
|
|
|
binary = args[0]
|
|
if not apparmor.sandbox.check_requirements(binary):
|
|
sys.exit(1)
|
|
|
|
if opt.withx:
|
|
rc, report = apparmor.sandbox.run_xsandbox(args, opt)
|
|
else:
|
|
rc, report = apparmor.sandbox.run_sandbox(args, opt)
|
|
|
|
apparmor.common.msg(report)
|
|
sys.exit(rc)
|