[apparmor] [patch 09/11] utils: split out aa-genprof command
Seth Arnold
seth.arnold at canonical.com
Thu Mar 6 07:26:58 UTC 2014
On Wed, Mar 05, 2014 at 05:44:43PM -0800, Steve Beattie wrote:
> 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>
Acked-by: Seth Arnold <seth.arnold at canonical.com>
Note that the new strings in UI_Info() aren't marked for localization.
Thanks
> ---
> 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)
>
>
>
> --
> AppArmor mailing list
> AppArmor at lists.ubuntu.com
> Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/apparmor
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 490 bytes
Desc: Digital signature
URL: <https://lists.ubuntu.com/archives/apparmor/attachments/20140305/569999a9/attachment.pgp>
More information about the AppArmor
mailing list