Skip to content

Commit

Permalink
gluon-core: dont fail on unset interface role (#3095)
Browse files Browse the repository at this point in the history
In case no interface role was selected for a given interface,
gluon-reconfigure currently fails with

Configuring: 021-interface-roles
/usr/bin/lua: /usr/lib/lua/gluon/util.lua:25: bad argument #1 to 'pairs' (table expected, got nil)
stack traceback:
	[C]: in function '?'
	/usr/lib/lua/simple-uci.lua:22: in function 'foreach'
	./021-interface-roles:47: in main chunk
	[C]: ?

Check we actually have a role set before accessing the table.

Signed-off-by: David Bauer <mail@david-bauer.net>
(cherry picked from commit c4d3703)
  • Loading branch information
herbetom committed Dec 11, 2023
1 parent 47fefe9 commit c59d070
Showing 1 changed file with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ end
uci:foreach('gluon', 'interface', function(interface)

local function has_role(role)
if interface.role == nil then
return false
end

return util.contains(interface.role, role)
end

Expand Down

0 comments on commit c59d070

Please sign in to comment.