diff --git a/smartd-conf.py b/smartd-conf.py index c7a4d61..271efdc 100755 --- a/smartd-conf.py +++ b/smartd-conf.py @@ -87,7 +87,7 @@ for drive in drives: if float(getfile("/sys/module/libata/version")) < 1.20: comment = "# not yet supported in this kernel version\n# " if not comment: - status = os.system("/usr/sbin/smartctl -s on -i %s%s 2>&1 >/dev/null" % + status = os.system("/usr/sbin/smartctl -s on -i %s %s 2>&1 >/dev/null" % (driver, drive.device)) if not os.WIFEXITED(status) or os.WEXITSTATUS(status) != 0: comment = "# smartctl -i returns error for this drive\n# " diff --git a/smartmontools-5.37-addrinfo.patch b/smartmontools-5.37-addrinfo.patch index 2d3df45..1d01d6b 100644 --- a/smartmontools-5.37-addrinfo.patch +++ b/smartmontools-5.37-addrinfo.patch @@ -1,38 +1,55 @@ ---- 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 @@ +Written-by: Tomas Smetana +Reviewed-by: Tomas Janousek +Reviewed-by: Karel Zak + +--- 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 @@ + 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. */ +-#ifdef HAVE_GETHOSTBYNAME ++#ifdef HAVE_GETADDRINFO + static char canon_name[NI_MAXHOST]; -+ struct addrinfo *info; ++ struct addrinfo *info = NULL; ++ struct addrinfo hints; + int err; + -+ if (err = getaddrinfo(hostname, NULL, NULL, &info)) { ++ memset(&hints, 0, sizeof(hints)); ++ hints.ai_flags = AI_CANONNAME; ++ if ((err = getaddrinfo(hostname, NULL, &hints, &info)) || (!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; - } ++ 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++; ++ } + freeaddrinfo(info); -+ p = canon_name; -+ if ((p = strchr(p, '.'))) -+ p++; ++#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 "." +- } ++ } #else ARGUSED(hostname); #endif +--- 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]) diff --git a/smartmontools.spec b/smartmontools.spec index c88c88e..e190fd5 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: 7%{?dist} +Release: 8%{?dist} Epoch: 1 Group: System Environment/Base License: GPLv2+ @@ -45,6 +45,7 @@ the /etc/smartd.conf configuration file. %patch3 -p1 -b .addrinfo %build +./autogen.sh %configure make CFLAGS="$RPM_OPT_FLAGS -fpie" LDFLAGS="-fpie -Wl,-z,relro,-z,now" @@ -93,6 +94,12 @@ exit 0 %exclude %{_sbindir}/smartd-conf.py[co] %changelog +* Wed Oct 31 2007 Tomas Smetana - 1:5.37-8 +- fix #359561 - typo in smartd-conf.py causes smartd to skip all disks + +* Mon Oct 15 2007 Tomas Smetana - 1:5.37-7.1 +- improved patch for getaddrinfo + * Fri Oct 12 2007 Tomas Smetana - 1:5.37-7 - replace gethostbyname with getaddrinfo