Merge branch 'cboltz-fix-genprof-json' into 'master'

Fix showing the local inactive profile in json mode

See merge request apparmor/apparmor!514

Acked-by: John Johansen <john.johansen@canonical.com> for 2.11..master
This commit is contained in:
Christian Boltz 2020-05-06 22:43:35 +00:00
commit 986b4f2b72
2 changed files with 10 additions and 8 deletions

View file

@ -527,8 +527,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':
created.append(prof_name)
return p['profile_data']

View file

@ -290,14 +290,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'),