[apparmor] [patch 09/11] utils: split out aa-genprof command
Steve Beattie
steve at nxnw.org
Thu Mar 6 01:44:43 UTC 2014
This patch splits out the genprof tool functionality into a separate
command function, merging with the use_autodep function that already
existed.
Signed-off-by: Steve Beattie <steve at nxnw.org>
---
utils/aa-autodep | 4 ++--
utils/apparmor/tools.py | 32 ++++++++++++++++++--------------
2 files changed, 20 insertions(+), 16 deletions(-)
Index: b/utils/aa-autodep
===================================================================
--- a/utils/aa-autodep
+++ b/utils/aa-autodep
@@ -26,6 +26,6 @@ parser.add_argument('-d', '--dir', type=
parser.add_argument('program', type=str, nargs='+', help=_('name of program'))
args = parser.parse_args()
-autodep = apparmor.tools.aa_tools('autodep', args)
+tool = apparmor.tools.aa_tools('autodep', args)
-autodep.act()
+tool.cmd_autodep()
Index: b/utils/apparmor/tools.py
===================================================================
--- a/utils/apparmor/tools.py
+++ b/utils/apparmor/tools.py
@@ -102,10 +102,7 @@ class aa_tools:
aaui.UI_Info(_("%s does not exist, please double-check the path.") % program)
sys.exit(1)
- if self.name == 'autodep' and program and os.path.exists(program):
- self.use_autodep(program)
-
- elif program and apparmor.profile_exists(program):
+ if program and apparmor.profile_exists(program):
if self.name == 'cleanprof':
self.clean_profile(program)
@@ -209,6 +206,23 @@ class aa_tools:
if cmd_info[0] != 0:
raise apparmor.AppArmorException(cmd_info[1])
+ def cmd_autodep(self):
+ for (program, profile) in self.get_next_to_profile():
+ if not program:
+ aaui.UI_Info('Profile %s already exists - skipping.' % profile)
+ continue
+
+ apparmor.read_profiles()
+
+ apparmor.check_qualifiers(program)
+
+ if os.path.exists(apparmor.get_profile_filename(program)) and not self.force:
+ aaui.UI_Info('Profile for %s already exists - skipping.' % program)
+ else:
+ apparmor.autodep(program)
+ if self.aa_mountpoint:
+ apparmor.reload(program)
+
def clean_profile(self, program):
filename = apparmor.get_profile_filename(program)
import apparmor.cleanprofile as cleanprofile
@@ -245,16 +259,6 @@ class aa_tools:
else:
raise apparmor.AppArmorException(_('The profile for %s does not exists. Nothing to clean.') % program)
- def use_autodep(self, program):
- apparmor.check_qualifiers(program)
-
- if os.path.exists(apparmor.get_profile_filename(program)) and not self.force:
- aaui.UI_Info('Profile for %s already exists - skipping.' % program)
- else:
- apparmor.autodep(program)
- if self.aa_mountpoint:
- apparmor.reload(program)
-
def enable_profile(self, filename):
apparmor.delete_symlink('disable', filename)
More information about the AppArmor
mailing list