mirror of
https://gitlab.com/apparmor/apparmor.git
synced 2025-03-04 08:24:42 +01:00

logprof/genprof and related utilities in python. Because the branch that was worked on was not based on the apparmor tree, not all of the history can be maintained for files that are not newly created or entirely rewritten in the branch. (This merge also includes a subsequent commit to the branch I was merging from which includes my missed bzr add of utils/apparmor/translations.py)
40 lines
1.4 KiB
Python
40 lines
1.4 KiB
Python
#!/usr/bin/python
|
|
# ----------------------------------------------------------------------
|
|
# Copyright (C) 2013 Kshitij Gupta <kgupta8592@gmail.com>
|
|
#
|
|
# 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 as published by the Free Software Foundation.
|
|
#
|
|
# This program is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU General Public License for more details.
|
|
#
|
|
# ----------------------------------------------------------------------
|
|
import argparse
|
|
import traceback
|
|
|
|
import apparmor.tools
|
|
|
|
# setup module translations
|
|
from apparmor.translations import init_translation
|
|
_ = init_translation()
|
|
|
|
parser = argparse.ArgumentParser(description=_('Switch the given programs to audit mode'))
|
|
parser.add_argument('-d', '--dir', type=str, help=_('path to profiles'))
|
|
parser.add_argument('-r', '--remove', action='store_true', help=_('remove audit mode'))
|
|
parser.add_argument('program', type=str, nargs='+', help=_('name of program'))
|
|
parser.add_argument('--trace', action='store_true', help=_('Show full trace'))
|
|
args = parser.parse_args()
|
|
|
|
try:
|
|
audit = apparmor.tools.aa_tools('audit', args)
|
|
|
|
audit.act()
|
|
except Exception as e:
|
|
if not args.trace:
|
|
print(e.value + "\n")
|
|
|
|
else:
|
|
traceback.print_exc()
|