Skip to content

Commit

Permalink
Firewall, aliasses. race condition in creating alias directory
Browse files Browse the repository at this point in the history
  • Loading branch information
AdSchellevis committed Jan 12, 2018
1 parent e433bfb commit 60e4e80
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/opnsense/scripts/filter/update_tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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()
Expand Down

0 comments on commit 60e4e80

Please sign in to comment.