From 1a8409c55aade398acba9450a804898c9a72da98 Mon Sep 17 00:00:00 2001 From: Mark Huth Date: Tue, 13 Dec 2022 07:36:49 +1000 Subject: [PATCH] Delete old malware rules files from /var/tmp as well Signed-off-by: Mark Huth --- insights/client/apps/malware_detection/__init__.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/insights/client/apps/malware_detection/__init__.py b/insights/client/apps/malware_detection/__init__.py index 27a6d6ee53..1accea5f6f 100644 --- a/insights/client/apps/malware_detection/__init__.py +++ b/insights/client/apps/malware_detection/__init__.py @@ -603,7 +603,9 @@ def _get_rules(self): # malware-detection client exits. # However it can happen that the rules file isn't removed for some reason, so remove any existing # rules files before beginning a new scan, otherwise they may show up as matches in the scan results. - old_rules_files = glob('/tmp/.tmpmdsigs*') + glob('/tmp/tmp_malware-detection-client_rules.*') + old_rules_files = sum([glob(os.path.join(path, rules)) + for path in ('/tmp', '/var/tmp') + for rules in ('.tmpmdsigs*', 'tmp_malware-detection-client_rules.*')], []) for old_rules_file in old_rules_files: logger.debug("Removing old rules file %s", old_rules_file) os.remove(old_rules_file)