Skip to content
Snippets Groups Projects
Commit a693e4d5 authored by Jason Parker's avatar Jason Parker
Browse files

Add autosystemname setting to asterisk.conf

When enabled, it will set the systemname to be the hostname of the system

Issue 9713, patch by Juggie - slightly modified by me, to "failover" to localhost


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@63967 65c4cc65-6c06-0410-ace0-fbb531ad65f3
parent a795ea58
No related branches found
No related tags found
No related merge requests found
...@@ -545,6 +545,7 @@ samples: adsi ...@@ -545,6 +545,7 @@ samples: adsi
echo ";[options]" ; \ echo ";[options]" ; \
echo ";internal_timing = yes" ; \ echo ";internal_timing = yes" ; \
echo ";systemname = my_system_name ; prefix uniqueid with a system name for global uniqueness issues" ; \ echo ";systemname = my_system_name ; prefix uniqueid with a system name for global uniqueness issues" ; \
echo ";autosystemname = yes ; automatically set systemname to hostname - uses 'localhost' on failure" ; \
echo "; Changing the following lines may compromise your security." ; \ echo "; Changing the following lines may compromise your security." ; \
echo ";[files]" ; \ echo ";[files]" ; \
echo ";astctlpermissions = 0660" ; \ echo ";astctlpermissions = 0660" ; \
......
...@@ -2374,6 +2374,7 @@ static void ast_readconfig(void) ...@@ -2374,6 +2374,7 @@ static void ast_readconfig(void)
struct ast_config *cfg; struct ast_config *cfg;
struct ast_variable *v; struct ast_variable *v;
char *config = AST_CONFIG_FILE; char *config = AST_CONFIG_FILE;
char hostname[MAXHOSTNAMELEN] = "";
if (ast_opt_override_config) { if (ast_opt_override_config) {
cfg = ast_config_load(ast_config_AST_CONFIG_FILE); cfg = ast_config_load(ast_config_AST_CONFIG_FILE);
...@@ -2523,6 +2524,15 @@ static void ast_readconfig(void) ...@@ -2523,6 +2524,15 @@ static void ast_readconfig(void)
ast_copy_string(ast_config_AST_RUN_GROUP, v->value, sizeof(ast_config_AST_RUN_GROUP)); ast_copy_string(ast_config_AST_RUN_GROUP, v->value, sizeof(ast_config_AST_RUN_GROUP));
} else if (!strcasecmp(v->name, "systemname")) { } else if (!strcasecmp(v->name, "systemname")) {
ast_copy_string(ast_config_AST_SYSTEM_NAME, v->value, sizeof(ast_config_AST_SYSTEM_NAME)); ast_copy_string(ast_config_AST_SYSTEM_NAME, v->value, sizeof(ast_config_AST_SYSTEM_NAME));
} else if (!strcasecmp(v->name, "autosystemname")) {
if (ast_true(v->value)) {
if (!gethostname(hostname, sizeof(hostname) - 1))
ast_copy_string(ast_config_AST_SYSTEM_NAME, hostname, sizeof(ast_config_AST_SYSTEM_NAME));
else {
ast_log(LOG_ERROR, "Cannot obtain hostname for this system. Using 'localhost' instead.\n");
ast_copy_string(ast_config_AST_SYSTEM_NAME, "localhost", sizeof(ast_config_AST_SYSTEM_NAME));
}
}
} else if (!strcasecmp(v->name, "languageprefix")) { } else if (!strcasecmp(v->name, "languageprefix")) {
ast_language_is_prefix = ast_true(v->value); ast_language_is_prefix = ast_true(v->value);
#if defined(HAVE_SYSINFO) #if defined(HAVE_SYSINFO)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment