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 <[email protected]> --- 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 <[email protected]> http://NxNW.org/~steve/
signature.asc
Description: Digital signature
-- AppArmor mailing list [email protected] Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/apparmor
