- fix #359561 - typo in smartd-conf.py causes smartd to skip all disks

This commit is contained in:
Tomas Smetana 2007-10-31 07:42:56 +00:00
parent c878d0ab97
commit 72569964ad
3 changed files with 51 additions and 27 deletions

View File

@ -87,7 +87,7 @@ for drive in drives:
if float(getfile("/sys/module/libata/version")) < 1.20: if float(getfile("/sys/module/libata/version")) < 1.20:
comment = "# not yet supported in this kernel version\n# " comment = "# not yet supported in this kernel version\n# "
if not comment: 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)) (driver, drive.device))
if not os.WIFEXITED(status) or os.WEXITSTATUS(status) != 0: if not os.WIFEXITED(status) or os.WEXITSTATUS(status) != 0:
comment = "# smartctl -i returns error for this drive\n# " comment = "# smartctl -i returns error for this drive\n# "

View File

@ -1,38 +1,55 @@
--- smartmontools-5.37/smartd.cpp.addrinfo 2007-10-12 13:09:55.000000000 +0200 Written-by: Tomas Smetana <tsmetana@redhat.com>
+++ smartmontools-5.37/smartd.cpp 2007-10-12 13:11:41.000000000 +0200 Reviewed-by: Tomas Janousek <tjanouse@redhat.com>
@@ -499,14 +499,28 @@ 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 @@
char* dnsdomain(const char* hostname) { char* dnsdomain(const char* hostname) {
char *p = NULL; char *p = NULL;
#ifdef HAVE_GETHOSTBYNAME -#ifdef HAVE_GETHOSTBYNAME
- struct hostent *hp; +#ifdef HAVE_GETADDRINFO
-
- 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]; + static char canon_name[NI_MAXHOST];
+ struct addrinfo *info; + struct addrinfo *info = NULL;
+ struct addrinfo hints;
+ int err; + 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", + PrintOut(LOG_CRIT, "Error retrieving info for %s: %s\n",
+ hostname, gai_strerror(err)); + hostname, gai_strerror(err));
+ return NULL; + return NULL;
+ } + }
+ canon_name[0] = '\0'; + if (info->ai_canonname) {
+ if (err = getnameinfo(info->ai_addr, sizeof(struct sockaddr), + strncpy(canon_name, info->ai_canonname, sizeof(canon_name));
+ canon_name, sizeof(canon_name), NULL, 0, 0)) { + canon_name[NI_MAXHOST - 1] = '\0';
+ PrintOut(LOG_CRIT, "Error retrieving name info for %s: %s\n", + p = canon_name;
+ hostname, gai_strerror(err)); + if((p = strchr(canon_name, '.')))
+ return NULL; + p++;
} + }
+ freeaddrinfo(info); + freeaddrinfo(info);
+ p = canon_name; +#elif HAVE_GETHOSTBYNAME
+ if ((p = strchr(p, '.'))) struct hostent *hp;
+ p++;
if ((hp = gethostbyname(hostname))) {
@@ -506,7 +527,7 @@
// colon/dot notation? [BA]
if ((p = strchr(hp->h_name, '.')))
p++; // skip "."
- }
+ }
#else #else
ARGUSED(hostname); ARGUSED(hostname);
#endif #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])

View File

@ -1,7 +1,7 @@
Summary: Tools for monitoring SMART capable hard disks Summary: Tools for monitoring SMART capable hard disks
Name: smartmontools Name: smartmontools
Version: 5.37 Version: 5.37
Release: 7%{?dist} Release: 8%{?dist}
Epoch: 1 Epoch: 1
Group: System Environment/Base Group: System Environment/Base
License: GPLv2+ License: GPLv2+
@ -45,6 +45,7 @@ the /etc/smartd.conf configuration file.
%patch3 -p1 -b .addrinfo %patch3 -p1 -b .addrinfo
%build %build
./autogen.sh
%configure %configure
make CFLAGS="$RPM_OPT_FLAGS -fpie" LDFLAGS="-fpie -Wl,-z,relro,-z,now" 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] %exclude %{_sbindir}/smartd-conf.py[co]
%changelog %changelog
* Wed Oct 31 2007 Tomas Smetana <tsmetana@redhat.com> - 1:5.37-8
- fix #359561 - typo in smartd-conf.py causes smartd to skip all disks
* Mon Oct 15 2007 Tomas Smetana <tsmetana@redhat.com> - 1:5.37-7.1
- improved patch for getaddrinfo
* Fri Oct 12 2007 Tomas Smetana <tsmetana@redhat.com> - 1:5.37-7 * Fri Oct 12 2007 Tomas Smetana <tsmetana@redhat.com> - 1:5.37-7
- replace gethostbyname with getaddrinfo - replace gethostbyname with getaddrinfo