This happens when a device has an empty configuration file or
the HOOK variable is not set for an other reason.
In that case the function make the entire program crash.
This patch changes behaviour in that sense that the function
returns with an error which must be evaluated by the calling
function.
Fixes #11400
Reported-by: Daniel Weismüller <daniel.weismueller@ipfire.org>
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
local hook=$(port_get_hook ${port})
- assert isset hook
+ # Abort if we could not find a hook
+ if ! isset hook; then
+ log CRITICAL "Port ${port} does not have a hook associated with it"
+ return ${EXIT_ERROR}
+ fi
hook_exec port ${hook} ${cmd} ${port} $@
}