2007-10-31 07:42:56 +00:00
|
|
|
Written-by: Tomas Smetana <tsmetana@redhat.com>
|
|
|
|
Reviewed-by: Tomas Janousek <tjanouse@redhat.com>
|
|
|
|
Reviewed-by: Karel Zak <kzak@redhat.com>
|
|
|
|
|
|
|
|
--- smartmontools-5.37/smartd.cpp.addrinfo 2007-10-15 16:53:37.000000000 +0200
|
|
|
|
+++ smartmontools-5.37/smartd.cpp 2007-10-15 16:54:18.000000000 +0200
|
|
|
|
@@ -498,7 +498,28 @@
|
|
|
|
|
2007-10-12 13:25:59 +00:00
|
|
|
char* dnsdomain(const char* hostname) {
|
|
|
|
char *p = NULL;
|
2007-10-31 07:42:56 +00:00
|
|
|
-#ifdef HAVE_GETHOSTBYNAME
|
|
|
|
+#ifdef HAVE_GETADDRINFO
|
2007-10-12 13:25:59 +00:00
|
|
|
+ static char canon_name[NI_MAXHOST];
|
2007-10-31 07:42:56 +00:00
|
|
|
+ struct addrinfo *info = NULL;
|
|
|
|
+ struct addrinfo hints;
|
2007-10-12 13:25:59 +00:00
|
|
|
+ int err;
|
|
|
|
+
|
2007-10-31 07:42:56 +00:00
|
|
|
+ memset(&hints, 0, sizeof(hints));
|
|
|
|
+ hints.ai_flags = AI_CANONNAME;
|
|
|
|
+ if ((err = getaddrinfo(hostname, NULL, &hints, &info)) || (!info)) {
|
2007-10-12 13:25:59 +00:00
|
|
|
+ PrintOut(LOG_CRIT, "Error retrieving info for %s: %s\n",
|
|
|
|
+ hostname, gai_strerror(err));
|
|
|
|
+ return NULL;
|
|
|
|
+ }
|
2007-10-31 07:42:56 +00:00
|
|
|
+ if (info->ai_canonname) {
|
|
|
|
+ strncpy(canon_name, info->ai_canonname, sizeof(canon_name));
|
|
|
|
+ canon_name[NI_MAXHOST - 1] = '\0';
|
|
|
|
+ p = canon_name;
|
|
|
|
+ if((p = strchr(canon_name, '.')))
|
|
|
|
+ p++;
|
|
|
|
+ }
|
2007-10-12 13:25:59 +00:00
|
|
|
+ freeaddrinfo(info);
|
2007-10-31 07:42:56 +00:00
|
|
|
+#elif HAVE_GETHOSTBYNAME
|
|
|
|
struct hostent *hp;
|
|
|
|
|
|
|
|
if ((hp = gethostbyname(hostname))) {
|
|
|
|
@@ -506,7 +527,7 @@
|
|
|
|
// colon/dot notation? [BA]
|
|
|
|
if ((p = strchr(hp->h_name, '.')))
|
|
|
|
p++; // skip "."
|
|
|
|
- }
|
|
|
|
+ }
|
2007-10-12 13:25:59 +00:00
|
|
|
#else
|
|
|
|
ARGUSED(hostname);
|
|
|
|
#endif
|
2007-10-31 07:42:56 +00:00
|
|
|
--- smartmontools-5.37/configure.in.addrinfo 2006-12-20 21:39:25.000000000 +0100
|
|
|
|
+++ smartmontools-5.37/configure.in 2007-10-15 16:53:37.000000000 +0200
|
|
|
|
@@ -70,6 +70,7 @@
|
|
|
|
AC_CHECK_FUNCS([getopt_long])
|
|
|
|
AC_CHECK_FUNCS([getdomainname])
|
|
|
|
AC_CHECK_FUNCS([gethostname])
|
|
|
|
+AC_CHECK_FUNCS([getaddrinfo])
|
|
|
|
AC_CHECK_FUNCS([gethostbyname])
|
|
|
|
AC_CHECK_FUNCS([sigset])
|
|
|
|
AC_CHECK_FUNCS([strtoull])
|