mirror of
https://gitlab.com/apparmor/apparmor
synced 2025-09-02 15:25: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:
@@ -498,6 +498,10 @@ def get_profile(prof_name):
|
|||||||
|
|
||||||
ans = ''
|
ans = ''
|
||||||
while 'CMD_USE_PROFILE' not in ans and 'CMD_CREATE_PROFILE' not in 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)
|
ans, arg = aaui.UI_PromptUser(q)
|
||||||
p = profile_hash[options[arg]]
|
p = profile_hash[options[arg]]
|
||||||
q['selected'] = options.index(options[arg])
|
q['selected'] = options.index(options[arg])
|
||||||
@@ -990,6 +994,10 @@ def handle_children(profile, hat, root):
|
|||||||
|
|
||||||
ans = aaui.UI_PromptUser(q)
|
ans = aaui.UI_PromptUser(q)
|
||||||
|
|
||||||
|
if ans == 'CMD_FINISHED':
|
||||||
|
save_profiles()
|
||||||
|
return
|
||||||
|
|
||||||
transitions[context] = ans
|
transitions[context] = ans
|
||||||
|
|
||||||
if ans == 'CMD_ADDHAT':
|
if ans == 'CMD_ADDHAT':
|
||||||
@@ -1251,6 +1259,11 @@ def handle_children(profile, hat, root):
|
|||||||
q['functions'] += build_x_functions(default, options, exec_toggle)
|
q['functions'] += build_x_functions(default, options, exec_toggle)
|
||||||
ans = ''
|
ans = ''
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
if ans == 'CMD_FINISHED':
|
||||||
|
save_profiles()
|
||||||
|
return
|
||||||
|
|
||||||
if ans == 'CMD_nx' or ans == 'CMD_nix':
|
if ans == 'CMD_nx' or ans == 'CMD_nix':
|
||||||
arg = exec_target
|
arg = exec_target
|
||||||
ynans = 'n'
|
ynans = 'n'
|
||||||
@@ -1550,6 +1563,11 @@ def ask_the_questions():
|
|||||||
done = False
|
done = False
|
||||||
while not done:
|
while not done:
|
||||||
ans, selected = aaui.UI_PromptUser(q)
|
ans, selected = aaui.UI_PromptUser(q)
|
||||||
|
|
||||||
|
if ans == 'CMD_FINISHED':
|
||||||
|
save_profiles()
|
||||||
|
return
|
||||||
|
|
||||||
# Ignore the log entry
|
# Ignore the log entry
|
||||||
if ans == 'CMD_IGNORE_ENTRY':
|
if ans == 'CMD_IGNORE_ENTRY':
|
||||||
done = True
|
done = True
|
||||||
@@ -1794,6 +1812,10 @@ def ask_the_questions():
|
|||||||
|
|
||||||
ans, selected = aaui.UI_PromptUser(q)
|
ans, selected = aaui.UI_PromptUser(q)
|
||||||
|
|
||||||
|
if ans == 'CMD_FINISHED':
|
||||||
|
save_profiles()
|
||||||
|
return
|
||||||
|
|
||||||
if ans == 'CMD_IGNORE_ENTRY':
|
if ans == 'CMD_IGNORE_ENTRY':
|
||||||
done = True
|
done = True
|
||||||
break
|
break
|
||||||
@@ -1945,6 +1967,11 @@ def ask_the_questions():
|
|||||||
done = False
|
done = False
|
||||||
while not done:
|
while not done:
|
||||||
ans, selected = aaui.UI_PromptUser(q)
|
ans, selected = aaui.UI_PromptUser(q)
|
||||||
|
|
||||||
|
if ans == 'CMD_FINISHED':
|
||||||
|
save_profiles()
|
||||||
|
return
|
||||||
|
|
||||||
if ans == 'CMD_IGNORE_ENTRY':
|
if ans == 'CMD_IGNORE_ENTRY':
|
||||||
done = True
|
done = True
|
||||||
break
|
break
|
||||||
|
@@ -288,10 +288,6 @@ def UI_PromptUser(q, params=''):
|
|||||||
if cmd == 'CMD_ABORT':
|
if cmd == 'CMD_ABORT':
|
||||||
confirm_and_abort()
|
confirm_and_abort()
|
||||||
cmd = 'XXXINVALIDXXX'
|
cmd = 'XXXINVALIDXXX'
|
||||||
elif cmd == 'CMD_FINISHED':
|
|
||||||
if not params:
|
|
||||||
confirm_and_finish()
|
|
||||||
cmd = 'XXXINVALIDXXX'
|
|
||||||
return (cmd, arg)
|
return (cmd, arg)
|
||||||
|
|
||||||
def confirm_and_abort():
|
def confirm_and_abort():
|
||||||
@@ -317,9 +313,6 @@ def UI_LongMessage(title, message):
|
|||||||
})
|
})
|
||||||
ypath, yarg = GetDataFromYast()
|
ypath, yarg = GetDataFromYast()
|
||||||
|
|
||||||
def confirm_and_finish():
|
|
||||||
sys.stdout.write(_('FINISHING...\n'))
|
|
||||||
sys.exit(0)
|
|
||||||
|
|
||||||
def Text_PromptUser(question):
|
def Text_PromptUser(question):
|
||||||
title = question['title']
|
title = question['title']
|
||||||
|
Reference in New Issue
Block a user