diff --git a/src/sshmngr.c b/src/sshmngr.c index 3ee2e5762e697dedd786682e907a3094159f319c..5b8f9a852e7fac2736cc0e231df46ad72ff5d8bb 100644 --- a/src/sshmngr.c +++ b/src/sshmngr.c @@ -179,9 +179,9 @@ static int delObjSSHKey(char *refparam, struct dmctx *ctx, void *data, char *ins switch (del_action) { case DEL_INST: - dmuci_get_value_by_section_string((struct uci_section *)data, "pubkey", &value); + dmuci_get_value_by_section_string(((struct dm_data *)data)->config_section, "pubkey", &value); remove_pubkey(value); - dmuci_delete_by_section((struct uci_section *)data, NULL, NULL); + dmuci_delete_by_section(((struct dm_data *)data)->config_section, NULL, NULL); break; case DEL_ALL: uci_path_foreach_sections_safe(bbfdm, "dmmap_sshmngr", "authkey", stmp, s) { @@ -233,7 +233,7 @@ static int browseSSHServerInst(struct dmctx *dmctx, DMNODE *parent_node, void *p inst = handle_instance(dmctx, parent_node, curr_data->dmmap_section, "server_instance", "server_alias"); - if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)curr_data, inst) == DM_STOP) + if (DM_LINK_INST_OBJ(dmctx, parent_node, curr_data, inst) == DM_STOP) break; } @@ -248,6 +248,7 @@ static int browseSSHKeyInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev char *key = NULL; unsigned idx = 0; json_object *json_key_list = NULL, *arr_obj = NULL; + struct dm_data curr_data = {0}; dmubus_call("sshmngr", "list_keys", UBUS_ARGS{0}, 0, &json_key_list); DM_ASSERT(json_key_list, return 0); @@ -288,9 +289,12 @@ static int browseSSHKeyInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev s = NULL; uci_path_foreach_sections_safe(bbfdm, "dmmap_sshmngr", "authkey", stmp, s) { + + curr_data.config_section = s; + inst = handle_instance(dmctx, parent_node, s, "instance", "alias"); - if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)s, inst) == DM_STOP) + if (DM_LINK_INST_OBJ(dmctx, parent_node, &curr_data, inst) == DM_STOP) break; } return 0; @@ -321,7 +325,7 @@ static int browseSSHServerSessionInst(struct dmctx *dmctx, DMNODE *parent_node, dmjson_foreach_obj_in_array(json_session_list, arr_obj, session_obj, idx, 1, "sessions") { curr_data.json_object = session_obj; inst = handle_instance_without_section(dmctx, parent_node, ++id); - if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)&curr_data, inst) == DM_STOP) + if (DM_LINK_INST_OBJ(dmctx, parent_node, &curr_data, inst) == DM_STOP) break; } @@ -634,17 +638,17 @@ static int get_ssh_server_session_port(char *refparam, struct dmctx *ctx, void * static int get_ssh_key_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { - return bbf_get_alias(ctx, (struct uci_section *)data, "alias", instance, value); + return bbf_get_alias(ctx, ((struct dm_data *)data)->config_section, "alias", instance, value); } static int set_ssh_key_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action) { - return bbf_set_alias(ctx, (struct uci_section *)data, "alias", instance, value); + return bbf_set_alias(ctx, ((struct dm_data *)data)->config_section, "alias", instance, value); } static int get_ssh_key_pubkey(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { - dmuci_get_value_by_section_string((struct uci_section *)data, "pubkey", value); + dmuci_get_value_by_section_string(((struct dm_data *)data)->config_section, "pubkey", value); return 0; } @@ -658,7 +662,7 @@ static int set_ssh_key_pubkey(char *refparam, struct dmctx *ctx, void *data, cha return FAULT_9007; /* check if same as current key value */ - dmuci_get_value_by_section_string((struct uci_section *)data, "pubkey", &cur_val); + dmuci_get_value_by_section_string(((struct dm_data *)data)->config_section, "pubkey", &cur_val); if (DM_STRCMP(cur_val, value) == 0) break; @@ -668,12 +672,12 @@ static int set_ssh_key_pubkey(char *refparam, struct dmctx *ctx, void *data, cha break; case VALUESET: /* check if same as current key value then nothing to do */ - dmuci_get_value_by_section_string((struct uci_section *)data, "pubkey", &cur_val); + dmuci_get_value_by_section_string(((struct dm_data *)data)->config_section, "pubkey", &cur_val); if (DM_STRCMP(cur_val, value) == 0) break; add_pubkey(cur_val, value); - dmuci_set_value_by_section((struct uci_section *)data, "pubkey", value); + dmuci_set_value_by_section(((struct dm_data *)data)->config_section, "pubkey", value); break; } return 0;