[apparmor] test-aa-easyprof.py fails because of UsrMove
Christian Boltz
apparmor at cboltz.de
Wed Mar 5 21:08:52 UTC 2014
Hello,
Am Mittwoch, 5. März 2014 schrieb Steve Beattie:
> On Wed, Mar 05, 2014 at 09:27:29PM +0100, Christian Boltz wrote:
> > I finally applied Steve's small change to preserve the tempdirs (and
> > another one to tell me the used tempdir - BTW: is there a "clean"
> > way to do this? I had to abuse a "self.assertTrue(0 == 1, "tempdir
> > %s" % self.tempdir)" because a simple "print" didn't produce any
> > screen output.
>
> Really? I get... voluminous output from the script, including the
> temporary directories, with either python or python3.
Hmm, I'd have to check again, but I'm quite sure I didn't see the print
output.
> > Hmm, thinking about it, it might also be a symlink issue:
> > The tempdirs are something like /tmp/test-aa-easyprofXXXXXX, and my
> > /tmp is a symlink to /home/sys-tmp/
> >
> > Seems to be a good guess - after
...
> > One more thing that breaks by /tmp being a symlink ;-)
...
> > Looks like we need os.path.realpath even for /tmp :-/
>
> The reason the test fails is because the policygroups directory that
> easyprof ends up with is different than the constructed one that
> includes the tmpdir path. It probably would have been easier to see
> this if the failure message had included the comparison values, like
> so:
>
> Index: b/utils/test/test-aa-easyprof.py
> ===================================================================
> --- a/utils/test/test-aa-easyprof.py
> +++ b/utils/test/test-aa-easyprof.py
> @@ -241,7 +241,8 @@ TEMPLATES_DIR="%s/templates"
> easyp = easyprof.AppArmorEasyProfile(self.binary,
> self.options)
>
> # no fallback
> - self.assertTrue(easyp.dirs['policygroups'] == rel, "Not using
> specified --policy-groups-dir")
> +
> self.assertTrue(easyp.dirs['policygroups'] == rel, "Not using
> specified --policy-groups-dir\n" +
> +
> "Specified dir: %s\nActual dir: %s" % (rel,
> str(easyp.dirs['policygroups'])))
> self.assertFalse(easyp.get_policy_groups() == None, "Could not find
> policy-groups")
> def test_policygroups_dir_nonexistent(self):
More verbose error messages are always a good idea :-)
Acked-by: Christian Boltz <apparmor at cboltz.de>
> > What about this patch?
> >
> > === modified file 'utils/test/test-aa-easyprof.py'
> > --- utils/test/test-aa-easyprof.py 2014-03-03 21:26:41 +0000
> > +++ utils/test/test-aa-easyprof.py 2014-03-05 20:19:49 +0000
> > @@ -108,7 +108,7 @@
> >
> > '''Setup for tests'''
> > global topdir
> >
> > - self.tmpdir = tempfile.mkdtemp(prefix='test-aa-easyprof')
> > + self.tmpdir = tempfile.mkdtemp(prefix='test-aa-easyprof',
> > dir=os.path.realpath('/tmp'))
> > Opinions? Acks? Naks? ;-)
>
> As someone who sets TMPDIR to point outside of /tmp, no, I don't like
> this patch. :)
;-)
> It seems to me the better fix would be:
>
> - self.tmpdir = tempfile.mkdtemp(prefix='test-aa-easyprof')
> + self.tmpdir =
> os.path.realpath(tempfile.mkdtemp(prefix='test-aa-easyprof'))
>
> This way, TMPDIR is still honored, but any symlinks in the generated
> path are resolved away.
Indeed, this way should work for everybody.
Acked-by: Christian Boltz <apparmor at cboltz.de>
Regards,
Christian Boltz
--
Yeah, I always need to have a sick bag handy when thinking about
web apps ;-) [Ludwig Nussel in opensuse-packaging]
More information about the AppArmor
mailing list