Better fallback method for autosystemname.
authorJason Parker <jparker@digium.com>
Fri, 11 May 2007 21:15:30 +0000 (21:15 +0000)
committerJason Parker <jparker@digium.com>
Fri, 11 May 2007 21:15:30 +0000 (21:15 +0000)
Issue 9713, patch by Juggie with minor mods by me.

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@64012 65c4cc65-6c06-0410-ace0-fbb531ad65f3

Makefile
main/asterisk.c

index ae4b046..aa7de5a 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -545,7 +545,7 @@ samples: adsi
                echo ";[options]" ; \
                echo ";internal_timing = yes" ; \
                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 ";autosystemname = yes ; automatically set systemname to hostname - uses 'localhost' on failure, or systemname if set" ; \
                echo "; Changing the following lines may compromise your security." ; \
                echo ";[files]" ; \
                echo ";astctlpermissions = 0660" ; \
index c44e2cb..a8dd93d 100644 (file)
@@ -2529,8 +2529,10 @@ static void ast_readconfig(void)
                                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));
+                                       if (!ast_strlen_zero(ast_config_AST_SYSTEM_NAME)){
+                                               ast_copy_string(ast_config_AST_SYSTEM_NAME, "localhost", sizeof(ast_config_AST_SYSTEM_NAME));
+                                       }
+                                       ast_log(LOG_ERROR, "Cannot obtain hostname for this system.  Using '%s' instead.\n", ast_config_AST_SYSTEM_NAME);
                                }
                        }
                } else if (!strcasecmp(v->name, "languageprefix")) {