[apparmor] [patch] Make aa.py 'log' non-global

Christian Boltz apparmor at cboltz.de
Sun Aug 27 15:53:05 UTC 2017


Hello,

'log' is only used in do_logprof_pass, and reset to [] at the beginning
of the function. Therefore it doesn't need to be a global variable.

Also, do_logprof_pass() initializes log = [], which gets then handed
over to ReadLog and overwritten by the read_log() call in the next line.
To make clear that [] gets handed over to ReadLog, replace log with []
and drop the now superfluous initialization with []. 


[ 04-non-global-log.diff ]

--- utils/apparmor/aa.py        2017-08-27 17:43:07.628447476 +0200
+++ utils/apparmor/aa.py        2017-08-27 17:37:01.861782946 +0200
@@ -101,7 +101,6 @@
 original_aa = hasher()
 extras = hasher()  # Inactive profiles from extras
 ### end our
-log = []
 log_pid = dict()  # handed over to ReadLog, gets filled in logparser.py. The only case the previous content of this variable _might_(?) be used is aa-genprof (multiple do_logprof_pass() runs)
 
 profile_changes = hasher()
@@ -1748,8 +1749,6 @@
 def do_logprof_pass(logmark='', passno=0, log_pid=log_pid):
     # set up variables for this pass
 #    transitions = hasher()
-    global log
-    log = []
     global existing_profiles
     global sev_db
 #    aa = hasher()
@@ -1773,7 +1772,7 @@
     ##    if not repo_cfg['repository'].get('enabled', False) or repo_cfg['repository]['enabled'] not in ['yes', 'no']:
     ##    UI_ask_to_enable_repo()
 
-    log_reader = apparmor.logparser.ReadLog(log_pid, logfile, existing_profiles, profile_dir, log)
+    log_reader = apparmor.logparser.ReadLog(log_pid, logfile, existing_profiles, profile_dir, [])
     log = log_reader.read_log(logmark)
     #read_log(logmark)
 


Regards,

Christian Boltz
-- 
> Als Vanilla werden die ungepatchten LinuxKernel bezeichnet die es
> z.B. bei http://www.kernel.org gibt.
Genau. Sozusagen ein Kernel ohne Aroma. Ich hatte den 2.4.19-pre7
probiert, der schmeckt nur nach Kernel - und geht.
[> Markus Kolb und Jörg Lippmann in suse-linux]
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: This is a digitally signed message part.
URL: <https://lists.ubuntu.com/archives/apparmor/attachments/20170827/5b264bd4/attachment.pgp>


More information about the AppArmor mailing list