Permalink
Browse files

Firewall, aliasses. race condition in creating alias directory

  • Loading branch information...
AdSchellevis committed Jan 12, 2018
1 parent e433bfb commit 60e4e8080c2df064d70ea3c83027c9496ddf1dc7
Showing with 3 additions and 4 deletions.
  1. +3 −4 src/opnsense/scripts/filter/update_tables.py
@@ -91,6 +91,9 @@ def __iter__(self):
parser.add_argument('--output', help='output type [json/text]', default='json')
parser.add_argument('--source_conf', help='configuration xml', default='/usr/local/etc/filter_tables.conf')
inputargs = parser.parse_args()
# make sure our target directory exists
if not os.path.isdir('/var/db/aliastables'):
os.makedirs('/var/db/aliastables')
try:
source_tree = ET.ElementTree(file=inputargs.source_conf)
@@ -114,10 +117,6 @@ def __iter__(self):
# 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))
if not os.path.isdir('/var/db/aliastables'):
if not os.path.isdir('/var/db'):
os.mkdir('/var/db')
os.mkdir('/var/db/aliastables')
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()

0 comments on commit 60e4e80

Please sign in to comment.