mirror of
https://github.com/CumulusNetworks/ifupdown2.git
synced 2024-05-06 15:54:50 +00:00
networkinterfaces: fix bad allow keyword
This commit fix the following by making an understandable error msg: * the 'allow eth0' would make a IndexError shown to the user. * the 'allow-' would be valid and use an empty classname.
This commit is contained in:
@@ -160,12 +160,13 @@ class networkInterfaces():
|
|||||||
allow_line = lines[cur_idx]
|
allow_line = lines[cur_idx]
|
||||||
|
|
||||||
words = re.split(self._ws_split_regex, allow_line)
|
words = re.split(self._ws_split_regex, allow_line)
|
||||||
if len(words) <= 1:
|
try:
|
||||||
raise Exception('invalid allow line \'%s\' at line %d'
|
allow_class = words[0].split('-')[1]
|
||||||
%(allow_line, lineno))
|
ifacenames = words[1:]
|
||||||
|
if not ifacenames or not allow_class:
|
||||||
allow_class = words[0].split('-')[1]
|
raise IndexError()
|
||||||
ifacenames = words[1:]
|
except IndexError:
|
||||||
|
raise Exception(f'invalid allow line {allow_line} at line {lineno}')
|
||||||
self._add_ifaces_to_class(allow_class, ifacenames)
|
self._add_ifaces_to_class(allow_class, ifacenames)
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user