From defdbf0d17b300a11f5e842656cd5fe7e02a4c4d Mon Sep 17 00:00:00 2001 From: Sebastian Harl Date: Fri, 25 Dec 2009 09:57:41 +0100 Subject: [PATCH] patches: Added bts557599_powerdns_fix.dpatch. This patch fixes communication to pdns versions 2.9.22 and above. Thanks to for reporting this and Luke Heberling for providing the patch! Closes: #557599 This patch was provided in #535787 as well, but did not get applied to 4.8.1. --- debian/changelog | 5 +- debian/patches/00list | 1 + debian/patches/bts557599_powerdns_fix.dpatch | 73 ++++++++++++++++++++ 3 files changed, 78 insertions(+), 1 deletion(-) create mode 100644 debian/patches/bts557599_powerdns_fix.dpatch diff --git a/debian/changelog b/debian/changelog index 2d09b17..06ea04b 100644 --- a/debian/changelog +++ b/debian/changelog @@ -40,6 +40,9 @@ collectd (4.8.2-1) unstable; urgency=low - Added bts561577_collectd2html_recursive_fix.dpatch -- fixed collectd2html.pl's recursive mode and improved some defaults; thanks to Yuri D'Elia for reporting this and providing a patch (Closes: #561577). + - Added bts557599_powerdns_fix.dpatch -- fixed communication to pdns + versions 2.9.22 and above; thanks to for reporting this + and Luke Heberling for providing the patch (Closes: #557599). * debian/rules: - Pass --without-included-ltdl to configure to tell libtool 2 to not use the shipped libltdl but rather the one available in the system. @@ -51,7 +54,7 @@ collectd (4.8.2-1) unstable; urgency=low * debian/README.Debian: - Added a short explanation of the package split. - -- Sebastian Harl Fri, 25 Dec 2009 09:42:42 +0100 + -- Sebastian Harl Fri, 25 Dec 2009 09:55:21 +0100 collectd (4.8.1-2) unstable; urgency=low diff --git a/debian/patches/00list b/debian/patches/00list index 0c322da..25c8ff1 100644 --- a/debian/patches/00list +++ b/debian/patches/00list @@ -1,4 +1,5 @@ rrd_filter_path.dpatch collection_conf_path.dpatch bts561577_collectd2html_recursive_fix.dpatch +bts557599_powerdns_fix.dpatch diff --git a/debian/patches/bts557599_powerdns_fix.dpatch b/debian/patches/bts557599_powerdns_fix.dpatch new file mode 100644 index 0000000..72b26c9 --- /dev/null +++ b/debian/patches/bts557599_powerdns_fix.dpatch @@ -0,0 +1,73 @@ +#! /bin/sh /usr/share/dpatch/dpatch-run +## bts557599_powerdns_fix.dpatch by Luke Heberling +## +## DP: powerdns plugin: Fixed communication when talking to pdns 2.9.22. +## DP: +## DP: powerdns version 2.9.22 (and above) require a newline at the end of +## DP: commands sent to the server. + +@DPATCH@ + +diff a/src/powerdns.c b/src/powerdns.c +--- a/src/powerdns.c ++++ b/src/powerdns.c +@@ -46,12 +46,12 @@ + #define FUNC_ERROR(func) do { char errbuf[1024]; ERROR ("powerdns plugin: %s failed: %s", func, sstrerror (errno, errbuf, sizeof (errbuf))); } while (0) + + #define SERVER_SOCKET LOCALSTATEDIR"/run/pdns.controlsocket" +-#define SERVER_COMMAND "SHOW *" ++#define SERVER_COMMAND "SHOW * \n" + + #define RECURSOR_SOCKET LOCALSTATEDIR"/run/pdns_recursor.controlsocket" + #define RECURSOR_COMMAND "get noerror-answers nxdomain-answers " \ + "servfail-answers sys-msec user-msec qa-latency cache-entries cache-hits " \ +- "cache-misses questions" ++ "cache-misses questions\n" + + struct list_item_s; + typedef struct list_item_s list_item_t; +@@ -437,6 +437,11 @@ static int powerdns_get_data_stream (lis + return (-1); + } + ++ struct timeval timeout; ++ timeout.tv_sec=5; ++ timeout.tv_usec=0; ++ status = setsockopt (sd, SOL_SOCKET, SO_RCVTIMEO, &timeout, sizeof (timeout)); ++ + status = connect (sd, (struct sockaddr *) &item->sockaddr, + sizeof (item->sockaddr)); + if (status != 0) +@@ -529,7 +534,7 @@ static int powerdns_read_server (list_it + int fields_num; + + if (item->command == NULL) +- item->command = strdup ("SHOW *"); ++ item->command = strdup (SERVER_COMMAND); + if (item->command == NULL) + { + ERROR ("powerdns plugin: strdup failed."); +@@ -610,7 +615,7 @@ static int powerdns_update_recursor_comm + else + { + sstrncpy (buffer, "get ", sizeof (buffer)); +- status = strjoin (&buffer[4], sizeof (buffer) - strlen ("get "), ++ status = strjoin (&buffer[strlen("get ")], sizeof (buffer) - strlen ("get "), + li->fields, li->fields_num, + /* seperator = */ " "); + if (status < 0) +@@ -618,6 +623,14 @@ static int powerdns_update_recursor_comm + ERROR ("powerdns plugin: strjoin failed."); + return (-1); + } ++ buffer[sizeof (buffer) - 1] = 0; ++ int i = strlen (buffer); ++ if (i < sizeof (buffer) - 2) ++ { ++ buffer[i++] = ' '; ++ buffer[i++] = '\n'; ++ buffer[i++] = '\0'; ++ } + } + + buffer[sizeof (buffer) - 1] = 0; -- 2.30.2