[apparmor] [patch] utils/easyprof: fix regression test when apparmor-easyprof is not installed

Tyler Hicks tyhicks at canonical.com
Thu Mar 20 00:35:58 UTC 2014


On 2014-03-19 16:58:02, Steve Beattie wrote:
> Bug: https://bugs.launchpad.net/bugs/1294848
> 
> This patch fixes the testsuite for aa-easyprof when the easyprof
> utilities and configuration files are not installed in the system. What
> was happening was that verify_manifest was calling parse_args()
> without the synthetic arguments created by the test case and passing
> the result to AppArmorEasyProfile(). Because parse_args() didn't have
> the synthetic arguments, it would parse the actual command line
> arguments passed to the testscript, which of course didn't specify the
> alternate configuration file location. This would work when easyprof had
> been installed in the system, because the fallback configuration file in
> /etc/apparmor/easyprof.conf would exist and specify template and policy
> group locations. Without that, though, the tests would abort due to not
> knowing the location of the templates and policy groups.
> 
> This patch fixes the issue by passing the synthetic argument list to
> verify_manifest, which uses that when calling parse_args(). A debugging
> statement that states which conffile is being used when
> AppArmorEasyProfile is being instantiated.
> 
> Signed-off-by: Steve Beattie <steve at nxnw.org>

Acked-by: Tyler Hicks <tyhicks at canonical.com>

Thanks!

FWIW, I noticed that the utils/ tests also incorrectly rely
on /etc/apparmor/logprof.conf and /etc/apparmor/severity.db existing. I
haven't had a chance to look into it.

Tyler

> ---
>  utils/apparmor/easyprof.py     |    5 +++--
>  utils/test/test-aa-easyprof.py |    4 ++--
>  2 files changed, 5 insertions(+), 4 deletions(-)
> 
> Index: b/utils/apparmor/easyprof.py
> ===================================================================
> --- a/utils/apparmor/easyprof.py
> +++ b/utils/apparmor/easyprof.py
> @@ -296,6 +296,7 @@ class AppArmorEasyProfile:
>          verify_options(opt)
>          opt.ensure_value("conffile", "/etc/apparmor/easyprof.conf")
>          self.conffile = os.path.abspath(opt.conffile)
> +        debug("Examining confile=%s" % (self.conffile))
>  
>          self.dirs = dict()
>          if os.path.isfile(self.conffile):
> @@ -1085,10 +1086,10 @@ def verify_options(opt, strict=False):
>                  raise AppArmorException("Invalid write path '%s'" % i)
>  
>  
> -def verify_manifest(params):
> +def verify_manifest(params, args=None):
>      '''Verify manifest for safe and unsafe options'''
>      err_str = ""
> -    (opt, args) = parse_args()
> +    (opt, args) = parse_args(args)
>      fake_easyp = AppArmorEasyProfile(None, opt)
>  
>      unsafe_keys = ['read_path', 'write_path']
> Index: b/utils/test/test-aa-easyprof.py
> ===================================================================
> --- a/utils/test/test-aa-easyprof.py
> +++ b/utils/test/test-aa-easyprof.py
> @@ -1644,9 +1644,9 @@ POLICYGROUPS_DIR="%s/templates"
>              raise
>          params = easyprof.gen_policy_params(binary, options)
>          if expected:
> -            self.assertTrue(easyprof.verify_manifest(params), "params=%s\nmanifest=%s" % (params,m))
> +            self.assertTrue(easyprof.verify_manifest(params, args), "params=%s\nmanifest=%s" % (params,m))
>          else:
> -            self.assertFalse(easyprof.verify_manifest(params), "params=%s\nmanifest=%s" % (params,m))
> +            self.assertFalse(easyprof.verify_manifest(params, args), "params=%s\nmanifest=%s" % (params,m))
>  
>      def test_verify_manifest_full(self):
>          '''Test verify_manifest (full)'''
> -- 
> Steve Beattie
> <sbeattie at ubuntu.com>
> http://NxNW.org/~steve/



> -- 
> 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: 819 bytes
Desc: Digital signature
URL: <https://lists.ubuntu.com/archives/apparmor/attachments/20140319/c1413550/attachment.pgp>


More information about the AppArmor mailing list