Get Name Method: Several fixes

This commit is contained in:
Amin Ben Romdhane 2024-01-31 16:15:36 +01:00
parent 09d0adde8e
commit eddef9c116

View file

@ -1506,7 +1506,7 @@ static int get_ubus_name(struct dmctx *dmctx, struct dmnode *node)
char *fault = dmjson_get_value(res_obj, 1, "fault"); char *fault = dmjson_get_value(res_obj, 1, "fault");
if (DM_STRLEN(fault)) if (DM_STRLEN(fault))
continue; return DM_STRTOUL(fault);
dmctx->findparam = 1; dmctx->findparam = 1;
@ -1521,6 +1521,9 @@ static int get_ubus_name(struct dmctx *dmctx, struct dmnode *node)
if ((path[len - 1] == '.' && path_dot_num > in_path_dot_num + 1) || if ((path[len - 1] == '.' && path_dot_num > in_path_dot_num + 1) ||
(path[len - 1] != '.' && path_dot_num > in_path_dot_num)) (path[len - 1] != '.' && path_dot_num > in_path_dot_num))
continue; continue;
} else {
if (i == 0 && (dmctx->in_param[0] == '\0' || rootcmp(dmctx->in_param, "Device") == 0))
continue;
} }
add_list_parameter(dmctx, dmstrdup(path), dmstrdup(data), dmstrdup(type), NULL); add_list_parameter(dmctx, dmstrdup(path), dmstrdup(data), dmstrdup(type), NULL);
@ -1833,10 +1836,8 @@ static int mparam_get_name_in_param(DMPARAM_ARGS)
{ {
if (node->is_ubus_service) { if (node->is_ubus_service) {
int err = get_ubus_name(dmctx, node); int err = get_ubus_name(dmctx, node);
if (err)
return err;
dmctx->stop = true; dmctx->stop = true;
return err ? err : 0;
} else { } else {
char *refparam; char *refparam;
char *perm = leaf->permission->val; char *perm = leaf->permission->val;
@ -1868,9 +1869,8 @@ static int mparam_get_name_in_param(DMPARAM_ARGS)
add_list_parameter(dmctx, refparam, perm, DMT_TYPE[leaf->type], NULL); add_list_parameter(dmctx, refparam, perm, DMT_TYPE[leaf->type], NULL);
dmctx->findparam = (dmctx->iswildcard) ? 1 : 0; dmctx->findparam = (dmctx->iswildcard) ? 1 : 0;
return 0;
} }
return 0;
} }
static int mobj_get_name_in_obj(DMOBJECT_ARGS) static int mobj_get_name_in_obj(DMOBJECT_ARGS)
@ -1947,6 +1947,7 @@ int dm_entry_get_name(struct dmctx *ctx)
ctx->method_obj = mobj_get_name; ctx->method_obj = mobj_get_name;
ctx->method_param = mparam_get_name; ctx->method_param = mparam_get_name;
ctx->in_param = root->obj; ctx->in_param = root->obj;
ctx->disable_mservice_browse = true;
node.matched = 1; node.matched = 1;
findparam_check = 1; findparam_check = 1;
} else if (*(ctx->in_param + len - 1) == '.') { } else if (*(ctx->in_param + len - 1) == '.') {