Fix crash with operate without input

This commit is contained in:
Vivek Kumar Dutta 2024-04-25 11:03:49 +05:30
parent 927e839c47
commit d5d84ae1da
2 changed files with 16 additions and 5 deletions

View file

@ -642,10 +642,10 @@ static int bbfdm_operate_handler(struct ubus_context *ctx, struct ubus_object *o
data.bbf_ctx.in_param = path;
data.bbf_ctx.linker = tb[DM_OPERATE_COMMAND_KEY] ? blobmsg_get_string(tb[DM_OPERATE_COMMAND_KEY]) : "";
str = blobmsg_format_json(tb[DM_OPERATE_INPUT], true);
if (tb[DM_OPERATE_INPUT])
if (tb[DM_OPERATE_INPUT]) {
str = blobmsg_format_json(tb[DM_OPERATE_INPUT], true);
data.bbf_ctx.in_value = str;
}
fill_optional_data(&data, tb[DM_OPERATE_OPTIONAL]);

View file

@ -5,6 +5,17 @@
BBFDM_DMMAP_CONFIG="/etc/bbfdm/dmmap"
BBFDM_DMMAP_SAVEDIR="/tmp/.bbfdm"
LOGLEVEL="$(uci -q get bbfdm.bbfdmd.loglevel)"
log() {
local level
level="${LOGLEVEL:-0}"
if [ "${level}" -gt 2 ]; then
echo "$@" | logger -t bbf.config -p info
fi
}
check_result() {
local res="$1"
local service="$2"
@ -25,7 +36,7 @@ apply_config_changes() {
return
fi
logger -t bbf.config -p info "Applying $action configuration for service: $service"
log "Applying $action configuration for service: $service"
# Commit/Revert config changes
ubus -t 1 call uci ${action} "{'config': '${service}'}"
@ -62,7 +73,7 @@ case "$1" in
# Commit/Revert bbfdm dmmap config changes
for file in "${BBFDM_DMMAP_CONFIG}"/*; do
file_name=$(basename "${file}")
logger -t bbf.config -p info "Applying $2 configuration for file: $file_name"
log "Applying $2 configuration for file: $file_name"
uci -q -c "${BBFDM_DMMAP_CONFIG}" -t "${BBFDM_DMMAP_SAVEDIR}" "$2" "${file_name}"
check_result "$?" "${file_name}" "$2"
done