From d9891b1ff99c1eddd3f35b7444ffbe9fb8be9c49 Mon Sep 17 00:00:00 2001 From: Ad Schellevis Date: Tue, 5 Jan 2021 14:52:44 +0100 Subject: [PATCH] filter/aliases: minor regression in maintaining target alias file (/var/db/aliastables/%s.txt). when it's either changed, expired or simply not there, it should dump the contents before loading it with pfctl --- src/opnsense/scripts/filter/update_tables.py | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/opnsense/scripts/filter/update_tables.py b/src/opnsense/scripts/filter/update_tables.py index fc0ad2bfc..38da06545 100755 --- a/src/opnsense/scripts/filter/update_tables.py +++ b/src/opnsense/scripts/filter/update_tables.py @@ -137,13 +137,8 @@ if __name__ == '__main__': alias_changed_or_expired = max(alias_changed_or_expired, rel_alias.changed(), rel_alias.expired()) alias_content += rel_alias.resolve() # when the alias or any of it's dependencies has changed, generate new - if alias_changed_or_expired: - alias_content_txt = '\n'.join(sorted(alias_content)) - open('/var/db/aliastables/%s.txt' % alias_name, 'w').write(alias_content_txt) - elif os.path.isfile('/var/db/aliastables/%s.txt' % alias_name): - alias_content_txt = open('/var/db/aliastables/%s.txt' % alias_name, 'r').read() - else: - alias_content_txt = "" + if alias_changed_or_expired or not os.path.isfile('/var/db/aliastables/%s.txt' % alias_name): + open('/var/db/aliastables/%s.txt' % alias_name, 'w').write('\n'.join(sorted(alias_content))) alias_pf_content = list() sp = subprocess.run(['/sbin/pfctl', '-t', alias_name, '-T', 'show'], capture_output=True, text=True)