diff --git a/UPGRADE.txt b/UPGRADE.txt index a654865fae..289043896d 100644 --- a/UPGRADE.txt +++ b/UPGRADE.txt @@ -92,7 +92,8 @@ chan_unistim users.conf: - A defined user with hasvoicemail=yes now finally uses a Gosub to stdexten as documented in extensions.conf.sample since v1.6.0 instead of a Macro as - documented in v1.4. + documented in v1.4. Set the asterisk.conf stdexten=macro parameter to + invoke the stdexten the old way. From 1.8 to 10: diff --git a/configs/asterisk.conf.sample b/configs/asterisk.conf.sample index cc9933044a..44f3c1deae 100644 --- a/configs/asterisk.conf.sample +++ b/configs/asterisk.conf.sample @@ -74,6 +74,12 @@ documentation_language = en_US ; Set the language you want documentation ;lockconfdir = no ; Protect the directory containing the ; configuration files (/etc/asterisk) with a ; lock. +;stdexten = gosub ; How to invoke the extensions.conf stdexten. + ; macro - Invoke the stdexten using a macro as + ; done by legacy Asterisk versions. + ; gosub - Invoke the stdexten using a gosub as + ; documented in extensions.conf.sample. + ; Default gosub. ; Changing the following lines may compromise your security. ;[files] diff --git a/include/asterisk/options.h b/include/asterisk/options.h index 2509f46429..c411b3aade 100644 --- a/include/asterisk/options.h +++ b/include/asterisk/options.h @@ -58,6 +58,8 @@ enum ast_option_flags { AST_OPT_FLAG_FULLY_BOOTED = (1 << 9), /*! Trascode via signed linear */ AST_OPT_FLAG_TRANSCODE_VIA_SLIN = (1 << 10), + /*! Invoke the stdexten using the legacy macro method. */ + AST_OPT_FLAG_STDEXTEN_MACRO = (1 << 11), /*! Dump core on a seg fault */ AST_OPT_FLAG_DUMP_CORE = (1 << 12), /*! Cache sound files */ @@ -116,6 +118,8 @@ enum ast_option_flags { #define ast_opt_no_color ast_test_flag(&ast_options, AST_OPT_FLAG_NO_COLOR) #define ast_fully_booted ast_test_flag(&ast_options, AST_OPT_FLAG_FULLY_BOOTED) #define ast_opt_transcode_via_slin ast_test_flag(&ast_options, AST_OPT_FLAG_TRANSCODE_VIA_SLIN) +/*! Invoke the stdexten using the legacy macro method. */ +#define ast_opt_stdexten_macro ast_test_flag(&ast_options, AST_OPT_FLAG_STDEXTEN_MACRO) #define ast_opt_dump_core ast_test_flag(&ast_options, AST_OPT_FLAG_DUMP_CORE) #define ast_opt_cache_record_files ast_test_flag(&ast_options, AST_OPT_FLAG_CACHE_RECORD_FILES) #define ast_opt_timestamp ast_test_flag(&ast_options, AST_OPT_FLAG_TIMESTAMP) diff --git a/main/asterisk.c b/main/asterisk.c index 19982b6e23..5f6449c925 100644 --- a/main/asterisk.c +++ b/main/asterisk.c @@ -3230,6 +3230,18 @@ static void ast_readconfig(void) ast_set2_flag(&ast_options, ast_true(v->value), AST_OPT_FLAG_HIDE_CONSOLE_CONNECT); } else if (!strcasecmp(v->name, "lockconfdir")) { ast_set2_flag(&ast_options, ast_true(v->value), AST_OPT_FLAG_LOCK_CONFIG_DIR); + } else if (!strcasecmp(v->name, "stdexten")) { + /* Choose how to invoke the extensions.conf stdexten */ + if (!strcasecmp(v->value, "gosub")) { + ast_clear_flag(&ast_options, AST_OPT_FLAG_STDEXTEN_MACRO); + } else if (!strcasecmp(v->value, "macro")) { + ast_set_flag(&ast_options, AST_OPT_FLAG_STDEXTEN_MACRO); + } else { + ast_log(LOG_WARNING, + "'%s' is not a valid setting for the stdexten option, defaulting to 'gosub'\n", + v->value); + ast_clear_flag(&ast_options, AST_OPT_FLAG_STDEXTEN_MACRO); + } } } for (v = ast_variable_browse(cfg, "compat"); v; v = v->next) { diff --git a/pbx/pbx_config.c b/pbx/pbx_config.c index 86b1322792..22ea1d7107 100644 --- a/pbx/pbx_config.c +++ b/pbx/pbx_config.c @@ -1753,8 +1753,14 @@ static void pbx_load_users(void) ast_add_extension2(con, 0, cat, -1, NULL, NULL, iface, NULL, NULL, registrar); /* If voicemail, use "stdexten" else use plain old dial */ if (hasvoicemail) { - snprintf(tmp, sizeof(tmp), "%s,stdexten(${HINT})", cat); - ast_add_extension2(con, 0, cat, 1, NULL, NULL, "Gosub", ast_strdup(tmp), ast_free_ptr, registrar); + if (ast_opt_stdexten_macro) { + /* Use legacy stdexten macro method. */ + snprintf(tmp, sizeof(tmp), "stdexten,%s,${HINT}", cat); + ast_add_extension2(con, 0, cat, 1, NULL, NULL, "Macro", ast_strdup(tmp), ast_free_ptr, registrar); + } else { + snprintf(tmp, sizeof(tmp), "%s,stdexten(${HINT})", cat); + ast_add_extension2(con, 0, cat, 1, NULL, NULL, "Gosub", ast_strdup(tmp), ast_free_ptr, registrar); + } } else { ast_add_extension2(con, 0, cat, 1, NULL, NULL, "Dial", ast_strdup("${HINT}"), ast_free_ptr, registrar); }