[apparmor] new profile tools: preserve full initial comment
Christian Boltz
apparmor at cboltz.de
Wed Feb 5 22:58:24 UTC 2014
Hello,
while playing with aa-cleanprof, I noticed only the last line of the
initial comment was preserved.
This patch
- preserves the complete initial comment
- makes sure whitespace inside the comment is kept (except leading
whitespace - line.trim() is still applied).
- no longer removes the "# vim:syntax" line
Note: I didn't test if handling the "REPOSITORY" line still works (in
theory it should), but without a working repo, I don't care too much ;-)
BTW: It might be a good idea to use a different variable name for the
result of line.split() to avoid confusion.
I also noticed you didn't commit my patch for handling (F)inish I sent
a week ago.
Kshitij, if you like my patches, please commit them - I'd like to have
a more readable "bzr diff" again soon ;-)
=== modified file 'apparmor/aa.py'
--- apparmor/aa.py 2014-02-01 00:44:05 +0000
+++ apparmor/aa.py 2014-02-05 22:30:08 +0000
@@ -2937,10 +2966,12 @@
elif line[0] == '#':
# Handle initial comments
if not profile:
- if line.startswith('# vim:syntax') or line.startswith('# Last Modified:'):
+# if line.startswith('# vim:syntax') or line.startswith('# Last Modified:'):
+ if line.startswith('# Last Modified:'):
continue
- line = line.split()
- if len(line) > 1 and line[1] == 'REPOSITORY:':
+ elif line.startswith('# REPOSITORY'): # TODO: allow any number of spaces/tabs
+# if len(line) > 1 and line[1] == 'REPOSITORY:':
+ line = line.split()
if len(line) == 3:
repo_data = {'neversubmit': True}
elif len(line) == 5:
@@ -2948,7 +2979,7 @@
'user': line[3],
'id': line[4]}
else:
- initial_comment = ' '.join(line) + '\n'
+ initial_comment = initial_comment + line + '\n'
else:
raise AppArmorException(_('Syntax Error: Unknown line found in file: %s line: %s') % (file, lineno+1))
Regards,
Christian Boltz
--
<cboltz> jjohansen: you are making it too easy for kshitij8 ;-)
<jjohansen> cboltz: oops sorry, now I'll have to come up with a new task
to make him suffer :)
<sarnold> review the c++11 conversion? :)
* sarnold runs
<jjohansen> haha, sarnold I said suffer, not drive him to commit suicide
[from #apparmor]
More information about the AppArmor
mailing list