1
0
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:
Adrien Banlin
2023-06-12 15:19:09 +02:00
parent a2d18a9d78
commit cb8c67bc66

View File

@@ -160,12 +160,13 @@ class networkInterfaces():
allow_line = lines[cur_idx]
words = re.split(self._ws_split_regex, allow_line)
if len(words) <= 1:
raise Exception('invalid allow line \'%s\' at line %d'
%(allow_line, lineno))
allow_class = words[0].split('-')[1]
ifacenames = words[1:]
try:
allow_class = words[0].split('-')[1]
ifacenames = words[1:]
if not ifacenames or not allow_class:
raise IndexError()
except IndexError:
raise Exception(f'invalid allow line {allow_line} at line {lineno}')
self._add_ifaces_to_class(allow_class, ifacenames)
return 0