--- shell.c.orig 2014-06-08 08:47:53 -0300 +++ shell.c 2014-06-08 14:13:04 -0300 @@ -22,6 +22,7 @@ Birthdate: Sunday, January 10th, 1988. Initial author: Brian Fox + Contributors: Renato Silva */ #define INSTALL_DEBUG_MODE @@ -37,6 +38,7 @@ #include #include #include +#include #include "filecntl.h" #include @@ -1694,6 +1696,8 @@ shell_initialize () { char hostname[256]; + struct addrinfo *addr_info; + struct addrinfo addr_hints; /* Line buffer output for stderr and stdout. */ if (shell_initialized == 0) @@ -1717,10 +1721,17 @@ if (current_host_name == 0) { /* Initialize current_host_name. */ - if (gethostname (hostname, 255) < 0) - current_host_name = "??host??"; + memset(&addr_hints, 0, sizeof(struct addrinfo)); + addr_hints.ai_flags = AI_CANONNAME; + + if (gethostname (hostname, 255) >= 0) + { + if (getaddrinfo (hostname, NULL, &addr_hints, &addr_info) == 0) + strncpy (hostname, addr_info->ai_canonname, 255); + current_host_name = savestring (hostname); + } else - current_host_name = savestring (hostname); + current_host_name = "??host??"; } /* Initialize the stuff in current_user that comes from the password