Changeset 295 for trunk/src/sh_unix.c
- Timestamp:
- Oct 31, 2010, 10:36:04 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/sh_unix.c
r294 r295 98 98 #include "sh_hash.h" 99 99 #include "sh_tools.h" 100 #include "sh_ipvx.h" 100 101 #include "sh_tiger.h" 101 102 #include "sh_prelink.h" … … 1605 1606 { 1606 1607 struct utsname buf; 1607 struct hostent * he1;1608 1608 int i; 1609 1609 int ddot; … … 1611 1611 char * p; 1612 1612 char hostname[256]; 1613 char numeric[SH_IP_BUF]; 1614 char * canonical; 1613 1615 1614 1616 … … 1656 1658 } 1657 1659 1658 SH_MUTEX_LOCK(mutex_resolv); 1659 he1 = sh_gethostbyname(hostname); 1660 1661 if (he1 != NULL) 1662 { 1663 sl_strlcpy (sh.host.name, sh_unix_h_name(he1), SH_PATHBUF); 1664 sh_tolower (sh.host.name); 1665 } 1666 SH_MUTEX_UNLOCK(mutex_resolv); 1667 1668 if (he1 == NULL) 1669 { 1670 dlog(1, FIL__, __LINE__, 1671 _("According to uname, your nodename is %s, but your resolver\nlibrary cannot resolve this nodename to a FQDN. For more information, see the entry about self-resolving under 'Most frequently' in the FAQ that you will find in the docs/ subdirectory.\n"), 1672 hostname); 1660 canonical = sh_ipvx_canonical(hostname, numeric, sizeof(numeric)); 1661 1662 if (canonical == NULL) 1663 { 1673 1664 sl_strlcpy (sh.host.name, hostname, SH_PATHBUF); 1674 1665 sh_tolower (sh.host.name); 1675 1666 } 1676 1667 else 1668 { 1669 sl_strlcpy (sh.host.name, canonical, SH_PATHBUF); 1670 SH_FREE(canonical); 1671 } 1677 1672 1678 1673 /* check whether it looks like a FQDN … … 1683 1678 if (sh.host.name[i] == '.') ++ddot; 1684 1679 1685 if (ddot == 0 && he1 != NULL)1680 if (ddot == 0) 1686 1681 { 1687 1682 dlog(1, FIL__, __LINE__, 1688 1683 _("According to uname, your nodename is %s, but your resolver\nlibrary cannot resolve this nodename to a FQDN.\nRather, it resolves this to %s.\nFor more information, see the entry about self-resolving under\n'Most frequently' in the FAQ that you will find in the docs/ subdirectory.\n"), 1689 1684 hostname, sh.host.name); 1690 sl_strlcpy (sh.host.name, 1691 inet_ntoa (*(struct in_addr *) he1->h_addr), 1692 SH_PATHBUF); 1685 sl_strlcpy (sh.host.name, numeric, SH_PATHBUF); 1693 1686 SL_RET0(_("sh_unix_localhost")); 1694 1687 } 1695 1688 1696 if ( is_numeric(sh.host.name))1689 if (sh_ipvx_is_numeric(sh.host.name)) 1697 1690 { 1698 1691 dlog(1, FIL__, __LINE__, … … 1717 1710 struct utsname buf; 1718 1711 #endif 1719 struct hostent * he1;1720 1712 int i; 1721 1713 int ddot; 1722 1714 int len; 1723 1715 char hostname[1024]; 1724 1716 char numeric[SH_IP_BUF]; 1717 char * canonical; 1725 1718 1726 1719 SL_ENTER(_("sh_unix_localhost")); … … 1737 1730 hostname[1023] = '\0'; 1738 1731 1739 SH_MUTEX_LOCK(mutex_resolv); 1740 he1 = sh_gethostbyname(hostname); 1741 1742 if (he1 != NULL) 1743 { 1744 sl_strlcpy (sh.host.name, sh_unix_h_name(he1), SH_PATHBUF); 1732 canonical = sh_ipvx_canonical(hostname, numeric, sizeof(numeric)); 1733 1734 if (canonical == NULL) 1735 { 1736 sl_strlcpy (sh.host.name, hostname, SH_PATHBUF); 1745 1737 sh_tolower (sh.host.name); 1746 1738 } 1747 SH_MUTEX_UNLOCK(mutex_resolv); 1748 1749 if (he1 == NULL) 1750 { 1751 dlog(1, FIL__, __LINE__, 1752 _("According to gethostname, your nodename is %s, but your resolver\nlibrary cannot resolve this nodename to a FQDN.\nFor more information, see the entry about self-resolving under\n'Most frequently' in the FAQ that you will find in the docs/ subdirectory.\n"), 1753 hostname); 1754 sl_strlcpy (sh.host.name, _("localhost"), SH_PATHBUF); 1755 SL_RET0(_("sh_unix_localhost")); 1739 else 1740 { 1741 sl_strlcpy (sh.host.name, canonical, SH_PATHBUF); 1742 SH_FREE(canonical); 1756 1743 } 1757 1744 … … 1767 1754 _("According to uname, your nodename is %s, but your resolver\nlibrary cannot resolve this nodename to a FQDN.\nRather, it resolves this to %s.\nFor more information, see the entry about self-resolving under\n'Most frequently' in the FAQ that you will find in the docs/ subdirectory.\n"), 1768 1755 hostname, sh.host.name); 1769 sl_strlcpy (sh.host.name, 1770 inet_ntoa (*(struct in_addr *) he1->h_addr), 1771 SH_PATHBUF); 1756 sl_strlcpy (sh.host.name, numeric, SH_PATHBUF); 1772 1757 SL_RET0(_("sh_unix_localhost")); 1773 1758 } 1774 1759 1775 if ( is_numeric(sh.host.name))1760 if (sh_ipvx_is_numeric(sh.host.name)) 1776 1761 { 1777 1762 dlog(1, FIL__, __LINE__,
Note:
See TracChangeset
for help on using the changeset viewer.