From 6c5d163299bd7cd3d57798a03a9cda951393309e Mon Sep 17 00:00:00 2001 From: Klaus Wenninger Date: Fri, 1 Feb 2019 17:57:53 +0100 Subject: [PATCH] * Fri Feb 1 2019 Klaus Wenninger - 1.4.0-1 - Rebase to upstream v1.4.0 - Fail earlier on invalid servants (solves GCC9 build issue as well) --- ...tor-fail-earlier-on-invalid-servants.patch | 142 ++++++++++++++++++ sbd.spec | 11 +- sources | 2 +- 3 files changed, 151 insertions(+), 4 deletions(-) create mode 100644 0001-Refactor-fail-earlier-on-invalid-servants.patch diff --git a/0001-Refactor-fail-earlier-on-invalid-servants.patch b/0001-Refactor-fail-earlier-on-invalid-servants.patch new file mode 100644 index 0000000..cb71002 --- /dev/null +++ b/0001-Refactor-fail-earlier-on-invalid-servants.patch @@ -0,0 +1,142 @@ +From 8301cbafed191f30656a22876941cc7c9189b623 Mon Sep 17 00:00:00 2001 +From: Klaus Wenninger +Date: Thu, 31 Jan 2019 14:42:01 +0100 +Subject: [PATCH] Refactor: fail earlier on invalid servants + +--- + src/sbd-inquisitor.c | 51 ++++++++++++++++++++++++++++++++------------------- + src/sbd-md.c | 7 +------ + src/sbd.h | 2 +- + 3 files changed, 34 insertions(+), 26 deletions(-) + +diff --git a/src/sbd-inquisitor.c b/src/sbd-inquisitor.c +index 8e0bc87..9be6c99 100644 +--- a/src/sbd-inquisitor.c ++++ b/src/sbd-inquisitor.c +@@ -42,19 +42,36 @@ void recruit_servant(const char *devname, pid_t pid) + struct servants_list_item *newbie; + + if (lookup_servant_by_dev(devname)) { +- cl_log(LOG_DEBUG, "Servant %s already exists", devname); +- return; ++ cl_log(LOG_DEBUG, "Servant %s already exists", devname); ++ return; + } + + newbie = malloc(sizeof(*newbie)); +- if (!newbie) { +- fprintf(stderr, "malloc failed in recruit_servant.\n"); +- exit(1); ++ if (newbie) { ++ memset(newbie, 0, sizeof(*newbie)); ++ newbie->devname = strdup(devname); ++ newbie->pid = pid; ++ newbie->first_start = 1; ++ } ++ if (!newbie || !newbie->devname) { ++ fprintf(stderr, "heap allocation failed in recruit_servant.\n"); ++ exit(1); ++ } ++ ++ /* some sanity-check on our newbie */ ++ if (sbd_is_disk(newbie)) { ++ cl_log(LOG_INFO, "Monitoring %s", devname); ++ disk_count++; ++ } else if (sbd_is_pcmk(newbie) || sbd_is_cluster(newbie)) { ++ /* alive just after pcmk and cluster servants have shown up */ ++ newbie->outdated = 1; ++ } else { ++ /* toss our newbie */ ++ cl_log(LOG_ERR, "Refusing to recruit unrecognized servant %s", devname); ++ free((void *) newbie->devname); ++ free(newbie); ++ return; + } +- memset(newbie, 0, sizeof(*newbie)); +- newbie->devname = strdup(devname); +- newbie->pid = pid; +- newbie->first_start = 1; + + if (!s) { + servants_leader = newbie; +@@ -65,12 +82,6 @@ void recruit_servant(const char *devname, pid_t pid) + } + + servant_count++; +- if(sbd_is_disk(newbie)) { +- cl_log(LOG_INFO, "Monitoring %s", devname); +- disk_count++; +- } else { +- newbie->outdated = 1; +- } + } + + int assign_servant(const char* devname, functionp_t functionp, int mode, const void* argp) +@@ -148,7 +159,7 @@ void servant_start(struct servants_list_item *s) + if (sbd_is_disk(s)) { + #if SUPPORT_SHARED_DISK + DBGLOG(LOG_INFO, "Starting servant for device %s", s->devname); +- s->pid = assign_servant(s->devname, servant, start_mode, s); ++ s->pid = assign_servant(s->devname, servant_md, start_mode, s); + #else + cl_log(LOG_ERR, "Shared disk functionality not supported"); + return; +@@ -785,12 +796,14 @@ parse_device_line(const char *line) + + if (lpc > last) { + entry = calloc(1, 1 + lpc - last); ++ if (!entry) { ++ fprintf(stderr, "heap allocation failed parsing device-line.\n"); ++ exit(1); ++ } + rc = sscanf(line + last, "%[^;]", entry); + } + +- if (entry == NULL) { +- /* Skip */ +- } else if (rc != 1) { ++ if (rc != 1) { + cl_log(LOG_WARNING, "Could not parse (%d %d): %s", last, lpc, line + last); + } else { + cl_log(LOG_DEBUG, "Adding '%s'", entry); +diff --git a/src/sbd-md.c b/src/sbd-md.c +index 579d273..ba2c34d 100644 +--- a/src/sbd-md.c ++++ b/src/sbd-md.c +@@ -1031,7 +1031,7 @@ static int servant_check_timeout_inconsistent(struct sector_header_s *hdr) + return 0; + } + +-int servant(const char *diskname, int mode, const void* argp) ++int servant_md(const char *diskname, int mode, const void* argp) + { + struct sector_mbox_s *s_mbox = NULL; + struct sector_node_s *s_node = NULL; +@@ -1046,11 +1046,6 @@ int servant(const char *diskname, int mode, const void* argp) + char uuid[37]; + const struct servants_list_item *s = argp; + +- if (!diskname) { +- cl_log(LOG_ERR, "Empty disk name %s.", diskname); +- return -1; +- } +- + cl_log(LOG_INFO, "Servant starting for device %s", diskname); + + /* Block most of the signals */ +diff --git a/src/sbd.h b/src/sbd.h +index 386c85c..6fe07f9 100644 +--- a/src/sbd.h ++++ b/src/sbd.h +@@ -175,7 +175,7 @@ int ping_via_slots(const char *name, struct servants_list_item *servants); + int dump_headers(struct servants_list_item *servants); + unsigned long get_first_msgwait(struct servants_list_item *servants); + int messenger(const char *name, const char *msg, struct servants_list_item *servants); +-int servant(const char *diskname, int mode, const void* argp); ++int servant_md(const char *diskname, int mode, const void* argp); + #endif + + int servant_pcmk(const char *diskname, int mode, const void* argp); +-- +1.8.3.1 + diff --git a/sbd.spec b/sbd.spec index 514544a..1de178a 100644 --- a/sbd.spec +++ b/sbd.spec @@ -15,17 +15,18 @@ # Please submit bugfixes or comments via http://bugs.opensuse.org/ # -%global commit 4927571f8e9b00db8242654b1329dfbd71dcfe99 +%global commit 7f33d1a409d0a4e2cd69946688c48eaa8f3c5d26 %global shortcommit %(c=%{commit}; echo ${c:0:7}) %global github_owner clusterlabs Name: sbd Summary: Storage-based death License: GPLv2+ -Version: 1.3.1 -Release: 1%{?shortcommit:.git%{shortcommit}}%{?dist} +Version: 1.4.0 +Release: 1%{?dist} Url: https://github.com/%{github_owner}/%{name} Source0: https://github.com/%{github_owner}/%{name}/archive/%{commit}/%{name}-%{commit}.tar.gz +Patch0: 0001-Refactor-fail-earlier-on-invalid-servants.patch BuildRequires: autoconf BuildRequires: automake BuildRequires: libuuid-devel @@ -109,6 +110,10 @@ install -m 644 src/sbd.sysconfig ${RPM_BUILD_ROOT}%{_sysconfdir}/sysconfig/sbd %doc COPYING %changelog +* Fri Feb 1 2019 Klaus Wenninger - 1.4.0-1 +- Rebase to upstream v1.4.0 +- Fail earlier on invalid servants (solves GCC9 build issue as well) + * Wed Nov 21 2018 Klaus Wenninger - 1.3.1-1.git4927571 - Rebased to commit 4927571f8e9b00db8242654b1329dfbd71dcfe99 - Removed disabling of shared-disk-support diff --git a/sources b/sources index 1bc96d2..fab3041 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -SHA512 (sbd-4927571f8e9b00db8242654b1329dfbd71dcfe99.tar.gz) = 9279f002310ebb375129860b86a4fba34f432585cc4594f14925192e8de36d2d4ba6df606d88af71fffe07d659dd40fb5d0f7f0f0568b27f016919f3b60ee901 +SHA512 (sbd-7f33d1a409d0a4e2cd69946688c48eaa8f3c5d26.tar.gz) = 1baca43ad95d8d0886cbd1db82eeb617a2055e5a31d16f2802c27b120894c6829bfc99663e2da402a37e6c52d0cda6cec63cbc15cb6c580895e5a1d30e5b1c62