Merge branch 'cboltz-2.13-genprof-fix-json' into 'apparmor-2.13'

[2.11..2.13] Fix showing the local inactive profile in json mode

See merge request apparmor/apparmor!516

Acked-by: Steve Beattie <steve.beattie@canonical.com> for 2.12 and 2.13
This commit is contained in:
Christian Boltz 2020-05-07 10:18:12 +00:00
commit eb5185c961
2 changed files with 10 additions and 8 deletions

View file

@ -559,8 +559,7 @@ def get_profile(prof_name):
p = profile_hash[options[arg]]
q.selected = options.index(options[arg])
if ans == 'CMD_VIEW_PROFILE':
pager = get_pager()
subprocess.call([pager, orig_filename])
aaui.UI_ShowFile(uname, orig_filename)
elif ans == 'CMD_USE_PROFILE':
if p['profile_type'] == 'INACTIVE_LOCAL':
profile_data = p['profile_data']

View file

@ -254,14 +254,17 @@ def UI_Changes(oldprofile, newprofile, comments=False):
else:
difftemp = generate_diff_with_comments(oldprofile, newprofile)
header = 'View Changes with comments'
if UI_mode == 'json':
jsonout = {'dialog': 'changes', 'header':header, 'filename': difftemp.name}
write_json(jsonout)
json_response('changes')["response"] # wait for response to delay deletion of difftemp (and ignore response content)
else:
subprocess.call('less %s' % difftemp.name, shell=True)
UI_ShowFile(header, difftemp.name)
difftemp.close()
def UI_ShowFile(header, filename):
if UI_mode == 'json':
jsonout = {'dialog': 'changes', 'header': header, 'filename': filename}
write_json(jsonout)
json_response('changes')["response"] # wait for response to delay deletion of filename (and ignore response content)
else:
subprocess.call('less %s' % filename, shell=True)
CMDS = {'CMD_ALLOW': _('(A)llow'),
'CMD_OTHER': _('(M)ore'),
'CMD_AUDIT_NEW': _('Audi(t)'),