2
0
mirror of https://gitlab.com/apparmor/apparmor synced 2025-08-30 22:05:27 +00:00

new profile tools - handling of "(F)inish"

Let "(F)inish" ask the user if he wants to save the changed profiles 
before exiting, instead of aborting without saving (we already have 
Abo(r)t for that ;-)


Acked-by: Kshitij Gupta <kgupta8592@gmail.com>
This commit is contained in:
Christian Boltz
2014-02-24 20:56:28 +01:00
parent ce8429523d
commit a5d003f90d
2 changed files with 27 additions and 7 deletions

View File

@@ -498,6 +498,10 @@ def get_profile(prof_name):
ans = ''
while 'CMD_USE_PROFILE' not in ans and 'CMD_CREATE_PROFILE' not in ans:
if ans == 'CMD_FINISHED':
save_profiles()
return
ans, arg = aaui.UI_PromptUser(q)
p = profile_hash[options[arg]]
q['selected'] = options.index(options[arg])
@@ -990,6 +994,10 @@ def handle_children(profile, hat, root):
ans = aaui.UI_PromptUser(q)
if ans == 'CMD_FINISHED':
save_profiles()
return
transitions[context] = ans
if ans == 'CMD_ADDHAT':
@@ -1251,6 +1259,11 @@ def handle_children(profile, hat, root):
q['functions'] += build_x_functions(default, options, exec_toggle)
ans = ''
continue
if ans == 'CMD_FINISHED':
save_profiles()
return
if ans == 'CMD_nx' or ans == 'CMD_nix':
arg = exec_target
ynans = 'n'
@@ -1550,6 +1563,11 @@ def ask_the_questions():
done = False
while not done:
ans, selected = aaui.UI_PromptUser(q)
if ans == 'CMD_FINISHED':
save_profiles()
return
# Ignore the log entry
if ans == 'CMD_IGNORE_ENTRY':
done = True
@@ -1794,6 +1812,10 @@ def ask_the_questions():
ans, selected = aaui.UI_PromptUser(q)
if ans == 'CMD_FINISHED':
save_profiles()
return
if ans == 'CMD_IGNORE_ENTRY':
done = True
break
@@ -1945,6 +1967,11 @@ def ask_the_questions():
done = False
while not done:
ans, selected = aaui.UI_PromptUser(q)
if ans == 'CMD_FINISHED':
save_profiles()
return
if ans == 'CMD_IGNORE_ENTRY':
done = True
break

View File

@@ -288,10 +288,6 @@ def UI_PromptUser(q, params=''):
if cmd == 'CMD_ABORT':
confirm_and_abort()
cmd = 'XXXINVALIDXXX'
elif cmd == 'CMD_FINISHED':
if not params:
confirm_and_finish()
cmd = 'XXXINVALIDXXX'
return (cmd, arg)
def confirm_and_abort():
@@ -317,9 +313,6 @@ def UI_LongMessage(title, message):
})
ypath, yarg = GetDataFromYast()
def confirm_and_finish():
sys.stdout.write(_('FINISHING...\n'))
sys.exit(0)
def Text_PromptUser(question):
title = question['title']