[apparmor] test-aa-easyprof.py fails because of UsrMove
Christian Boltz
apparmor at cboltz.de
Sat Mar 1 20:41:38 UTC 2014
Hello,
Am Sonntag, 2. März 2014 schrieb Kshitij Gupta:
> On Sat, Mar 1, 2014 at 3:41 AM, Christian Boltz wrote:
> > test-aa-easyprof.py depends on /bin/ls being a real binary.
> > In practise, it is a symlink to /usr/bin/ls on some distributions.
> >
> > The patch below fixes this for me, but I know it isn't a good
> > solution because it breaks on systems that didn't follow UsrMove
> > and still have /bin/ls as real binary.
>
> How about using os.path.islink() to determine if the given system
> followed UsrMove or not and accordingly setting test up?
>
> Something on the lines of:
>
> ls_path='/bin/ls'
> if os.path.islink(ls_path):
> ls_path='/usr/bin/ls'
>
> and then use ls_path everywhere.
That sounds like a plan, even if it means we replace a hardcoded value
with two hardcoded values ;-) [1]
Here's a patch that should work for everybody:
=== modified file 'utils/test/test-aa-easyprof.py'
--- utils/test/test-aa-easyprof.py 2014-02-14 01:53:40 +0000
+++ utils/test/test-aa-easyprof.py 2014-03-01 20:38:07 +0000
@@ -424,14 +424,14 @@
#
def test_binary_without_profile_name(self):
'''Test binary (<binary> { })'''
- easyprof.AppArmorEasyProfile('/bin/ls', self.options)
+ easyprof.AppArmorEasyProfile(ls_path, self.options)
def test_binary_with_profile_name(self):
'''Test binary (profile <name> <binary> { })'''
args = self.full_args
args += ['--profile-name=some-profile-name']
(self.options, self.args) = easyprof.parse_args(args)
- easyprof.AppArmorEasyProfile('/bin/ls', self.options)
+ easyprof.AppArmorEasyProfile(ls_path, self.options)
def test_binary_omitted_with_profile_name(self):
'''Test binary (profile <name> { })'''
@@ -1206,7 +1206,7 @@
def test_gen_manifest_policy_with_binary_with_profile_name(self):
'''Test gen_manifest_policy (binary with profile name)'''
m = Manifest("test_gen_manifest_policy")
- m.add_binary('/bin/ls')
+ m.add_binary(ls_path)
self._gen_manifest_policy(m)
def
test_gen_manifest_policy_without_binary_with_profile_name(self):
@@ -2482,6 +2482,11 @@
# Now that we have everything we need, import aa-easyprof
import easyprof
+ # work around UsrMove
+ ls_path='/bin/ls'
+ if os.path.islink(ls_path):
+ ls_path='/usr/bin/ls'
+
# run the tests
suite = unittest.TestSuite()
suite.addTest(unittest.TestLoader().loadTestsFromTestCase(T))
Regards,
Christian Boltz
[1] let's hope nobody comes up with another idea to move ls around ;-)
--
[SuSE-Plugger] Ist auch nichts von KDE, sondern ist eine SuSE-
spezifische Fehlentwicklung. [Manfred Tremmel in suse-linux]
More information about the AppArmor
mailing list