From 39f5977a47d89445bcc58adfe35a58ed60580e9f Mon Sep 17 00:00:00 2001 From: Dmitry Verenitsin Date: Wed, 18 Nov 2026 19:53:41 +0500 Subject: [PATCH] [mod_verto] Prefix login userVariables with verto_uvar_ Store `userVariables` sent in a `login` with a `verto_uvar_` prefix, matching the `verto_dvar_` prefix per-call `dialogParams` userVariables already carry, so the two scopes stay separate. Variables from the user's directory `` block keep their names. Dialplan that reads login variables by their unprefixed names needs updating. The new per-profile `enable-uservars-namespace` turns the prefix off for deployments that cannot do that yet; it defaults on. --- conf/vanilla/autoload_configs/verto.conf.xml | 7 +++++ src/mod/endpoints/mod_verto/mod_verto.c | 29 ++++++++++++++++---- src/mod/endpoints/mod_verto/mod_verto.h | 1 + 3 files changed, 31 insertions(+), 6 deletions(-) diff --git a/conf/vanilla/autoload_configs/verto.conf.xml b/conf/vanilla/autoload_configs/verto.conf.xml index b65430471e..3afd470f7b 100644 --- a/conf/vanilla/autoload_configs/verto.conf.xml +++ b/conf/vanilla/autoload_configs/verto.conf.xml @@ -26,6 +26,12 @@ Prefer the fsapi method with jsonrpc-allowed-fsapi, which allow-lists commands per user. This param is here for clients that already use api+. --> + + @@ -52,6 +58,7 @@ + diff --git a/src/mod/endpoints/mod_verto/mod_verto.c b/src/mod/endpoints/mod_verto/mod_verto.c index fe935bcd0f..bf2a0f4190 100644 --- a/src/mod/endpoints/mod_verto/mod_verto.c +++ b/src/mod/endpoints/mod_verto/mod_verto.c @@ -1158,18 +1158,30 @@ static switch_bool_t check_auth(jsock_t *jsock, cJSON *params, int *code, char * switch_mutex_lock(jsock->flag_mutex); for (i = json_ptr->child; i; i = i->next) { + char *prefixed = NULL; + const char *name = i->string; + /* Skip empty names, and the NULL ones cJSON gives array elements. */ if (zstr(i->string)) { continue; } - if (i->type == cJSON_True) { - switch_event_add_header_string(jsock->user_vars, SWITCH_STACK_BOTTOM, i->string, "true"); - } else if (i->type == cJSON_False) { - switch_event_add_header_string(jsock->user_vars, SWITCH_STACK_BOTTOM, i->string, "false"); - } else if (!zstr(i->valuestring)) { - switch_event_add_header_string(jsock->user_vars, SWITCH_STACK_BOTTOM, i->string, i->valuestring); + if (jsock->profile->enable_uservars_namespace) { + if (!(prefixed = switch_mprintf("verto_uvar_%s", i->string))) { + continue; + } + name = prefixed; } + + if (i->type == cJSON_True) { + switch_event_add_header_string(jsock->user_vars, SWITCH_STACK_BOTTOM, name, "true"); + } else if (i->type == cJSON_False) { + switch_event_add_header_string(jsock->user_vars, SWITCH_STACK_BOTTOM, name, "false"); + } else if (!zstr(i->valuestring)) { + switch_event_add_header_string(jsock->user_vars, SWITCH_STACK_BOTTOM, name, i->valuestring); + } + + switch_safe_free(prefixed); } switch_mutex_unlock(jsock->flag_mutex); } @@ -5338,6 +5350,7 @@ static switch_status_t parse_config(const char *cf) profile->mcast_sub.sock = KS_SOCK_INVALID; profile->mcast_pub.sock = KS_SOCK_INVALID; profile->chop_domain = SWITCH_TRUE; + profile->enable_uservars_namespace = SWITCH_TRUE; for (param = switch_xml_child(xprofile, "param"); param; param = param->next) { char *var = NULL; @@ -5379,6 +5392,10 @@ static switch_status_t parse_config(const char *cf) profile->blind_reg = switch_true(val); } else if (!strcasecmp(var, "enable-chat-api-proto") && !zstr(val)) { profile->enable_chat_api_proto = switch_true(val); + } else if (!strcasecmp(var, "enable-uservars-namespace") && !zstr(val)) { + /* Only a recognised negative turns this off, so a value + * neither side spells correctly keeps the prefix. */ + profile->enable_uservars_namespace = !switch_false(val); } else if (!strcasecmp(var, "userauth") && !zstr(val)) { profile->userauth = switch_core_strdup(profile->pool, val); } else if (!strcasecmp(var, "chop-domain") && !zstr(val)) { diff --git a/src/mod/endpoints/mod_verto/mod_verto.h b/src/mod/endpoints/mod_verto/mod_verto.h index e565447e7b..7d035ff6db 100644 --- a/src/mod/endpoints/mod_verto/mod_verto.h +++ b/src/mod/endpoints/mod_verto/mod_verto.h @@ -248,6 +248,7 @@ struct verto_profile_s { int in_thread; int blind_reg; int enable_chat_api_proto; + int enable_uservars_namespace; char *userauth; char *root_passwd;