[apparmor] [patch] aamode.py - fix LOG_MODE_RE

Christian Boltz apparmor at cboltz.de
Tue Dec 2 12:55:00 UTC 2014


Hello,

Am Dienstag, 2. Dezember 2014 schrieb Peter Maloney:
> Oh if that's the way it is supposed to be (each part of the regex has
> to be the whole string), using a set instead of a regex there is also
> very easy, and should be faster just like the other regex to set
> change.

It's not that easy - the string can contain one or multiple permissions, 
which is why the regex is "^(...)+$". This also means checking with
    if mode in LOG_MODE_SET:
won't work.

> Patch attached.

Your second patch results (as I expected) in some test failures for 
tests with multiple permissions:

# PYTHONPATH=.. python3 test-aamode.py
[...]

======================================================================
FAIL: test_validate_log_mode_2 (__main__.AamodeTest_validate_log_mode)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "test-aamode.py", line 58, in test_validate_log_mode_2
    self.assertTrue(validate_log_mode('rw'))
AssertionError: False is not true

======================================================================
FAIL: test_validate_log_mode_3 (__main__.AamodeTest_validate_log_mode)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "test-aamode.py", line 60, in test_validate_log_mode_3
    self.assertTrue(validate_log_mode('Pixrw'))
AssertionError: False is not true

======================================================================
FAIL: test_validate_log_mode_4 (__main__.AamodeTest_validate_log_mode)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "test-aamode.py", line 62, in test_validate_log_mode_4
    self.assertTrue(validate_log_mode('rrrr'))
AssertionError: False is not true

----------------------------------------------------------------------
Ran 24 tests in 0.005s

FAILED (failures=3)


This means we should keep this as a regex ;-)
(or, to say it more formally, NACK)


Regards,

Christian Boltz
-- 
Pullmail? Ein POP Connector aus der Hölle?
Reliable and inexpensive POP3 connector for Exchange servers
Bruahahahahahahaha. Glaub ich nicht. Exchange und Reliable in 
einem Satz. [Ralf Hildebrandt in postfixbuch-users]




More information about the AppArmor mailing list