mirror of
https://gitlab.com/apparmor/apparmor
synced 2025-09-03 15:55:46 +00:00
make 'prelog' non-global
It's only used by two functions: - handle_hashlog() - writes to prelog, and now returns it - collapse_log() - reads prelog, and now gets it as parameter
This commit is contained in:
@@ -104,7 +104,6 @@ original_aa = hasher()
|
|||||||
extras = hasher() # Inactive profiles from extras
|
extras = hasher() # Inactive profiles from extras
|
||||||
### end our
|
### end our
|
||||||
|
|
||||||
prelog = hasher()
|
|
||||||
changed = dict()
|
changed = dict()
|
||||||
created = []
|
created = []
|
||||||
helpers = dict() # Preserve this between passes # was our
|
helpers = dict() # Preserve this between passes # was our
|
||||||
@@ -888,6 +887,8 @@ def build_x_functions(default, options, exec_toggle):
|
|||||||
def handle_hashlog(hashlog):
|
def handle_hashlog(hashlog):
|
||||||
'''Copy hashlog content to prelog'''
|
'''Copy hashlog content to prelog'''
|
||||||
|
|
||||||
|
prelog = hasher()
|
||||||
|
|
||||||
for aamode in hashlog.keys():
|
for aamode in hashlog.keys():
|
||||||
for full_profile in hashlog[aamode].keys():
|
for full_profile in hashlog[aamode].keys():
|
||||||
if hashlog[aamode][full_profile]['final_name'] == '':
|
if hashlog[aamode][full_profile]['final_name'] == '':
|
||||||
@@ -899,6 +900,8 @@ def handle_hashlog(hashlog):
|
|||||||
for typ in hashlog[aamode][full_profile].keys():
|
for typ in hashlog[aamode][full_profile].keys():
|
||||||
prelog[aamode][profile][hat][typ] = hashlog[aamode][full_profile][typ]
|
prelog[aamode][profile][hat][typ] = hashlog[aamode][full_profile][typ]
|
||||||
|
|
||||||
|
return prelog
|
||||||
|
|
||||||
def ask_addhat(hashlog):
|
def ask_addhat(hashlog):
|
||||||
'''ask the user about change_hat events (requests to add a hat)'''
|
'''ask the user about change_hat events (requests to add a hat)'''
|
||||||
|
|
||||||
@@ -1688,7 +1691,6 @@ def do_logprof_pass(logmark='', passno=0):
|
|||||||
global active_profiles
|
global active_profiles
|
||||||
global sev_db
|
global sev_db
|
||||||
# aa = hasher()
|
# aa = hasher()
|
||||||
# prelog = hasher()
|
|
||||||
# changed = dict()
|
# changed = dict()
|
||||||
# filelist = hasher()
|
# filelist = hasher()
|
||||||
|
|
||||||
@@ -1712,11 +1714,11 @@ def do_logprof_pass(logmark='', passno=0):
|
|||||||
|
|
||||||
ask_exec(hashlog)
|
ask_exec(hashlog)
|
||||||
ask_addhat(hashlog)
|
ask_addhat(hashlog)
|
||||||
handle_hashlog(hashlog)
|
prelog = handle_hashlog(hashlog)
|
||||||
|
|
||||||
#read_log(logmark)
|
#read_log(logmark)
|
||||||
|
|
||||||
log_dict = collapse_log()
|
log_dict = collapse_log(prelog)
|
||||||
|
|
||||||
ask_the_questions(log_dict)
|
ask_the_questions(log_dict)
|
||||||
|
|
||||||
@@ -1799,7 +1801,7 @@ def save_profiles():
|
|||||||
def get_pager():
|
def get_pager():
|
||||||
return 'less'
|
return 'less'
|
||||||
|
|
||||||
def collapse_log():
|
def collapse_log(prelog):
|
||||||
log_dict = hasher()
|
log_dict = hasher()
|
||||||
for aamode in prelog.keys():
|
for aamode in prelog.keys():
|
||||||
for profile in prelog[aamode].keys():
|
for profile in prelog[aamode].keys():
|
||||||
|
@@ -239,9 +239,9 @@ def logfile_to_profile(logfile):
|
|||||||
|
|
||||||
apparmor.aa.ask_exec(hashlog)
|
apparmor.aa.ask_exec(hashlog)
|
||||||
apparmor.aa.ask_addhat(hashlog)
|
apparmor.aa.ask_addhat(hashlog)
|
||||||
apparmor.aa.handle_hashlog(hashlog)
|
prelog = apparmor.aa.handle_hashlog(hashlog)
|
||||||
|
|
||||||
log_dict = apparmor.aa.collapse_log()
|
log_dict = apparmor.aa.collapse_log(prelog)
|
||||||
|
|
||||||
if profile != hat:
|
if profile != hat:
|
||||||
# log event for a child profile means log_dict only contains the child profile
|
# log event for a child profile means log_dict only contains the child profile
|
||||||
|
Reference in New Issue
Block a user