/usr/bin/aa-clickquery is in click-apparmor 0.2.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 | #!/usr/bin/python3
# ------------------------------------------------------------------
#
# Copyright (C) 2014 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.
#
# ------------------------------------------------------------------
from apparmor import click
import optparse
import sys
def error(out, exit_code=1, do_exit=True):
'''Print error message and exit'''
try:
sys.stderr.write("ERROR: %s\n" % (out))
except IOError:
pass
if do_exit:
sys.exit(exit_code)
def warn(out):
'''Print warning message'''
try:
sys.stderr.write("WARN: %s\n" % (out))
except IOError:
pass
def msg(out):
'''Print message'''
try:
sys.stdout.write("%s\n" % (out))
except IOError:
pass
def main():
parser = optparse.OptionParser()
parser.add_option("-q", "--query",
dest='query',
help="Query for given framework. Specify 'help' " +
"for more information",
metavar="QUERY",
default=None)
parser.add_option("--click-framework",
dest='click_framework',
help='Specify click framework to query',
metavar="CLICKFRAMEWORK",
default=None)
(opt, args) = parser.parse_args()
if not len(args) == 0:
sys.exit(1)
rc = 0
if opt.query == "help":
m = '''Valid query strings:
policy_version
'''
elif opt.query is None or opt.click_framework is None:
error("Not enough arguments")
elif opt.query == "policy_version":
try:
v = click.get_policy_version_for_framework(
opt.click_framework)
except click.AppArmorException:
error("Could not determine policy version for '%s'" %
opt.click_framework)
m = "%s" % str(v)
else:
error("Invalid query '%s'" % opt.query)
msg(m)
return rc
if __name__ == "__main__":
sys.exit(main())
|