--- watchdog-5.6.orig/watchdog.conf.5
+++ watchdog-5.6/watchdog.conf.5
@@ -76,6 +76,10 @@
 They don't neccessarily have to follow each other directly. But you cannot
 specify a 'change =' before a 'file ='.
 The default is to only stat the file and don't look for changes.
+Using this feature to monitor changes in /var/log/messages might require some
+special syslog daemon configuration, e.g. rsyslog needs
+"$ActionWriteAllMarkMessages on" to be set to make sure the marks are written
+no matter what.
 .TP
 pidfile = <pidfilename>
 Set pidfile name for server test mode.
--- watchdog-5.6.orig/src/wd_keepalive.c
+++ watchdog-5.6/src/wd_keepalive.c
@@ -138,9 +138,10 @@
     }
 
     while ( !feof(wc) ) {
-        char line[CONFIG_LINE_LEN];
+	char *line = NULL;
+	size_t n;
 
-        if ( fgets(line, CONFIG_LINE_LEN, wc) == NULL ) {
+	if (getline(&line, &n, wc) == -1) {
             if ( !ferror(wc) )
                 break;
             else {
--- watchdog-5.6.orig/src/watchdog.c
+++ watchdog-5.6/src/watchdog.c
@@ -25,6 +25,7 @@
 #include <sys/wait.h>
 #include <sys/stat.h>
 #include <sys/types.h>
+#include <sys/ioctl.h>
 #include <linux/watchdog.h>
 #define __USE_GNU
 #include <string.h>
@@ -253,9 +254,10 @@
     }
 
     while (!feof(wc)) {
-	char line[CONFIG_LINE_LEN];
+	char *line = NULL;
+	size_t n;
 
-	if (fgets(line, CONFIG_LINE_LEN, wc) == NULL) {
+	if (getline(&line, &n, wc) == -1) {
 	    if (!ferror(wc))
 		break;
 	    else {
@@ -690,7 +692,7 @@
 	       driver default) */
 	    if (ioctl(watchdog, WDIOC_SETTIMEOUT, &devtimeout) < 0) {
 #if USE_SYSLOG
-            	syslog(LOG_ERR, "cannot set timeout %s (errno = %d = '%m')", strerror(errno), devtimeout, errno);
+                syslog(LOG_ERR, "cannot set timeout %d (errno = %d = '%m')", devtimeout, errno);
 #else				
             	perror(progname);
 #endif			   
--- watchdog-5.6.orig/debian/changelog
+++ watchdog-5.6/debian/changelog
@@ -1,3 +1,66 @@
+watchdog (5.6-8~bpo50+1) lenny-backports; urgency=low
+
+  * Rebuild for lenny-backports.
+
+ -- Michael Meskes <meskes@debian.org>  Thu, 22 Oct 2009 14:13:09 +0200
+
+watchdog (5.6-8) unstable; urgency=low
+
+  * Next try in getting the dependencies right, wd_keepalive is supposed to be
+    started as early as possible to cope with system that boot with the
+    watchdog device open and watchdog is supposed to be started as late as
+    possible to be able to monitor other process. For the very same reason
+    watchdog should be stopped very early before the other process stop.
+
+ -- Michael Meskes <meskes@debian.org>  Tue, 22 Sep 2009 11:00:19 +0200
+
+watchdog (5.6-7) unstable; urgency=low
+
+  * Added rsyslog config option to watchdog.conf manpage, closes: #544671
+
+ -- Michael Meskes <meskes@debian.org>  Mon, 21 Sep 2009 13:13:26 +0200
+
+watchdog (5.6-6) unstable; urgency=low
+
+  * wd_keepalive must not be started before portmap because /usr could be nfs
+    mounted. In the process of fixing this some more dependencies were added.
+
+ -- Michael Meskes <meskes@debian.org>  Thu, 20 Aug 2009 12:29:55 +0200
+
+watchdog (5.6-5) unstable; urgency=low
+
+  * Fixed wd_keepalive init script LSB header to specify no stop level. Also
+    removed superfluous dependencies and old links, closes: #540390
+  * Also made sure that watchdog itself is stopped as early as possible. This
+    needs an insserv version that processes $all in stop lines.  Bumped
+  * Standards-Version to 3.8.3 no changes needed.
+
+ -- Michael Meskes <meskes@debian.org>  Wed, 19 Aug 2009 11:56:30 +0200
+
+watchdog (5.6-4) unstable; urgency=low
+
+  * wd_keepalive immediately terminates if no watchdog device is given,
+    therefore it cannot be stopped when starting watchdog. Make sure we do not
+    print an error in this case, closes: #533608
+  * Bumped Standards-Version to 3.8.2 no changes needed.
+  * Remove path specification from command in maintainer script.
+
+ -- Michael Meskes <meskes@debian.org>  Sun, 21 Jun 2009 10:54:23 +0200
+
+watchdog (5.6-3) unstable; urgency=low
+
+  * Prevent usage of unset variable by applying upstream patch, closes: #530843
+  * Made initscript use lsb functions.
+  * Added status argument to init script.
+
+ -- Michael Meskes <meskes@debian.org>  Thu, 28 May 2009 12:45:18 +0200
+
+watchdog (5.6-2) unstable; urgency=low
+
+  * Accept config lines with arbitrary length, closes: #529891
+
+ -- Michael Meskes <meskes@debian.org>  Mon, 25 May 2009 02:54:51 +0200
+
 watchdog (5.6-1) unstable; urgency=low
 
   * New upstream version, closes: #517419
--- watchdog-5.6.orig/debian/init
+++ watchdog-5.6/debian/init
@@ -4,8 +4,10 @@
 ### BEGIN INIT INFO
 # Provides:          watchdog
 # Short-Description: Start software watchdog daemon
-# Required-Start:    $local_fs $remote_fs $syslog
-# Required-Stop:     $local_fs $remote_fs $syslog
+# Required-Start:    $all
+# Required-Stop:     $all
+# Should-Start:      
+# Should-Stop:       
 # Default-Start:     2 3 4 5
 # Default-Stop:      0 1 6
 ### END INIT INFO
@@ -34,6 +36,9 @@
 DAEMON=/usr/sbin/watchdog
 WD_DAEMON=/usr/sbin/wd_keepalive
 
+# Get lsb functions
+. /lib/lsb/init-functions
+
 case "$1" in
   start)
     if [ $run_watchdog = 1 ]
@@ -41,47 +46,37 @@
     	# do we have to load a module?
 	[ ${watchdog_module:-none} != "none" ] && /sbin/modprobe $watchdog_module
 	# make sure that wd_keepalive is stopped
-	echo -n "Stopping watchdog keepalive daemon: "
-        if start-stop-daemon --stop --quiet \
+	log_begin_msg "Stopping watchdog keepalive daemon..."
+        start-stop-daemon --stop --quiet -oknodo \
             --pidfile  /var/run/$WD_NAME.pid
-        then
-            echo wd_keepalive.
-        else
-            echo
-        fi
-
-	echo -n "Starting watchdog daemon: "
-	if start-stop-daemon --start --quiet \
-	    --exec $DAEMON -- $watchdog_options
-	then
-	    echo watchdog.
-	else
-	    echo
-	fi
+        log_end_msg $?
+
+	sleep 5
+	# Unconditionally start watchdog daemon because we want to run it even
+	# if wd_keepalive wasn't running
+	log_begin_msg "Starting watchdog daemon..."
+	start-stop-daemon --start --quiet \
+             --exec $DAEMON -- $watchdog_options
+	log_end_msg $?
     fi
     ;;
 
   stop)
     if [ $run_watchdog = 1 ]
     then
-	echo -n "Stopping watchdog daemon: "
+	log_begin_msg "Stopping watchdog daemon..."
 	if start-stop-daemon --stop --quiet \
 	    --pidfile /var/run/$NAME.pid
 	then
-	    echo watchdog.
+	    log_end_msg $?
 
+	    sleep 5
 	    # make sure that wd_keepalive is started
-	    echo -n "Starting watchdog keepalive daemon: "
-            if start-stop-daemon --start --quiet \
+	    log_begin_msg "Starting watchdog keepalive daemon..."
+            start-stop-daemon --start --quiet \
 		--exec $WD_DAEMON -- $watchdog_options
-            then
-		echo wd_keepalive.
-            else
-		echo
-            fi
-	else
-	    echo
 	fi
+	log_end_msg $?
     fi
     ;;
 
@@ -91,22 +86,20 @@
 
   force-reload)
     if [ $run_watchdog = 0 ]; then exit 0; fi
-    echo -n "Restarting $NAME daemon."
+    log_begin_msg "Restarting $NAME daemon..."
     start-stop-daemon --stop --quiet --pidfile /var/run/$NAME.pid
-    echo -n "."
     sleep 5
-    echo -n "."
-    if start-stop-daemon --start --quiet --pidfile /var/run/$NAME.pid \
+    start-stop-daemon --start --quiet --pidfile /var/run/$NAME.pid \
 	--exec $DAEMON -- $watchdog_options
-    then
-	echo "done."
-    else
-	echo
-    fi
+    log_end_msg $?
+    ;;
+
+  status)
+    status_of_proc "$DAEMON" watchdog
     ;;
 
   *)
-    echo "Usage: /etc/init.d/watchdog {start|stop|restart|force-reload}"
+    echo "Usage: /etc/init.d/watchdog {start|stop|restart|force-reload|status}"
     exit 1
 
 esac
--- watchdog-5.6.orig/debian/control
+++ watchdog-5.6/debian/control
@@ -3,12 +3,12 @@
 Priority: extra
 Maintainer: Michael Meskes <meskes@debian.org>
 Build-Depends: debhelper (>= 5), po-debconf (>= 0.5.0)
-Standards-Version: 3.8.1
+Standards-Version: 3.8.3
 Homepage: http://watchdog.sourceforge.net
 
 Package: watchdog
 Architecture: any
-Depends: ${shlibs:Depends}, ${misc:Depends}, makedev (>= 2.3.1-24) | udev
+Depends: ${shlibs:Depends}, ${misc:Depends}, makedev (>= 2.3.1-24) | udev, lsb-base (>= 3.2-14)
 Description: A software watchdog
  The watchdog program writes to /dev/watchdog every ten seconds.  If
  the device is opened but not written to within a minute, the machine
--- watchdog-5.6.orig/debian/wd_keepalive.init
+++ watchdog-5.6/debian/wd_keepalive.init
@@ -4,10 +4,11 @@
 ### BEGIN INIT INFO
 # Provides:          wd_keepalive
 # Short-Description: Start watchdog keepalive daemon
-# Required-Start:    $local_fs $remote_fs $syslog
-# Required-Stop:     $local_fs $remote_fs $syslog
+# Required-Start:    $remote_fs
+# Required-Stop:     $remote_fs
+# X-Start-Before:    $all
 # Default-Start:     2 3 4 5
-# Default-Stop:      0 1 6
+# Default-Stop:      
 ### END INIT INFO
 
 PATH=/bin:/usr/bin:/sbin:/usr/sbin
--- watchdog-5.6.orig/debian/postinst
+++ watchdog-5.6/debian/postinst
@@ -6,17 +6,17 @@
 then
     . /usr/share/debconf/confmodule
 
-    if [ -x /sbin/MAKEDEV ]; then
+    if [ -x `which MAKEDEV` ]; then
 	    # do we have to create the device?
 	    if [ ! -c /dev/watchdog ]
 	    then
-		(cd /dev; /sbin/MAKEDEV misc || true)
+		(cd /dev; MAKEDEV misc || true)
 	    fi
 
 	    # do we have to create the temperature device?
 	    if [ ! -c /dev/temperature ]
 	    then
-		(cd /dev; /sbin/MAKEDEV misc || true)
+		(cd /dev; MAKEDEV misc || true)
 	    fi
     fi
 
@@ -115,6 +115,16 @@
 		update-rc.d -f wd_keepalive remove
 	fi
 fi
+
+if dpkg --compare-versions "$2" lt 5.6-5
+then
+	if [ -f /var/lib/insserv/using-insserv ]; then
+		rm -f /etc/rc0.d/K*wd_keepalive
+		rm -f /etc/rc1.d/K*wd_keepalive
+		rm -f /etc/rc6.d/K*wd_keepalive
+	fi
+fi
+
 # Not automatically added by dh_installinit (--noscripts)
 update-rc.d watchdog defaults 89 11 >/dev/null
 update-rc.d wd_keepalive start 09 2 3 4 5 . >/dev/null
