From ff72ea9a56918da19f4a53acda26d14c7e598b56 Mon Sep 17 00:00:00 2001 From: John Johansen Date: Mon, 19 Oct 2020 19:14:59 -0700 Subject: [PATCH] aa-notify: Stop aa-notify from exit after 100s of polling MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When run with the -p flag, aa-notify works fine for 100 seconds and then it exits. I suspect that the issue arises from the following check on line 259 in utils/aa-notify if debug_logger.debug_level <= 10 and int(time.time()) - start_time > 100: debug_logger.debug('Debug mode detected: aborting notification emitter after 100 seconds.') sys.exit(0) together with line 301 in utils/apparmor/common.py which initializes debug_logger.debug_level to logging.DEBUG which has the numerical value 10. A simple solution might be to just remove the check as I'm not quit sure why one would want aa-notify to exit when run in debug mode in the first place. Alternatively, one could check against debug_logger.debugging (initialized to False) or change the initialization of debug_logger.debug_level to something else, but I don't know how that would affect other consumers of utils/apparmor/common.py. For now just add dbugger_logger.debugging as an additional check as the reason for timing out after 100s during debugging are unclear. Suggested-by: vicvbcun Fixes: https://gitlab.com/apparmor/apparmor/-/issues/126 MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/660 Signed-off-by: John Johansen Acked-by: Otto Kekäläinen (cherry picked from commit 8ea7630b6dc6b46e00341835e92c4f6ead05e984) --- utils/aa-notify | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/utils/aa-notify b/utils/aa-notify index 7bb8997c4..b98a5d439 100755 --- a/utils/aa-notify +++ b/utils/aa-notify @@ -256,7 +256,7 @@ def follow_apparmor_events(logfile, wait=0): continue yield event - if debug_logger.debug_level <= 10 and int(time.time()) - start_time > 100: + if debug_logger.debugging and debug_logger.debug_level <= 10 and int(time.time()) - start_time > 100: debug_logger.debug('Debug mode detected: aborting notification emitter after 100 seconds.') sys.exit(0) @@ -407,7 +407,8 @@ def main(): debug_logger.activateStderr() debug_logger.debug('Logging level: {}'.format(debug_logger.debug_level)) debug_logger.debug('Running as uid: {0[0]}, euid: {0[1]}, suid: {0[2]}'.format(os.getresuid())) - + if args.poll: + debug_logger.debug('Running with --debug and --poll. Will exit in 100s') # Sanity checks user_ids = os.getresuid() groups_ids = os.getresgid()