[apparmor] [patch] aa.py: let parse_audit_allow also match comments

Christian Boltz apparmor at cboltz.de
Sat Nov 8 15:55:11 UTC 2014


Hello,

Am Samstag, 8. November 2014 schrieb Kshitij Gupta:
> On Sat, Nov 8, 2014 at 3:56 AM, Christian Boltz wrote:
> > +        comment = ' %s' % matches.group('comment').strip()
> 
> Would the superfluous spaces be better dealt in the regex RE_EOL by
> ignoring them from comment group?
> That would save us many such calls.

Indeed, good idea!

Here's the follow-up patch to let RE_EOL strip whitespace from the 
comment:

=== modified file 'utils/apparmor/aa.py'
--- utils/apparmor/aa.py        2014-11-08 15:47:39 +0000
+++ utils/apparmor/aa.py        2014-11-08 15:53:23 +0000
@@ -2613,7 +2613,7 @@
 ## Profile parsing Regex
 RE_AUDIT_DENY           = '^\s*(?P<audit>audit\s+)?(?P<allow>allow\s+|deny\s+)?'  # line start, optionally: leading whitespace, <audit> and <allow>/deny
 RE_OWNER                = '(?P<owner>owner\s+)?'  # optionally: <owner>
-RE_EOL                  = '\s*(?P<comment>#.*)?$'  # optional whitespace, optional <comment>, end of the line
+RE_EOL                  = '\s*(?P<comment>#.*?)?\s*$'  # optional whitespace, optional <comment>, optional whitespace, end of the line
 RE_COMMA_EOL            = '\s*,' + RE_EOL # optional whitespace, comma + RE_EOL
 
 RE_PROFILE_START        = re.compile('^\s*("?(/.+?)"??|(profile\s+"?(.+?)"??))\s+((flags=)?\((.+)\)\s+)?\{' + RE_EOL)



Regards,

Christian Boltz
-- 
Key Signing Party? Was ist denn das?
Kultiges Zusammensitzen und gemeinsames Murmeln magischer Zahlen.
-- Gert Döring, FdI 95




More information about the AppArmor mailing list