From ebeefbbb7ed07c9bfdff7a9d818a6f43e366c096 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Wed, 6 Feb 2019 13:34:29 +0000 Subject: [PATCH] Add all upstream patches since 5.15. Fix RPC/libtirpc (again?). Remove .rhsel patch. Equivalent added upstream in 7310afccc1. --- ...param.h-for-EXEC_PAGESIZE-definition.patch | 28 +++ ...ake-watchdog-refresh-settimeout-work.patch | 153 +++++++++++++++ 0003-Ignore-build-products-in-GIT.patch | 66 +++++++ 0003-watchdog-5.13-rhsel.patch | 34 ---- ...mpile-with-musl-when-nfs-is-disabled.patch | 32 +++ 0005-Rename-READ_ENUM-to-READ_YESNO.patch | 64 ++++++ ...ake-IT87-fix-up-automatic-by-default.patch | 183 ++++++++++++++++++ 0007-Synced-Debian-files-with-5.15-2.patch | 116 +++++++++++ 0008-Fix-automated-CentOS-7-build.patch | 58 ++++++ ...atchdog-configuration-file-corruptio.patch | 101 ++++++++++ ...or-another-RPC-library-for-XDR-heade.patch | 57 ++++++ watchdog.spec | 35 +++- 12 files changed, 889 insertions(+), 38 deletions(-) create mode 100644 0001-Include-linux-param.h-for-EXEC_PAGESIZE-definition.patch create mode 100644 0002-Generalize-and-make-watchdog-refresh-settimeout-work.patch create mode 100644 0003-Ignore-build-products-in-GIT.patch delete mode 100644 0003-watchdog-5.13-rhsel.patch create mode 100644 0004-Compile-with-musl-when-nfs-is-disabled.patch create mode 100644 0005-Rename-READ_ENUM-to-READ_YESNO.patch create mode 100644 0006-Make-IT87-fix-up-automatic-by-default.patch create mode 100644 0007-Synced-Debian-files-with-5.15-2.patch create mode 100644 0008-Fix-automated-CentOS-7-build.patch create mode 100644 0009-Bugfix-against-watchdog-configuration-file-corruptio.patch create mode 100644 0010-Choose-libtirpc-or-another-RPC-library-for-XDR-heade.patch diff --git a/0001-Include-linux-param.h-for-EXEC_PAGESIZE-definition.patch b/0001-Include-linux-param.h-for-EXEC_PAGESIZE-definition.patch new file mode 100644 index 0000000..35eadf1 --- /dev/null +++ b/0001-Include-linux-param.h-for-EXEC_PAGESIZE-definition.patch @@ -0,0 +1,28 @@ +From c5cb4e1a0339844ae3f55ff1dc4a716c28012f05 Mon Sep 17 00:00:00 2001 +From: Paul Crawford +Date: Tue, 28 Jun 2016 18:08:48 +0100 +Subject: [PATCH 01/10] Include linux/param.h for EXEC_PAGESIZE definition + +Musl does not include linux/param.h whereas glibc does, so it fails +to build on musl. Patch supplied by Khem Raj +--- + src/watchdog.c | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/src/watchdog.c b/src/watchdog.c +index acf6450..486384a 100644 +--- a/src/watchdog.c ++++ b/src/watchdog.c +@@ -26,6 +26,9 @@ + #include /* For EXEC_PAGESIZE */ + #include + #include ++#ifdef __linux__ ++#include ++#endif + #include + + #include +-- +2.20.1 + diff --git a/0002-Generalize-and-make-watchdog-refresh-settimeout-work.patch b/0002-Generalize-and-make-watchdog-refresh-settimeout-work.patch new file mode 100644 index 0000000..f31af9a --- /dev/null +++ b/0002-Generalize-and-make-watchdog-refresh-settimeout-work.patch @@ -0,0 +1,153 @@ +From 00cf0b0afc7cac797713276435322aeacd6020cb Mon Sep 17 00:00:00 2001 +From: "Maciej S. Szmigiero" +Date: Fri, 16 Dec 2016 23:18:00 +0100 +Subject: [PATCH 02/10] Generalize and make watchdog refresh "settimeout" + workaround configurable + +Commit 0d156df287656 introduced a workaround for a bug in the kernel +it87_wdt driver, where on some boards the watchdog timer wasn't refreshed +correctly. The workaround was to set its timeout again every refresh. + +However, this workaround was introduced unconditionally for every user of +the it87_wdt driver. +Currently, this kernel bug is supposed to be fixed ( by kernel commit +0bcd0b6a47431 ) so let's revert to old behavior by default so we by +coincidence don't mask future bugs and also comply with the kernel watchdog +API. + +Let's also print an informational message for an user how to re-enable the +workaround in case this driver bug wasn't fixed completely or the user +has an older kernel version without the fix. + +This change also makes this workaround available generically in case +a similar problem occurs in future in some other driver. +--- + include/extern.h | 1 + + src/configfile.c | 3 +++ + src/keep_alive.c | 20 +++++++++++--------- + watchdog.conf | 3 +++ + watchdog.conf.5 | 6 ++++++ + 5 files changed, 24 insertions(+), 9 deletions(-) + +diff --git a/include/extern.h b/include/extern.h +index f00e4cf..cbf97fd 100644 +--- a/include/extern.h ++++ b/include/extern.h +@@ -91,6 +91,7 @@ extern char *logdir; + extern char *heartbeat; + extern int hbstamps; + ++extern int refresh_use_settimeout; + extern int realtime; + + extern struct list *tr_bin_list; +diff --git a/src/configfile.c b/src/configfile.c +index a0996e2..10bbc69 100644 +--- a/src/configfile.c ++++ b/src/configfile.c +@@ -28,6 +28,7 @@ static void add_test_binaries(const char *path); + #define ADMIN "admin" + #define CHANGE "change" + #define DEVICE "watchdog-device" ++#define DEVICE_USE_SETTIMEOUT "watchdog-refresh-use-settimeout" + #define DEVICE_TIMEOUT "watchdog-timeout" + #define FILENAME "file" + #define INTERFACE "interface" +@@ -95,6 +96,7 @@ char *logdir = "/var/log/watchdog"; + char *heartbeat = NULL; + int hbstamps = 300; + ++int refresh_use_settimeout = FALSE; + int realtime = FALSE; + + /* Self-repairing binaries list */ +@@ -206,6 +208,7 @@ void read_config(char *configfile) + } else if (READ_INT(LOGTICK, &logtick) == 0) { + ticker = logtick; + } else if (READ_STRING(DEVICE, &devname) == 0) { ++ } else if (READ_ENUM(DEVICE_USE_SETTIMEOUT, &refresh_use_settimeout) == 0) { + } else if (READ_INT(DEVICE_TIMEOUT, &dev_timeout) == 0) { + } else if (READ_LIST(TEMP, &temp_list) == 0) { + } else if (READ_INT(MAXTEMP, &maxtemp) == 0) { +diff --git a/src/keep_alive.c b/src/keep_alive.c +index 2f77665..a57b0b5 100644 +--- a/src/keep_alive.c ++++ b/src/keep_alive.c +@@ -29,7 +29,6 @@ + + static int watchdog_fd = -1; + static int timeout_used = TIMER_MARGIN; +-static int Refresh_using_ioctl = FALSE; + + /* + * Open the watchdog timer (if name non-NULL) and set the time-out value (if non-zero). +@@ -68,16 +67,19 @@ int open_watchdog(char *name, int timeout) + /* The IT8728 on Gigabyte motherboard (and similar) would trip due to the normal + * refresh in the device driver failing to reset the timer for no obvious reason + * (though the normal operation used the Consumer IR sender to refresh via an +- * interrupt - also a non-obvious method!) so this work-around simply sets the +- * time-out every refresh operation. ++ * interrupt - also a non-obvious method!) so let's warn users of these ++ * watchdogs and direct them to a workaround option. + * +- * See https://bugs.launchpad.net/ubuntu/+source/linux/+bug/932381 ++ * See https://bugs.launchpad.net/ubuntu/+source/linux/+bug/932381 and ++ * https://bugzilla.kernel.org/show_bug.cgi?id=42801 + * + */ +- Refresh_using_ioctl = FALSE; +- if (strcmp("IT87 WDT", (char *)ident.identity) == 0) { +- Refresh_using_ioctl = TRUE; +- log_message(LOG_INFO, "Running IT87 module fix-up"); ++ if (!refresh_use_settimeout && strcmp("IT87 WDT", (char *)ident.identity) == 0) { ++ log_message(LOG_INFO, ++ "IT87 watchdog detected, if watchdog trips by itself when the first timeout interval elapses " ++ "try updating to the latest kernel"); ++ log_message(LOG_INFO, "if this does not help please report a kernel bug (not this package bug!) " ++ "and try using watchdog-refresh-use-settimeout=yes config option as a workaround"); + } + + return rv; +@@ -163,7 +165,7 @@ int keep_alive(void) + if (watchdog_fd == -1) + return (ENOERR); + +- if (Refresh_using_ioctl) { ++ if (refresh_use_settimeout) { + int timeout = timeout_used; + if (ioctl(watchdog_fd, WDIOC_SETTIMEOUT, &timeout) < 0) { + err = errno; +diff --git a/watchdog.conf b/watchdog.conf +index 3ccdb97..dcd59ce 100644 +--- a/watchdog.conf ++++ b/watchdog.conf +@@ -29,6 +29,9 @@ + #repair-maximum = 1 + + #watchdog-device = /dev/watchdog ++# If your watchdog trips by itself when the first timeout interval elapses try ++# uncommenting the line below ++#watchdog-refresh-use-settimeout = yes + + # Defaults compiled into the binary + #temperature-sensor = +diff --git a/watchdog.conf.5 b/watchdog.conf.5 +index 5af519d..4e5155a 100644 +--- a/watchdog.conf.5 ++++ b/watchdog.conf.5 +@@ -64,6 +64,12 @@ Set the watchdog device name, typically /dev/watchdog. Default is to disable + keep alive support. This should be tested by running the daemon from the + command line before configuring it to start automatically on booting. + .TP ++watchdog-refresh-use-settimeout = ++Refresh watchdog timer by setting its timeout instead of using a normal watchdog ++refresh operation. ++Might help if your watchdog trips by itself when the first timeout interval ++elapses. ++.TP + watchdog-timeout = + Set the watchdog device timeout during startup. If not set, a default is used + that should be set to the kernel timer margin at compile time. +-- +2.20.1 + diff --git a/0003-Ignore-build-products-in-GIT.patch b/0003-Ignore-build-products-in-GIT.patch new file mode 100644 index 0000000..39af455 --- /dev/null +++ b/0003-Ignore-build-products-in-GIT.patch @@ -0,0 +1,66 @@ +From de06f50eee35e3ea0daaf77d21e8888f8d8753ad Mon Sep 17 00:00:00 2001 +From: Paul Crawford +Date: Wed, 21 Dec 2016 22:00:51 +0000 +Subject: [PATCH 03/10] Ignore build products in GIT + +- Added a .gitignore file to list those files we do not track in GIT + +- Based on pull request by Maciej S. Szmigiero: + + Currently, after doing checkout and build 'git status' on the + source tree returns a lot of untracked files. Their presence + makes it harder to spot actual tree changes, so let's make + the noise disappear from 'git status' by adding proper .gitignore + files. +--- + .gitignore | 38 ++++++++++++++++++++++++++++++++++++++ + 1 file changed, 38 insertions(+) + create mode 100644 .gitignore + +diff --git a/.gitignore b/.gitignore +new file mode 100644 +index 0000000..db2baeb +--- /dev/null ++++ b/.gitignore +@@ -0,0 +1,38 @@ ++# Ignore hidden/backup/compilation files ++ ++.* ++*.o ++*~ ++ ++# However don't ignore this file ++ ++!/.gitignore ++ ++# Ignore the build programs ++ ++src/watchdog ++src/wd_identify ++src/wd_keepalive ++ ++# Ignore remaining files create/modified by the steps: ++# autoreconf -i ++# ./configure ++# make ++ ++Makefile ++Makefile.in ++aclocal.m4 ++autom4te.cache/ ++compile ++config.log ++config.status ++configure ++depcomp ++include/config.h ++include/config.h.in ++include/stamp-h1 ++install-sh ++missing ++src/Makefile ++src/Makefile.in ++ +-- +2.20.1 + diff --git a/0003-watchdog-5.13-rhsel.patch b/0003-watchdog-5.13-rhsel.patch deleted file mode 100644 index 49a7ecd..0000000 --- a/0003-watchdog-5.13-rhsel.patch +++ /dev/null @@ -1,34 +0,0 @@ -diff -ur watchdog-5.15.old/src/test_binary.c watchdog-5.15/src/test_binary.c ---- watchdog-5.15.old/src/test_binary.c 2016-02-26 12:05:00.000000000 +0000 -+++ watchdog-5.15/src/test_binary.c 2018-02-13 08:51:27.292750445 +0000 -@@ -263,11 +263,11 @@ - * to cause trouble, so make them go to their respective files */ - strcpy(filename_buf, logdir); - strcat(filename_buf, "/test-bin.stdout"); -- if (!freopen(filename_buf, "a+", stdout)) -+ if (!freopen(filename_buf, "a", stdout)) - exit(errno); - strcpy(filename_buf, logdir); - strcat(filename_buf, "/test-bin.stderr"); -- if (!freopen(filename_buf, "a+", stderr)) -+ if (!freopen(filename_buf, "a", stderr)) - exit(errno); - - /* now start binary */ -diff -ur watchdog-5.15.old/src/watchdog.c watchdog-5.15/src/watchdog.c ---- watchdog-5.15.old/src/watchdog.c 2016-02-26 12:05:00.000000000 +0000 -+++ watchdog-5.15/src/watchdog.c 2018-02-13 08:51:43.747738628 +0000 -@@ -86,11 +86,11 @@ - * So make stdout and stderr go to their respective files */ - strcpy(filename_buf, logdir); - strcat(filename_buf, "/repair-bin.stdout"); -- if (!freopen(filename_buf, "a+", stdout)) -+ if (!freopen(filename_buf, "a", stdout)) - exit(errno); - strcpy(filename_buf, logdir); - strcat(filename_buf, "/repair-bin.stderr"); -- if (!freopen(filename_buf, "a+", stderr)) -+ if (!freopen(filename_buf, "a", stderr)) - exit(errno); - - /* now start binary */ diff --git a/0004-Compile-with-musl-when-nfs-is-disabled.patch b/0004-Compile-with-musl-when-nfs-is-disabled.patch new file mode 100644 index 0000000..9162c3f --- /dev/null +++ b/0004-Compile-with-musl-when-nfs-is-disabled.patch @@ -0,0 +1,32 @@ +From f52c40680f0aad44b9ae16648803453ec00cbb2c Mon Sep 17 00:00:00 2001 +From: Paul Crawford +Date: Fri, 30 Dec 2016 15:55:45 +0000 +Subject: [PATCH 04/10] Compile with musl when nfs is disabled + +musl does by default not ship with rpc headers. The watchdog should +not require rpc headers when nfs support is disabled. + +Patch by Felix Janda +--- + include/sundries.h | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/include/sundries.h b/include/sundries.h +index 4379982..98c489a 100644 +--- a/include/sundries.h ++++ b/include/sundries.h +@@ -9,9 +9,11 @@ + #include + #include + #include ++#if HAVE_NFS + #if !defined(bool_t) && !defined(__GLIBC__) + #include + #endif ++#endif + + extern int mount_mount_quiet; + extern int mount_verbose; +-- +2.20.1 + diff --git a/0005-Rename-READ_ENUM-to-READ_YESNO.patch b/0005-Rename-READ_ENUM-to-READ_YESNO.patch new file mode 100644 index 0000000..8dc24e2 --- /dev/null +++ b/0005-Rename-READ_ENUM-to-READ_YESNO.patch @@ -0,0 +1,64 @@ +From 2878f90d6f50e7243038f4b1221654f18b2bd475 Mon Sep 17 00:00:00 2001 +From: Paul Crawford +Date: Fri, 30 Dec 2016 16:01:15 +0000 +Subject: [PATCH 05/10] Rename READ_ENUM to READ_YESNO + +- Previously we only has a single enumerated choice - the Boolean + yes/no option in the config file. + +- In preparation for having yes/no/auto we should make this more + obvious. +--- + src/configfile.c | 12 ++++++------ + 1 file changed, 6 insertions(+), 6 deletions(-) + +diff --git a/src/configfile.c b/src/configfile.c +index 10bbc69..809e39a 100644 +--- a/src/configfile.c ++++ b/src/configfile.c +@@ -128,7 +128,7 @@ READ_LIST_END() + + #define READ_INT(name, iv) read_int_func( arg, val, name, 0, 0, iv) + #define READ_STRING(name, str) read_string_func( arg, val, name, Read_allow_blank, str) +-#define READ_ENUM(name, iv) read_enumerated_func(arg, val, name, Yes_No_list, iv) ++#define READ_YESNO(name, iv) read_enumerated_func(arg, val, name, Yes_No_list, iv) + #define READ_LIST(name, list) read_list_func( arg, val, name, 0, list) + + /* +@@ -195,7 +195,7 @@ void read_config(char *configfile) + } else if (READ_INT(PINGCOUNT, &pingcount) == 0) { + } else if (READ_LIST(PING, &target_list) == 0) { + } else if (READ_LIST(INTERFACE, &iface_list) == 0) { +- } else if (READ_ENUM(REALTIME, &realtime) == 0) { ++ } else if (READ_YESNO(REALTIME, &realtime) == 0) { + } else if (READ_INT(PRIORITY, &schedprio) == 0) { + } else if (READ_STRING(REPAIRBIN, &repair_bin) == 0) { + } else if (READ_INT(REPAIRTIMEOUT, &repair_timeout) == 0) { +@@ -208,7 +208,7 @@ void read_config(char *configfile) + } else if (READ_INT(LOGTICK, &logtick) == 0) { + ticker = logtick; + } else if (READ_STRING(DEVICE, &devname) == 0) { +- } else if (READ_ENUM(DEVICE_USE_SETTIMEOUT, &refresh_use_settimeout) == 0) { ++ } else if (READ_YESNO(DEVICE_USE_SETTIMEOUT, &refresh_use_settimeout) == 0) { + } else if (READ_INT(DEVICE_TIMEOUT, &dev_timeout) == 0) { + } else if (READ_LIST(TEMP, &temp_list) == 0) { + } else if (READ_INT(MAXTEMP, &maxtemp) == 0) { +@@ -219,12 +219,12 @@ void read_config(char *configfile) + } else if (READ_INT(ALLOCMEM, &minalloc) == 0) { + } else if (READ_STRING(LOGDIR, &logdir) == 0) { + } else if (READ_STRING(TESTDIR, &test_dir) == 0) { +- } else if (READ_ENUM(SOFTBOOT, &softboot) == 0) { +- } else if (READ_ENUM(TEMPPOWEROFF, &temp_poweroff) == 0) { ++ } else if (READ_YESNO(SOFTBOOT, &softboot) == 0) { ++ } else if (READ_YESNO(TEMPPOWEROFF, &temp_poweroff) == 0) { + } else if (READ_INT(SIGTERM_DELAY, &sigterm_delay) == 0) { + } else if (READ_INT(RETRYTIMEOUT, &retry_timeout) == 0) { + } else if (READ_INT(REPAIRMAX, &repair_max) == 0) { +- } else if (READ_ENUM(VERBOSE, &verbose) == 0) { ++ } else if (READ_YESNO(VERBOSE, &verbose) == 0) { + } else { + log_message(LOG_WARNING, "Ignoring invalid option at line %d of config file: %s=%s", linecount, arg, val); + } +-- +2.20.1 + diff --git a/0006-Make-IT87-fix-up-automatic-by-default.patch b/0006-Make-IT87-fix-up-automatic-by-default.patch new file mode 100644 index 0000000..6821c02 --- /dev/null +++ b/0006-Make-IT87-fix-up-automatic-by-default.patch @@ -0,0 +1,183 @@ +From 25fa3156526d2e4e1a9bc84a160bf7850107bf27 Mon Sep 17 00:00:00 2001 +From: Paul Crawford +Date: Fri, 30 Dec 2016 16:39:16 +0000 +Subject: [PATCH 06/10] Make IT87 fix-up automatic by default + +- Update 00cf0b0 from Maciej S. Szmigiero proposed making the IT87 + style of fix something that is set only by the configuration file, + however, for many users with the buggy IT87 driver this will cause + problems. + +- This change make the choice a 3 state one: + + NO = never use ioctl-based refresh (old way, and in keeping + with the kernel API guidelines for watchdog use). + + YES = always use the ioctl-based refresh (i.e set timer every + time, instead of writing to /dev/watchdog). Might be + useful if another driver module is found to share same + sort of bug as the IT87 module. + + AUTO = check for IT87 and use ioctl-based method if found. This + is the same basec behaviour as before update 00cf0b0 but + the choice for yes/no now supported. +--- + include/extern.h | 4 ++++ + src/configfile.c | 12 ++++++++++-- + src/keep_alive.c | 43 ++++++++++++++++++++++++++++++++----------- + watchdog.conf.5 | 8 ++++---- + 4 files changed, 50 insertions(+), 17 deletions(-) + +diff --git a/include/extern.h b/include/extern.h +index cbf97fd..6d4ba5e 100644 +--- a/include/extern.h ++++ b/include/extern.h +@@ -59,6 +59,10 @@ struct list { + #define FALSE 0 + #endif + ++#define ENUM_NO 0 ++#define ENUM_YES 1 ++#define ENUM_AUTO 2 ++ + #define TS_SIZE 12 + + /* === External variables === */ +diff --git a/src/configfile.c b/src/configfile.c +index 809e39a..29e3464 100644 +--- a/src/configfile.c ++++ b/src/configfile.c +@@ -96,7 +96,7 @@ char *logdir = "/var/log/watchdog"; + char *heartbeat = NULL; + int hbstamps = 300; + +-int refresh_use_settimeout = FALSE; ++int refresh_use_settimeout = ENUM_AUTO; + int realtime = FALSE; + + /* Self-repairing binaries list */ +@@ -120,6 +120,13 @@ READ_LIST_ADD("yes", 1) + READ_LIST_END() + }; + ++static const read_list_t YN_Auto_list[] = { ++READ_LIST_ADD("no", ENUM_NO) ++READ_LIST_ADD("yes", ENUM_YES) ++READ_LIST_ADD("auto", ENUM_AUTO) ++READ_LIST_END() ++}; ++ + /* Use the macros below to simplify the parsing function. For now we don't use the + * integer range checking (0=0 so not checked), and assume all strings can be blank and + * enumerated choices are Yes/No, but in future we could add such settings to the #define'd +@@ -129,6 +136,7 @@ READ_LIST_END() + #define READ_INT(name, iv) read_int_func( arg, val, name, 0, 0, iv) + #define READ_STRING(name, str) read_string_func( arg, val, name, Read_allow_blank, str) + #define READ_YESNO(name, iv) read_enumerated_func(arg, val, name, Yes_No_list, iv) ++#define READ_YN_AUTO(name, iv) read_enumerated_func(arg, val, name, YN_Auto_list, iv) + #define READ_LIST(name, list) read_list_func( arg, val, name, 0, list) + + /* +@@ -208,7 +216,7 @@ void read_config(char *configfile) + } else if (READ_INT(LOGTICK, &logtick) == 0) { + ticker = logtick; + } else if (READ_STRING(DEVICE, &devname) == 0) { +- } else if (READ_YESNO(DEVICE_USE_SETTIMEOUT, &refresh_use_settimeout) == 0) { ++ } else if (READ_YN_AUTO(DEVICE_USE_SETTIMEOUT, &refresh_use_settimeout) == 0) { + } else if (READ_INT(DEVICE_TIMEOUT, &dev_timeout) == 0) { + } else if (READ_LIST(TEMP, &temp_list) == 0) { + } else if (READ_INT(MAXTEMP, &maxtemp) == 0) { +diff --git a/src/keep_alive.c b/src/keep_alive.c +index a57b0b5..6e721d9 100644 +--- a/src/keep_alive.c ++++ b/src/keep_alive.c +@@ -29,6 +29,7 @@ + + static int watchdog_fd = -1; + static int timeout_used = TIMER_MARGIN; ++static int Refresh_using_ioctl = FALSE; + + /* + * Open the watchdog timer (if name non-NULL) and set the time-out value (if non-zero). +@@ -67,19 +68,39 @@ int open_watchdog(char *name, int timeout) + /* The IT8728 on Gigabyte motherboard (and similar) would trip due to the normal + * refresh in the device driver failing to reset the timer for no obvious reason + * (though the normal operation used the Consumer IR sender to refresh via an +- * interrupt - also a non-obvious method!) so let's warn users of these +- * watchdogs and direct them to a workaround option. ++ * interrupt - also a non-obvious method!) so this work-around simply sets the ++ * time-out every refresh operation. + * +- * See https://bugs.launchpad.net/ubuntu/+source/linux/+bug/932381 and +- * https://bugzilla.kernel.org/show_bug.cgi?id=42801 ++ * See https://bugs.launchpad.net/ubuntu/+source/linux/+bug/932381 ++ * Also https://bugzilla.kernel.org/show_bug.cgi?id=42801 + * + */ +- if (!refresh_use_settimeout && strcmp("IT87 WDT", (char *)ident.identity) == 0) { +- log_message(LOG_INFO, +- "IT87 watchdog detected, if watchdog trips by itself when the first timeout interval elapses " +- "try updating to the latest kernel"); +- log_message(LOG_INFO, "if this does not help please report a kernel bug (not this package bug!) " +- "and try using watchdog-refresh-use-settimeout=yes config option as a workaround"); ++ ++ Refresh_using_ioctl = FALSE; ++ ++ switch (refresh_use_settimeout) { ++ case ENUM_NO: ++ /* Set to "no" so never use ioctl mode. */ ++ break; ++ ++ case ENUM_YES: ++ /* Set to "yes" so always use ioctl mode. */ ++ Refresh_using_ioctl = TRUE; ++ log_message(LOG_INFO, "Running ioctl-based refresh"); ++ break; ++ ++ case ENUM_AUTO: ++ /* Set to "auto" to decide based on driver identity. */ ++ Refresh_using_ioctl = FALSE; ++ if (strcmp("IT87 WDT", (char *)ident.identity) == 0) { ++ Refresh_using_ioctl = TRUE; ++ log_message(LOG_INFO, "Running IT87 module fix-up"); ++ } ++ break; ++ ++ default: ++ log_message(LOG_ERR, "Unknown ioctl selection mode (%d)", refresh_use_settimeout); ++ break; + } + + return rv; +@@ -165,7 +186,7 @@ int keep_alive(void) + if (watchdog_fd == -1) + return (ENOERR); + +- if (refresh_use_settimeout) { ++ if (Refresh_using_ioctl) { + int timeout = timeout_used; + if (ioctl(watchdog_fd, WDIOC_SETTIMEOUT, &timeout) < 0) { + err = errno; +diff --git a/watchdog.conf.5 b/watchdog.conf.5 +index 4e5155a..709c36e 100644 +--- a/watchdog.conf.5 ++++ b/watchdog.conf.5 +@@ -64,11 +64,11 @@ Set the watchdog device name, typically /dev/watchdog. Default is to disable + keep alive support. This should be tested by running the daemon from the + command line before configuring it to start automatically on booting. + .TP +-watchdog-refresh-use-settimeout = ++watchdog-refresh-use-settimeout = + Refresh watchdog timer by setting its timeout instead of using a normal watchdog +-refresh operation. +-Might help if your watchdog trips by itself when the first timeout interval +-elapses. ++refresh operation. Might help if your watchdog trips by itself when the first ++timeout interval elapses. Default is 'auto' for IT87 fix-up but this can be ++disabled with 'no' or forced for other modules with 'yes'. + .TP + watchdog-timeout = + Set the watchdog device timeout during startup. If not set, a default is used +-- +2.20.1 + diff --git a/0007-Synced-Debian-files-with-5.15-2.patch b/0007-Synced-Debian-files-with-5.15-2.patch new file mode 100644 index 0000000..032f626 --- /dev/null +++ b/0007-Synced-Debian-files-with-5.15-2.patch @@ -0,0 +1,116 @@ +From 62face90fe89ea1dc88b6b093f4921e47461f48d Mon Sep 17 00:00:00 2001 +From: Michael Meskes +Date: Fri, 20 Jan 2017 14:02:17 +0100 +Subject: [PATCH 07/10] Synced Debian files with 5.15-2 + +--- + debian/changelog | 9 +++++++++ + debian/control | 2 +- + debian/po/nl.po | 3 --- + debian/po/ru.po | 8 ++------ + debian/rules | 9 +++++---- + 5 files changed, 17 insertions(+), 14 deletions(-) + +diff --git a/debian/changelog b/debian/changelog +index fd436d8..1559626 100644 +--- a/debian/changelog ++++ b/debian/changelog +@@ -1,3 +1,12 @@ ++watchdog (5.15-2) unstable; urgency=medium ++ ++ * Fix FTCBFS: Let dh_auto_configure pass --host to ./configure ++ (Closes: #851231) Thanks to Helmut Grohne ++ * Bumped Standards-Version to 3.9.8, no changes needed. ++ * Enabled bindnow linker flag. ++ ++ -- Michael Meskes Fri, 20 Jan 2017 13:31:26 +0100 ++ + watchdog (5.15-1) unstable; urgency=medium + + * New upstream version. +diff --git a/debian/control b/debian/control +index a9f8a68..625f820 100644 +--- a/debian/control ++++ b/debian/control +@@ -3,7 +3,7 @@ Section: admin + Priority: extra + Maintainer: Michael Meskes + Build-Depends: debhelper (>= 9), po-debconf (>= 0.5.0), dh-systemd (>= 1.5) +-Standards-Version: 3.9.6 ++Standards-Version: 3.9.8 + Homepage: http://watchdog.sourceforge.net + + Package: watchdog +diff --git a/debian/po/nl.po b/debian/po/nl.po +index 9f9d657..73d1d28 100644 +--- a/debian/po/nl.po ++++ b/debian/po/nl.po +@@ -45,9 +45,6 @@ msgstr "Na het stoppen van watchdog wd_keepalive starten?" + #. Type: boolean + #. Description + #: ../templates:3001 +-#| msgid "" +-#| "Please specify whether watchdog should be started as part of the boot " +-#| "process. This can be changed later by editing /etc/default/watchdog." + msgid "" + "Please specify whether stopping watchdog should start wd_keepalive to keep " + "on triggering the watchdog device. This can be changed later by editing /etc/" +diff --git a/debian/po/ru.po b/debian/po/ru.po +index 6b2208c..211e4d8 100644 +--- a/debian/po/ru.po ++++ b/debian/po/ru.po +@@ -44,17 +44,14 @@ msgstr "Запускать wd_keepalive после остановки watchdog?" + #. Type: boolean + #. Description + #: ../templates:3001 +-#| msgid "" +-#| "Please specify whether watchdog should be started as part of the boot " +-#| "process. This can be changed later by editing /etc/default/watchdog." + msgid "" + "Please specify whether stopping watchdog should start wd_keepalive to keep " + "on triggering the watchdog device. This can be changed later by editing /etc/" + "default/watchdog." + msgstr "" + "Укажите, нужно ли при остановке watchdog запускать wd_keepalive, чтобы " +-"оставить рабочим устройство watchdog. Это можно " +-"изменить позже отредактировав файл /etc/default/watchdog." ++"оставить рабочим устройство watchdog. Это можно изменить позже " ++"отредактировав файл /etc/default/watchdog." + + #. Type: boolean + #. Description +@@ -91,4 +88,3 @@ msgstr "" + "Укажите модули, которые нужно загрузить перед запуском watchdog. Модуль " + "'softdog' обычно подходит для всех случаев. Введите 'none', если не хотите, " + "чтобы сценарий загружал модуль." +- +diff --git a/debian/rules b/debian/rules +index 2ca0797..0ece076 100755 +--- a/debian/rules ++++ b/debian/rules +@@ -1,9 +1,10 @@ + #!/usr/bin/make -f + + SHELL = /bin/bash +-CFLAGS = $(shell dpkg-buildflags --get CFLAGS) +-CPPFLAGS = $(shell dpkg-buildflags --get CPPFLAGS) +-LDFLAGS = $(shell dpkg-buildflags --get LDFLAGS) ++export DEB_BUILD_MAINT_OPTIONS=hardening=+all ++CFLAGS = `dpkg-buildflags --get CFLAGS` ++CPPFLAGS = `dpkg-buildflags --get CPPFLAGS` ++LDFLAGS = `dpkg-buildflags --get LDFLAGS` + + build: build-arch build-indep + build-arch: build-stamp +@@ -14,7 +15,7 @@ build-stamp: Makefile + touch build + + Makefile: +- CFLAGS="${CFLAGS}" CPPFLAGS="${CPPFLAGS}" LDFLAGS="${LDFLAGS}" ./configure --prefix=/usr \ ++ CFLAGS="${CFLAGS}" CPPFLAGS="${CPPFLAGS}" LDFLAGS="${LDFLAGS}" dh_auto_configure -- \ + --with-configfile=/etc/watchdog.conf + + clean: Makefile +-- +2.20.1 + diff --git a/0008-Fix-automated-CentOS-7-build.patch b/0008-Fix-automated-CentOS-7-build.patch new file mode 100644 index 0000000..ed74a84 --- /dev/null +++ b/0008-Fix-automated-CentOS-7-build.patch @@ -0,0 +1,58 @@ +From d7f483a0bc6214258098894daabc2ce590ca41fc Mon Sep 17 00:00:00 2001 +From: Paul Crawford +Date: Mon, 31 Jul 2017 16:18:53 +0100 +Subject: [PATCH 08/10] Fix automated CentOS 7 build + +- Apply changes from Marcus Furlong to fix automated CentOS 7 build + +- Update URLs to https and fix download address from sourceforge +--- + redhat/watchdog.spec | 11 ++++++----- + 1 file changed, 6 insertions(+), 5 deletions(-) + +diff --git a/redhat/watchdog.spec b/redhat/watchdog.spec +index a13730a..85a0164 100644 +--- a/redhat/watchdog.spec ++++ b/redhat/watchdog.spec +@@ -5,8 +5,8 @@ Release: 2%{?dist} + License: GPL+ + Group: System Environment/Daemons + +-URL: http://sourceforge.net/projects/watchdog/ +-Source0: http://dl.sf.net/watchdog/watchdog-%{version}.tar.gz ++URL: https://sourceforge.net/projects/watchdog/ ++Source0: https://downloads.sourceforge.net/project/watchdog/watchdog/%{version}/watchdog-%{version}.tar.gz + Source1: watchdog.init + Source2: README.watchdog.ipmi + Source3: README.Fedora +@@ -61,8 +61,6 @@ make %{?_smp_mflags} + rm -Rf ${RPM_BUILD_ROOT} + install -d -m0755 ${RPM_BUILD_ROOT}%{_sysconfdir} + make DESTDIR=${RPM_BUILD_ROOT} install +-install -Dp -m0644 %{name}.sysconfig ${RPM_BUILD_ROOT}%{_sysconfdir}/sysconfig/watchdog +-install -Dp -m0755 %{SOURCE1} ${RPM_BUILD_ROOT}%{_initrddir}/watchdog + + %clean + rm -Rf ${RPM_BUILD_ROOT} +@@ -91,7 +89,6 @@ fi + %defattr(-, root, root, -) + %doc AUTHORS ChangeLog COPYING examples/ IAFA-PACKAGE NEWS README TODO README.watchdog.ipmi README.Fedora + %config(noreplace) %{_sysconfdir}/watchdog.conf +-%config(noreplace) %{_sysconfdir}/sysconfig/watchdog + %{_sysconfdir}/rc.d/init.d/watchdog + %{_sbindir}/watchdog + %{_sbindir}/wd_keepalive +@@ -101,6 +98,10 @@ fi + + + %changelog ++* Tue Dec 13 2016 Paul Crawford - 5.15 ++- Apply changes from Marcus Furlong to fix automated CentOS 7 build ++- Update URLs to https and fix download address from sourceforge ++ + * Thu Mar 5 2009 Richard W.M. Jones - 5.5-2 + - Use '-' in defattr line instead of explicit file mode. + +-- +2.20.1 + diff --git a/0009-Bugfix-against-watchdog-configuration-file-corruptio.patch b/0009-Bugfix-against-watchdog-configuration-file-corruptio.patch new file mode 100644 index 0000000..49b46e2 --- /dev/null +++ b/0009-Bugfix-against-watchdog-configuration-file-corruptio.patch @@ -0,0 +1,101 @@ +From 7310afccc11070fd4207a41881401d619dd113b1 Mon Sep 17 00:00:00 2001 +From: Paul Crawford +Date: Mon, 31 Jul 2017 16:36:10 +0100 +Subject: [PATCH 09/10] Bugfix against watchdog configuration file corruption + +- Apply the bugfix/patch against watchdog configuration file + corruption during runtime by Greg Vishnepolsky greg@armis.com + +- Modify from Greg's patch to include the permission mode and to + declare the new fd variables immediately after the opening brace. + +- Greg provided the follow description: + +The following patch fixes a bug where writes/prints (out of a test +binary) that are intended for stdout/stderr may instead be written +to other files (like the watchdog configuration files). + +The bug lies in the call to "freopen" on "stdout" when the actual +FD (1) for stdout had been previously closed by the daemon. Instead +this FD could have been re-used (for instance, for opening watchdog +configuration files). Thus any prints out of the daemon/test binaries +will be erroneously written into it. +--- + src/test_binary.c | 13 +++++++++++-- + src/watchdog.c | 13 +++++++++++-- + 2 files changed, 22 insertions(+), 4 deletions(-) + +diff --git a/src/test_binary.c b/src/test_binary.c +index 2211f9e..a58c107 100644 +--- a/src/test_binary.c ++++ b/src/test_binary.c +@@ -3,6 +3,7 @@ + #endif + + #include ++#include + #include + #include + #include +@@ -258,16 +259,24 @@ int check_bin(char *tbinary, int timeout, int version) + + child_pid = fork(); + if (!child_pid) { ++ int test_stdout_fd, test_stderr_fd; + + /* Don't want the stdout and stderr of our test program + * to cause trouble, so make them go to their respective files */ + strcpy(filename_buf, logdir); + strcat(filename_buf, "/test-bin.stdout"); +- if (!freopen(filename_buf, "a+", stdout)) ++ test_stdout_fd = open(filename_buf, O_WRONLY|O_CREAT|O_APPEND, S_IWUSR|S_IRUSR|S_IRGRP); ++ if (test_stdout_fd == -1) + exit(errno); ++ if (dup2(test_stdout_fd, fileno(stdout)) == -1) ++ exit(errno); ++ + strcpy(filename_buf, logdir); + strcat(filename_buf, "/test-bin.stderr"); +- if (!freopen(filename_buf, "a+", stderr)) ++ test_stderr_fd = open(filename_buf, O_WRONLY|O_CREAT|O_APPEND, S_IWUSR|S_IRUSR|S_IRGRP); ++ if (test_stderr_fd == -1) ++ exit(errno); ++ if (dup2(test_stderr_fd, fileno(stderr)) == -1) + exit(errno); + + /* now start binary */ +diff --git a/src/watchdog.c b/src/watchdog.c +index 486384a..a69dba4 100644 +--- a/src/watchdog.c ++++ b/src/watchdog.c +@@ -84,16 +84,25 @@ static int repair(char *rbinary, int result, char *name, int version) + + child_pid = fork(); + if (!child_pid) { ++ int repair_stdout_fd, repair_stderr_fd; ++ + /* Don't want the stdin and stdout of our repair program + * to cause trouble. + * So make stdout and stderr go to their respective files */ + strcpy(filename_buf, logdir); + strcat(filename_buf, "/repair-bin.stdout"); +- if (!freopen(filename_buf, "a+", stdout)) ++ repair_stdout_fd = open(filename_buf, O_WRONLY|O_CREAT|O_APPEND, S_IWUSR|S_IRUSR|S_IRGRP); ++ if (repair_stdout_fd == -1) + exit(errno); ++ if (dup2(repair_stdout_fd, fileno(stdout)) == -1) ++ exit(errno); ++ + strcpy(filename_buf, logdir); + strcat(filename_buf, "/repair-bin.stderr"); +- if (!freopen(filename_buf, "a+", stderr)) ++ repair_stderr_fd = open(filename_buf, O_WRONLY|O_CREAT|O_APPEND, S_IWUSR|S_IRUSR|S_IRGRP); ++ if (repair_stderr_fd == -1) ++ exit(errno); ++ if (dup2(repair_stderr_fd, fileno(stderr)) == -1) + exit(errno); + + /* now start binary */ +-- +2.20.1 + diff --git a/0010-Choose-libtirpc-or-another-RPC-library-for-XDR-heade.patch b/0010-Choose-libtirpc-or-another-RPC-library-for-XDR-heade.patch new file mode 100644 index 0000000..8a3a8b8 --- /dev/null +++ b/0010-Choose-libtirpc-or-another-RPC-library-for-XDR-heade.patch @@ -0,0 +1,57 @@ +From 93f5334052cf14ae1149aa0f0b3178137eec01dd Mon Sep 17 00:00:00 2001 +From: "Richard W.M. Jones" +Date: Wed, 6 Feb 2019 13:25:47 +0000 +Subject: [PATCH 10/10] Choose libtirpc or another RPC library for XDR headers + and library. + +Signed-off-by: Richard W.M. Jones +--- + configure.ac | 20 ++++++++++++++++++++ + src/Makefile.am | 2 ++ + 2 files changed, 22 insertions(+) + +diff --git a/configure.ac b/configure.ac +index f100829..4220411 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -156,4 +156,24 @@ AC_ARG_WITH(randomseed, + AC_MSG_RESULT("/var/run/random-seed") + ]) + ++# Check for an RPC library, starting with libtirpc. ++PKG_CHECK_MODULES([RPC], [libtirpc], [], [ ++ # If we don't have libtirpc, then we must have and ++ # some library to link to in libdir. ++ RPC_CFLAGS="" ++ AC_CHECK_HEADER([rpc/rpc.h],[],[ ++ AC_MSG_ERROR([XDR header files are required]) ++ ], ++ [#include ]) ++ ++ old_LIBS="$LIBS" ++ LIBS="" ++ AC_SEARCH_LIBS([xdrmem_create],[rpc xdr nsl]) ++ RPC_LIBS="$LIBS" ++ LIBS="$old_LIBS" ++ ++ AC_SUBST([RPC_CFLAGS]) ++ AC_SUBST([RPC_LIBS]) ++]) ++ + AC_OUTPUT([Makefile src/Makefile]) +diff --git a/src/Makefile.am b/src/Makefile.am +index 4ecfd97..7f63be5 100644 +--- a/src/Makefile.am ++++ b/src/Makefile.am +@@ -6,6 +6,8 @@ watchdog_SOURCES = file_stat.c file_table.c fstab.c iface.c ifdown.c keep_alive. + temp.c test_binary.c umount.c version.c watchdog.c \ + logmessage.c xmalloc.c heartbeat.c lock_mem.c daemon-pid.c configfile.c \ + errorcodes.c read-conf.c sigterm.c ++watchdog_CFLAGS = $(RPC_CFLAGS) ++watchdog_LDADD = $(RPC_LIBS) + + wd_keepalive_SOURCES = wd_keepalive.c logmessage.c lock_mem.c daemon-pid.c xmalloc.c \ + configfile.c keep_alive.c read-conf.c sigterm.c +-- +2.20.1 + diff --git a/watchdog.spec b/watchdog.spec index 4a5c8ec..228b34e 100644 --- a/watchdog.spec +++ b/watchdog.spec @@ -12,8 +12,21 @@ Source3: README.Fedora Source4: watchdog.service Source5: watchdog-ping.service -Patch3: 0003-watchdog-5.13-rhsel.patch -Patch4: 0004-watchdog-5.13-rhseldoc.patch +# Upstream patches since 5.15. +Patch1: 0001-Include-linux-param.h-for-EXEC_PAGESIZE-definition.patch +Patch2: 0002-Generalize-and-make-watchdog-refresh-settimeout-work.patch +Patch3: 0003-Ignore-build-products-in-GIT.patch +Patch4: 0004-Compile-with-musl-when-nfs-is-disabled.patch +Patch5: 0005-Rename-READ_ENUM-to-READ_YESNO.patch +Patch6: 0006-Make-IT87-fix-up-automatic-by-default.patch +Patch7: 0007-Synced-Debian-files-with-5.15-2.patch +Patch8: 0008-Fix-automated-CentOS-7-build.patch +Patch9: 0009-Bugfix-against-watchdog-configuration-file-corruptio.patch +# Fixes building on glibc without RPC. Sent upstream 2019-02-06. +Patch10: 0010-Choose-libtirpc-or-another-RPC-library-for-XDR-heade.patch + +# Non-upstream patch to document SELinux support. +Patch99: 0004-watchdog-5.13-rhseldoc.patch BuildRequires: gcc BuildRequires: libtirpc-devel @@ -43,8 +56,17 @@ expiration) initiated by the BMC. %prep %setup -q -n %{name}-%{version} -%patch3 -p1 -b .rhsel -%patch4 -p1 -b .rhseldoc +%patch1 -p1 +%patch2 -p1 +%patch3 -p1 +%patch4 -p1 +%patch5 -p1 +%patch6 -p1 +%patch7 -p1 +%patch8 -p1 +%patch9 -p1 +%patch10 -p1 +%patch99 -p1 -b .rhseldoc cp %{SOURCE2} . cp %{SOURCE3} . @@ -119,6 +141,11 @@ install -Dd -m0755 ${RPM_BUILD_ROOT}%{_libexecdir}/watchdog/scripts %changelog +* Wed Feb 06 2019 Richard W.M. Jones - 5.15-5 +- Add all upstream patches since 5.15. +- Fix RPC/libtirpc (again?). +- Remove .rhsel patch. Equivalent added upstream in 7310afccc1. + * Sun Feb 03 2019 Fedora Release Engineering - 5.15-4 - Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild