From 658bb27ff49ceb20a3225214fd16207fee2b4c80 Mon Sep 17 00:00:00 2001 From: Tomas Smetana Date: Fri, 12 Oct 2007 13:25:59 +0000 Subject: [PATCH] - replace gethostbyname with getaddrinfo --- smartmontools-5.37-addrinfo.patch | 38 +++++++++++++++++++++++++++++++ smartmontools.spec | 7 +++++- 2 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 smartmontools-5.37-addrinfo.patch diff --git a/smartmontools-5.37-addrinfo.patch b/smartmontools-5.37-addrinfo.patch new file mode 100644 index 0000000..2d3df45 --- /dev/null +++ b/smartmontools-5.37-addrinfo.patch @@ -0,0 +1,38 @@ +--- smartmontools-5.37/smartd.cpp.addrinfo 2007-10-12 13:09:55.000000000 +0200 ++++ smartmontools-5.37/smartd.cpp 2007-10-12 13:11:41.000000000 +0200 +@@ -499,14 +499,28 @@ + char* dnsdomain(const char* hostname) { + char *p = NULL; + #ifdef HAVE_GETHOSTBYNAME +- struct hostent *hp; +- +- if ((hp = gethostbyname(hostname))) { +- // Does this work if gethostbyname() returns an IPv6 name in +- // colon/dot notation? [BA] +- if ((p = strchr(hp->h_name, '.'))) +- p++; // skip "." ++ /* This is a Fedora specific patch. We KNOW that there is getaddrinfo ++ * and getnameinfo. This part is not portable. */ ++ static char canon_name[NI_MAXHOST]; ++ struct addrinfo *info; ++ int err; ++ ++ if (err = getaddrinfo(hostname, NULL, NULL, &info)) { ++ PrintOut(LOG_CRIT, "Error retrieving info for %s: %s\n", ++ hostname, gai_strerror(err)); ++ return NULL; ++ } ++ canon_name[0] = '\0'; ++ if (err = getnameinfo(info->ai_addr, sizeof(struct sockaddr), ++ canon_name, sizeof(canon_name), NULL, 0, 0)) { ++ PrintOut(LOG_CRIT, "Error retrieving name info for %s: %s\n", ++ hostname, gai_strerror(err)); ++ return NULL; + } ++ freeaddrinfo(info); ++ p = canon_name; ++ if ((p = strchr(p, '.'))) ++ p++; + #else + ARGUSED(hostname); + #endif diff --git a/smartmontools.spec b/smartmontools.spec index b96f980..c88c88e 100644 --- a/smartmontools.spec +++ b/smartmontools.spec @@ -1,7 +1,7 @@ Summary: Tools for monitoring SMART capable hard disks Name: smartmontools Version: 5.37 -Release: 6%{?dist} +Release: 7%{?dist} Epoch: 1 Group: System Environment/Base License: GPLv2+ @@ -12,6 +12,7 @@ Source2: smartd-conf.py Source3: smartmontools.sysconf Patch1: smartmontools-5.37-cloexec.patch Patch2: smartmontools-5.37-3ware.patch +Patch3: smartmontools-5.37-addrinfo.patch BuildRoot: %{_tmppath}/%{name}-%{version}-root PreReq: /sbin/chkconfig /sbin/service @@ -41,6 +42,7 @@ the /etc/smartd.conf configuration file. %setup -q %patch1 -p1 -b .cloexec %patch2 -p1 -b .3ware +%patch3 -p1 -b .addrinfo %build %configure @@ -91,6 +93,9 @@ exit 0 %exclude %{_sbindir}/smartd-conf.py[co] %changelog +* Fri Oct 12 2007 Tomas Smetana - 1:5.37-7 +- replace gethostbyname with getaddrinfo + * Tue Sep 04 2007 Tomas Smetana - 1:5.37-6 - fix #271741 - smartd-conf.py should allow customization of parameters - fix #253753 - service starting by default, perhaps shouldn't