[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 `<variables>` 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.
This commit is contained in:
Dmitry Verenitsin committed 2026-11-19 00:09:29 +05:00
1 parent 898de5d1dd
commit 39f5977a47
3 files changed
+31 -6

No files matched your search

@@ -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+<command>. -->
<!-- <param name="enable-chat-api-proto" value="true"/> -->
<!-- login userVariables become channel variables on calls from that socket.
Their names are prefixed with verto_uvar_, which keeps them clear of the
names FreeSWITCH acts on itself. Setting this false stores them under the
names the client sent and is not recommended: it is here only for clients
and dialplan that still expect the unprefixed names. -->
<!-- <param name="enable-uservars-namespace" value="false"/> -->
<param name="mcast-ip" value="224.1.1.1"/>
<param name="mcast-port" value="1337"/>
<param name="rtp-ip" value="$${local_ip_v4}"/>
@@ -52,6 +58,7 @@
<!-- setting this to true will allow anyone to register even with no account so use with care -->
<param name="blind-reg" value="false"/>
<!-- <param name="enable-chat-api-proto" value="true"/> -->
<!-- <param name="enable-uservars-namespace" value="false"/> -->
<param name="rtp-ip" value="$${local_ip_v6}"/>
<!-- <param name="ext-rtp-ip" value=""/> -->
<param name="outbound-codec-string" value="opus,h264,vp8"/>
+23 -6
View File
@@ -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)) {
+1
View File
@@ -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;