utils: fix writing alias rules

write_pair() ignored the 'tail' parameter, which resulted in writing
invalid alias rules (without the trailing comma).

Also add an alias to test/cleanprof.* to ensure it doesn't break again.

(cherry picked from commit ae4ab62855)

Acked-by: John Johansen <john.johansen@canonical.com>
Acked-by: Steve Beattie <steve@nxnw.org>
PR: https://gitlab.com/apparmor/apparmor/merge_requests/119
This commit is contained in:
Christian Boltz 2018-05-06 19:35:22 +02:00 committed by Steve Beattie
parent 43285d69fe
commit 8c2371a7cd
Failed to generate hash of commit
3 changed files with 5 additions and 1 deletions

View file

@ -3355,7 +3355,7 @@ def write_pair(prof_data, depth, allow, name, prefix, sep, tail, fn):
if ref.get(name, False):
for key in sorted(ref[name].keys()):
value = fn(ref[name][key]) # eval('%s(%s)' % (fn, ref[name][key]))
data.append('%s%s%s%s%s%s' % (pre, allow, prefix, key, sep, value))
data.append('%s%s%s%s%s%s%s' % (pre, allow, prefix, key, sep, value, tail))
if ref[name].keys():
data.append('')

View file

@ -1,6 +1,8 @@
# A simple test comment which will persist
#include <tunables/global>
alias /foo -> /bar ,
/usr/bin/a/simple/cleanprof/test/profile {
# Just for the heck of it, this comment wont see the day of light
#include <abstractions/base>

View file

@ -1,3 +1,5 @@
alias /foo -> /bar,
#include <tunables/global>
# A simple test comment which will persist