diff --git a/0001-Fix-query-watchdog-avoid-issues-on-heap-allocation-f.patch b/0001-Fix-query-watchdog-avoid-issues-on-heap-allocation-f.patch new file mode 100644 index 0000000..3b0696a --- /dev/null +++ b/0001-Fix-query-watchdog-avoid-issues-on-heap-allocation-f.patch @@ -0,0 +1,84 @@ +From 030d7edb179235b7df65ada3a79837b01e682a5b Mon Sep 17 00:00:00 2001 +From: Klaus Wenninger +Date: Thu, 21 Jul 2022 10:48:21 +0200 +Subject: [PATCH] Fix: query-watchdog: avoid issues on heap allocation failing + +coverity is moaning either due to slight code rearangement +or new version/settings. +--- + src/sbd-common.c | 27 ++++++++++++++++++++++++++- + 1 file changed, 26 insertions(+), 1 deletion(-) + +diff --git a/src/sbd-common.c b/src/sbd-common.c +index f3f226a..3abf75f 100644 +--- a/src/sbd-common.c ++++ b/src/sbd-common.c +@@ -385,8 +385,17 @@ watchdog_populate_list(void) + struct link_list_item *lli = + calloc(1, sizeof(struct link_list_item)); + ++ if (lli == NULL) { ++ break; ++ } + lli->dev_node = strdup(buf); + lli->link_name = strdup(entry_name); ++ if ((lli->dev_node == NULL) || (lli->link_name == NULL)) { ++ free(lli->dev_node); ++ free(lli->link_name); ++ free(lli); ++ break; ++ } + lli->next = link_list; + link_list = lli; + } +@@ -404,18 +413,27 @@ watchdog_populate_list(void) + if(!stat(entry_name, &statbuf) && S_ISCHR(statbuf.st_mode) && + is_watchdog(statbuf.st_rdev)) { + +- int wdfd = watchdog_init_fd(entry_name, -1); ++ int wdfd; + struct watchdog_list_item *wdg = + calloc(1, sizeof(struct watchdog_list_item)); + int len; + struct link_list_item *tmp_list = NULL; + ++ if (wdg == NULL) { ++ break; ++ } ++ + wdg->dev = statbuf.st_rdev; + wdg->dev_node = strdup(entry_name); ++ if (wdg->dev_node == NULL) { ++ free(wdg); ++ break; ++ } + wdg->next = watchdog_list; + watchdog_list = wdg; + watchdog_list_items++; + ++ wdfd = watchdog_init_fd(entry_name, -1); + if (wdfd >= 0) { + struct watchdog_info ident; + +@@ -450,11 +468,18 @@ watchdog_populate_list(void) + struct watchdog_list_item *dupe_wdg = + calloc(1, sizeof(struct watchdog_list_item)); + ++ if (dupe_wdg == NULL) { ++ break; ++ } + /* as long as we never purge watchdog_list + * there is no need to dupe strings + */ + *dupe_wdg = *wdg; + dupe_wdg->dev_node = strdup(tmp_list->link_name); ++ if (dupe_wdg->dev_node == NULL) { ++ free(dupe_wdg); ++ break; ++ } + dupe_wdg->next = watchdog_list; + watchdog_list = dupe_wdg; + watchdog_list_items++; +-- +2.39.0 + diff --git a/0002-Refactor-sbd-md-alloc-de-alloc-reverse-order.patch b/0002-Refactor-sbd-md-alloc-de-alloc-reverse-order.patch new file mode 100644 index 0000000..81cf444 --- /dev/null +++ b/0002-Refactor-sbd-md-alloc-de-alloc-reverse-order.patch @@ -0,0 +1,56 @@ +From 48c9a11e5b4ace22011e51d4c5dcacaddf9bbc43 Mon Sep 17 00:00:00 2001 +From: Klaus Wenninger +Date: Fri, 3 Feb 2023 10:58:10 +0100 +Subject: [PATCH] Refactor: sbd-md: alloc/de-alloc reverse order + +Having de-allocation in the reverse order compared to +allocation seems to make gcc-12 static analysis of +dynamic-memory-management happy. +--- + src/sbd-md.c | 11 +++++------ + 1 file changed, 5 insertions(+), 6 deletions(-) + +diff --git a/src/sbd-md.c b/src/sbd-md.c +index 7a37522..2a237ad 100644 +--- a/src/sbd-md.c ++++ b/src/sbd-md.c +@@ -441,9 +441,9 @@ init_device(struct sbd_context *st) + } + } + +-out: free(s_node); ++out: free(s_mbox); ++ free(s_node); + free(s_header); +- free(s_mbox); + return(rc); + } + +@@ -556,9 +556,9 @@ slot_allocate(struct sbd_context *st, const char *name) + } + } + +-out: free(s_node); ++out: free(s_mbox); ++ free(s_node); + free(s_header); +- free(s_mbox); + return(rc); + } + +@@ -1279,11 +1279,10 @@ int servant_md(const char *diskname, int mode, const void* argp) + } + } + out: +- free(s_header); + free(s_node); + free(s_mbox); ++ free(s_header); + close_device(st); + exit(rc); + } + +- +-- +2.39.0 + diff --git a/0003-spec-convert-license-naming-to-SPDX.patch b/0003-spec-convert-license-naming-to-SPDX.patch new file mode 100644 index 0000000..5d3eddc --- /dev/null +++ b/0003-spec-convert-license-naming-to-SPDX.patch @@ -0,0 +1,34 @@ +From 0e4534ebdfe8d7a37beb0028e604e560a5674891 Mon Sep 17 00:00:00 2001 +From: Klaus Wenninger +Date: Fri, 3 Feb 2023 15:35:22 +0100 +Subject: [PATCH] spec: convert license naming to SPDX + +--- + sbd.spec | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/sbd.spec b/sbd.spec +index e9ff7bc..b9e7f72 100644 +--- a/sbd.spec ++++ b/sbd.spec +@@ -49,7 +49,7 @@ + + Name: sbd + Summary: Storage-based death +-License: GPLv2+ ++License: GPL-2.0-or-later + Group: System Environment/Daemons + Version: 1.5.2 + Release: 99.%{buildnum}.%{shortcommit}.%{modified}git%{?dist} +@@ -95,7 +95,7 @@ Available rpmbuild rebuild options: + + %package tests + Summary: Storage-based death environment for regression tests +-License: GPLv2+ ++License: GPL-2.0-or-later + Group: System Environment/Daemons + + %description tests +-- +2.39.0 + diff --git a/sbd-6bb085f5704dd4c3841c79504f2aed2228e6d76a.tar.gz b/sbd-6bb085f5704dd4c3841c79504f2aed2228e6d76a.tar.gz deleted file mode 100644 index da27f75..0000000 Binary files a/sbd-6bb085f5704dd4c3841c79504f2aed2228e6d76a.tar.gz and /dev/null differ diff --git a/sbd-cf5c2208bad2db2dff9b09624b89b05415c3bc11.tar.gz b/sbd-cf5c2208bad2db2dff9b09624b89b05415c3bc11.tar.gz new file mode 100644 index 0000000..cb8d3c3 Binary files /dev/null and b/sbd-cf5c2208bad2db2dff9b09624b89b05415c3bc11.tar.gz differ diff --git a/sbd.spec b/sbd.spec index 64ed030..8fd6d2c 100644 --- a/sbd.spec +++ b/sbd.spec @@ -1,23 +1,40 @@ -%global longcommit 6bb085f5704dd4c3841c79504f2aed2228e6d76a +%global longcommit cf5c2208bad2db2dff9b09624b89b05415c3bc11 %global shortcommit %(echo %{longcommit}|cut -c1-8) %global modified %(echo %{longcommit}-|cut -f2 -d-) %global github_owner Clusterlabs -%global buildnum 4 -%global watchdog_timeout_default 5 -%global sync_resource_startup_sysconfig "" +%global buildnum 1 +%global watchdog_timeout_default 5 + +# Be careful with sync_resource_startup_default +# being enabled. This configuration has +# to be in sync with configuration in pacemaker +# where it is called sbd_sync - assure by e.g. +# mutual rpm dependencies. %bcond_without sync_resource_startup_default +# Syncing enabled per default will lead to +# syncing enabled on upgrade without adaption +# of the config. +# Setting can still be overruled via sysconfig. +# The setting in the config-template packaged +# will follow the default if below is is left +# empty. But it is possible to have the setting +# in the config-template deviate from the default +# by setting below to an explicit 'yes' or 'no'. +%global sync_resource_startup_sysconfig "" Name: sbd Summary: Storage-based death -License: GPLv2 and MIT +License: GPL-2.0-or-later Group: System Environment/Daemons -Version: 1.5.1 +Version: 1.5.2 Release: %{buildnum} Url: https://github.com/%{github_owner}/%{name} Source0: https://github.com/%{github_owner}/%{name}/archive/%{longcommit}/%{name}-%{longcommit}.tar.gz Patch0: 0001-Fix-the-problem-of-service-error-when-uninstalling.patch -BuildRoot: %{_tmppath}/%{name}-%{version}-build +Patch1: 0001-Fix-query-watchdog-avoid-issues-on-heap-allocation-f.patch +Patch2: 0002-Refactor-sbd-md-alloc-de-alloc-reverse-order.patch +Patch3: 0003-spec-convert-license-naming-to-SPDX.patch BuildRequires: autoconf BuildRequires: automake BuildRequires: libuuid-devel @@ -31,24 +48,24 @@ BuildRequires: libxml2-devel BuildRequires: pkgconfig BuildRequires: systemd BuildRequires: make -Conflicts: fence-agents-sbd < 4.2.1 -Conflicts: pacemaker-libs < 2.0.5 +Conflicts: fence-agents-sbd < 4.5.0 +Conflicts: pacemaker-libs < 2.1.0 ExclusiveArch: x86_64 aarch64 riscv64 loongarch64 ppc64le - %if %{defined systemd_requires} %systemd_requires %endif %description + This package contains the storage-based death functionality. + Available rpmbuild rebuild options: --with(out) : sync_resource_startup_default -%package tests +%package tests Summary: Storage-based death environment for regression tests -License: GPLv2 and MIT -Group: System Environment/Daemons +License: GPL-2.0-or-later %description tests This package provides an environment + testscripts for @@ -66,10 +83,11 @@ export CFLAGS="$RPM_OPT_FLAGS -Wall -Werror" --with-runstatedir=%{_rundir} make %{?_smp_mflags} - %install + make DESTDIR=$RPM_BUILD_ROOT LIBDIR=%{_libdir} install rm -rf ${RPM_BUILD_ROOT}%{_libdir}/stonith + install -D -m 0755 tests/regressions.sh $RPM_BUILD_ROOT/usr/share/sbd/regressions.sh %if %{defined _unitdir} install -D -m 0644 src/sbd.service $RPM_BUILD_ROOT/%{_unitdir}/sbd.service @@ -83,10 +101,10 @@ install -m 644 src/sbd.sysconfig ${RPM_BUILD_ROOT}%{_sysconfdir}/sysconfig/sbd find %{buildroot} -name '*.a' -type f -print0 | xargs -0 rm -f find %{buildroot} -name '*.la' -type f -print0 | xargs -0 rm -f - %clean rm -rf %{buildroot} + %if %{defined _unitdir} %post %systemd_post sbd.service @@ -132,6 +150,9 @@ fi %{_libdir}/libsbdtestbed* %changelog +* Wed Mar 27 2024 bizhiyuan - 1.5.2-1 +- Update to 1.5.2 + * Wed Mar 6 2024 xurui - 1.5.1-4 - Add ppc64le to ExclusiveArch