Skip to content

Commit

Permalink
Fix including configs with relative paths
Browse files Browse the repository at this point in the history
  • Loading branch information
jplitza committed Sep 27, 2019
1 parent 2137888 commit bea34e3
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions birdagent.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import re
import subprocess
import glob
import os
import dateutil.parser
from datetime import datetime
import traceback
Expand All @@ -48,7 +49,7 @@ def __init__(self, cfgfile, birdcli, sscmd):
"established": 6,
}

_re_config_include = re.compile("^include\s*\"(/[^\"]*)\".*$")
_re_config_include = re.compile("^include\s*\"([^\"]*)\".*$")
_re_config_bgp_proto_begin = re.compile(
"^protocol bgp ([a-zA-Z0-9_]+).*\{$")
_re_config_bgp_holdtime = re.compile("hold time ([0-9]+);")
Expand Down Expand Up @@ -151,7 +152,10 @@ def combinedConfigLines(filename):
if not match:
yield line
else:
for subconf in glob.glob(match.group(1)):
included = match.group(1)
if not included.startswith('/'):
included = os.path.join(os.path.dirname(filename), included)
for subconf in glob.glob(included):
yield "# subconf: %s (from %s)" % (subconf, line)
for subline in BirdAgent.combinedConfigLines(subconf):
yield subline
Expand Down

0 comments on commit bea34e3

Please sign in to comment.