Update to sanlock 3.7.0

- Update version and release
- Remove the unneeded with_systemd flag
- Remove all the patches, they are included in 3.7.0
This commit is contained in:
Nir Soffer 2019-03-20 22:54:20 +02:00
parent 8a363c58ec
commit bda28c805c
6 changed files with 6 additions and 285 deletions

View File

@ -1,40 +0,0 @@
From 39b4d87397e5a09adcd100e0f379f34d5dde7e9b Mon Sep 17 00:00:00 2001
From: Nir Soffer <nsoffer@redhat.com>
Date: Mon, 15 Jan 2018 01:21:51 +0200
Subject: [PATCH 1/2] Fix libsanlock build on Unubtu/Debian
LIB_ENTIRE_LDFLAGS included libraries (e.g. -laio -lblkid) instead of
linker flags. The libraries should be in LIB_ENTIRE_LDDADD and come
*after* the sources. Otherwisae, the libraries are not linked, and
loading libsanlock.so fail with undefined symbol error.
Signed-off-by: Nir Soffer <nsoffer@redhat.com>
---
src/Makefile | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/Makefile b/src/Makefile
index 69fcd1321ee7..73a2b3498475 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -98,15 +98,15 @@ CMD_CFLAGS = $(CFLAGS) -fPIE -DPIE
CMD_LDFLAGS += -Wl,-z,now -Wl,-z,relro -pie
CMD_LDADD += -lpthread -luuid -lrt -laio -lblkid -lsanlock -L../wdmd -lwdmd
-LIB_ENTIRE_LDFLAGS += -lpthread -lrt -laio -lblkid -L../wdmd -lwdmd
LIB_ENTIRE_LDFLAGS += -Wl,-z,relro -pie
+LIB_ENTIRE_LDADD += -lpthread -lrt -laio -lblkid -L../wdmd -lwdmd
LIB_CLIENT_LDFLAGS += -Wl,-z,relro -pie
all: $(LIBSO_ENTIRE_TARGET) $(LIBSO_CLIENT_TARGET) $(CMD_TARGET) $(LIBPC_ENTIRE_TARGET) $(LIBPC_CLIENT_TARGET)
$(LIBSO_ENTIRE_TARGET): $(LIB_ENTIRE_SOURCE)
- $(CC) $(CFLAGS) $(LIB_ENTIRE_LDFLAGS) -shared -fPIC -o $@ -Wl,-soname=$(LIB_ENTIRE_TARGET).so.$(SOMAJOR) $^
+ $(CC) $(CFLAGS) $(LIB_ENTIRE_LDFLAGS) -shared -fPIC -o $@ -Wl,-soname=$(LIB_ENTIRE_TARGET).so.$(SOMAJOR) $^ $(LIB_ENTIRE_LDADD)
ln -sf $(LIBSO_ENTIRE_TARGET) $(LIB_ENTIRE_TARGET).so
ln -sf $(LIBSO_ENTIRE_TARGET) $(LIB_ENTIRE_TARGET).so.$(SOMAJOR)
--
2.7.5

View File

@ -1,23 +0,0 @@
From f4b87765ff8cb4f2d1850c0fd6238ce1fdb1c8a4 Mon Sep 17 00:00:00 2001
From: David Teigland <teigland@redhat.com>
Date: Mon, 18 Aug 2014 14:17:07 -0500
Subject: [PATCH] reset: install man pages
Signed-off-by: David Teigland <teigland@redhat.com>
---
reset/Makefile | 2 ++
1 file changed, 2 insertions(+)
diff --git a/reset/Makefile b/reset/Makefile
index 457da5e5bbfa..d67ceb3a4883 100644
--- a/reset/Makefile
+++ b/reset/Makefile
@@ -58,3 +58,5 @@ MANDIR=/usr/share/man
install: all
$(INSTALL) -d $(DESTDIR)/$(BINDIR)
$(INSTALL) -c -m 755 $(TARGET1) $(TARGET2) $(DESTDIR)/$(BINDIR)
+ $(INSTALL) -m 644 sanlk-reset.8 $(DESTDIR)/$(MANDIR)/man8/
+ $(INSTALL) -m 644 sanlk-resetd.8 $(DESTDIR)/$(MANDIR)/man8/
--
1.8.3.1

View File

@ -1,85 +0,0 @@
From fa6d48a7c8991b2251e50469a7e57058be226ab0 Mon Sep 17 00:00:00 2001
From: David Teigland <teigland@redhat.com>
Date: Wed, 14 Mar 2018 11:49:35 -0500
Subject: [PATCH 2/2] fix makefile flags
should let the fedora build flags work
---
reset/Makefile | 2 +-
src/Makefile | 15 +++++++--------
wdmd/Makefile | 8 ++++----
3 files changed, 12 insertions(+), 13 deletions(-)
diff --git a/reset/Makefile b/reset/Makefile
index c61348a2b9c3..04a23032614a 100644
--- a/reset/Makefile
+++ b/reset/Makefile
@@ -34,7 +34,7 @@ VER=$(shell cat ../VERSION)
CFLAGS += -DVERSION=\"$(VER)\" -I../src -I../wdmd
CFLAGS += -fPIE -DPIE
-LDFLAGS = -Wl,-z,now -Wl,-z,relro -pie
+LDFLAGS += -Wl,-z,now -Wl,-z,relro
LDADD = -lsanlock -lwdmd
all: $(TARGET1) $(TARGET2)
diff --git a/src/Makefile b/src/Makefile
index 73a2b3498475..14c0a53e6aeb 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -94,24 +94,23 @@ VER=$(shell cat ../VERSION)
CFLAGS += -DVERSION=\"$(VER)\"
CMD_CFLAGS = $(CFLAGS) -fPIE -DPIE
+CMD_LDFLAGS = $(LDFLAGS) -Wl,-z,now -Wl,-z,relro
+CMD_LDADD = -lpthread -luuid -lrt -laio -lblkid -lsanlock -L../wdmd -lwdmd
-CMD_LDFLAGS += -Wl,-z,now -Wl,-z,relro -pie
-CMD_LDADD += -lpthread -luuid -lrt -laio -lblkid -lsanlock -L../wdmd -lwdmd
+LIB_ENTIRE_LDFLAGS = $(LDFLAGS) -Wl,-z,relro
+LIB_ENTIRE_LDADD = -lpthread -lrt -laio -lblkid -L../wdmd -lwdmd
-LIB_ENTIRE_LDFLAGS += -Wl,-z,relro -pie
-LIB_ENTIRE_LDADD += -lpthread -lrt -laio -lblkid -L../wdmd -lwdmd
-
-LIB_CLIENT_LDFLAGS += -Wl,-z,relro -pie
+LIB_CLIENT_LDFLAGS = $(LDFLAGS) -Wl,-z,relro
all: $(LIBSO_ENTIRE_TARGET) $(LIBSO_CLIENT_TARGET) $(CMD_TARGET) $(LIBPC_ENTIRE_TARGET) $(LIBPC_CLIENT_TARGET)
$(LIBSO_ENTIRE_TARGET): $(LIB_ENTIRE_SOURCE)
- $(CC) $(CFLAGS) $(LIB_ENTIRE_LDFLAGS) -shared -fPIC -o $@ -Wl,-soname=$(LIB_ENTIRE_TARGET).so.$(SOMAJOR) $^ $(LIB_ENTIRE_LDADD)
+ $(CC) $(CFLAGS) $(LDFLAGS) $(LIB_ENTIRE_LDFLAGS) -shared -fPIC -o $@ -Wl,-soname=$(LIB_ENTIRE_TARGET).so.$(SOMAJOR) $^ $(LIB_ENTIRE_LDADD)
ln -sf $(LIBSO_ENTIRE_TARGET) $(LIB_ENTIRE_TARGET).so
ln -sf $(LIBSO_ENTIRE_TARGET) $(LIB_ENTIRE_TARGET).so.$(SOMAJOR)
$(LIBSO_CLIENT_TARGET): $(LIB_CLIENT_SOURCE)
- $(CC) $(CFLAGS) $(LIB_CLIENT_LDFLAGS) -shared -fPIC -o $@ -Wl,-soname=$(LIB_CLIENT_TARGET).so.$(SOMAJOR) $^
+ $(CC) $(CFLAGS) $(LDFLAGS) $(LIB_CLIENT_LDFLAGS) -shared -fPIC -o $@ -Wl,-soname=$(LIB_CLIENT_TARGET).so.$(SOMAJOR) $^
ln -sf $(LIBSO_CLIENT_TARGET) $(LIB_CLIENT_TARGET).so
ln -sf $(LIBSO_CLIENT_TARGET) $(LIB_CLIENT_TARGET).so.$(SOMAJOR)
diff --git a/wdmd/Makefile b/wdmd/Makefile
index bf871c591943..0c4438950d6e 100644
--- a/wdmd/Makefile
+++ b/wdmd/Makefile
@@ -45,12 +45,12 @@ CFLAGS += -D_GNU_SOURCE -g -O2 \
VER=$(shell cat ../VERSION)
CFLAGS += -DVERSION=\"$(VER)\"
-CMD_LDFLAGS += -Wl,-z,now -Wl,-z,relro -pie
-CMD_LDADD += -lwdmd -lrt
+CMD_LDFLAGS = $(LDFLAGS) -Wl,-z,now -Wl,-z,relro
+CMD_LDADD = -lwdmd -lrt
-LIB_LDFLAGS += -Wl,-z,relro -pie
+LIB_LDFLAGS = $(LDFLAGS) -Wl,-z,relro
-TEST_LDFLAGS = -lwdmd
+TEST_LDFLAGS = $(LDFLAGS) -lwdmd
all: $(SHLIB_TARGET) $(CMD_TARGET) $(TEST_TARGET)
--
2.7.5

View File

@ -1,80 +0,0 @@
From 9edc101e5d8a3e25fa49d30b3a9c3c7691a49a21 Mon Sep 17 00:00:00 2001
From: Nir Soffer <nsoffer@redhat.com>
Date: Thu, 6 Dec 2018 13:23:11 -0600
Subject: [PATCH] lockfile: Keep lockfile owned by root
On Fedora 28, sanlock fails to create the lockfile before dropping
privileges, because /run/sanlock is owned by sanlock, and selinux
disables DAC_OVERRIDE.
To allow root to create the lockfile before dropping privileges
/run/sanlock is owned by group root, and group writable. Since sanlock
never write to the lockfile after dropping privileges, keep the lockfile
owned by root.
Here are /run/sanlock permissions with this change:
$ ls -lhdZ /run/sanlock
drwxrwxr-x. 2 sanlock root system_u:object_r:sanlock_var_run_t:s0 80 Nov 29 23:07 /run/sanlock
$ ls -lhZ /run/sanlock
total 4.0K
-rw-r--r--. 1 root root system_u:object_r:sanlock_var_run_t:s0 5 Nov 29 23:07 sanlock.pid
srw-rw----. 1 sanlock sanlock system_u:object_r:sanlock_var_run_t:s0 0 Nov 29 23:07 sanlock.sock
Signed-off-by: Nir Soffer <nsoffer@redhat.com>
---
src/lockfile.c | 12 ++++--------
src/main.c | 6 +++++-
2 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/src/lockfile.c b/src/lockfile.c
index e3b720c613f8..61847f11c23c 100644
--- a/src/lockfile.c
+++ b/src/lockfile.c
@@ -37,7 +37,10 @@ int lockfile(const char *dir, const char *name, int uid, int gid)
mode_t old_umask;
int fd, rv;
- old_umask = umask(0022);
+ /* Make rundir group writable, allowing creation of the lockfile when
+ * starting as root. */
+
+ old_umask = umask(0002);
rv = mkdir(SANLK_RUN_DIR, 0775);
if (rv < 0 && errno != EEXIST) {
umask(old_umask);
@@ -90,13 +93,6 @@ int lockfile(const char *dir, const char *name, int uid, int gid)
goto fail;
}
- rv = fchown(fd, uid, gid);
- if (rv < 0) {
- log_error("lockfile fchown error %s: %s",
- path, strerror(errno));
- goto fail;
- }
-
return fd;
fail:
close(fd);
diff --git a/src/main.c b/src/main.c
index 0117183def26..86a2725d40f6 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1667,7 +1667,11 @@ static int do_daemon(void)
setup_signals();
setup_logging();
- fd = lockfile(SANLK_RUN_DIR, SANLK_LOCKFILE_NAME, com.uid, com.gid);
+ /* If we run as root, make run_dir owned by root, so we can create the
+ * lockfile when selinux disables DAC_OVERRIDE.
+ * See https://danwalsh.livejournal.com/79643.html */
+
+ fd = lockfile(SANLK_RUN_DIR, SANLK_LOCKFILE_NAME, com.uid, 0);
if (fd < 0) {
close_logging();
return fd;
--
2.7.5

View File

@ -1,17 +0,0 @@
diff --git a/python/Makefile b/python/Makefile
index 92b0c28d520c..4208c8ce0c8a 100644
--- a/python/Makefile
+++ b/python/Makefile
@@ -5,10 +5,10 @@
# of the GNU General Public License v.2.
all:
- python setup.py build
+ python2 setup.py build
install:
- python setup.py install --root=$(DESTDIR)
+ python2 setup.py install --root=$(DESTDIR)
clean:
rm -rf build

View File

@ -1,46 +1,27 @@
%define with_systemd 0%{!?_without_systemd:0}
%if 0%{?fedora} >= 17 || 0%{?rhel} >= 7
%define with_systemd 1
%endif
Name: sanlock
Version: 3.6.0
Release: 8%{?dist}
Version: 3.7.0
Release: 1%{?dist}
Summary: A shared storage lock manager
License: GPLv2 and GPLv2+ and LGPLv2+
URL: https://pagure.io/sanlock/
BuildRequires: gcc
BuildRequires: libblkid-devel libaio-devel python2 python2-devel
%if %{with_systemd}
BuildRequires: systemd-units
%endif
Requires: %{name}-lib = %{version}-%{release}
Requires(pre): /usr/sbin/groupadd
Requires(pre): /usr/sbin/useradd
%if %{with_systemd}
Requires(post): systemd-units
Requires(post): systemd-sysv
Requires(preun): systemd-units
Requires(postun): systemd-units
%endif
Source0: https://releases.pagure.org/sanlock/%{name}-%{version}.tar.gz
Patch0: 0001-Fix-libsanlock-build-on-Unubtu-Debian.patch
Patch1: 0002-fix-makefile-flags.patch
Patch2: 0003-lockfile-Keep-lockfile-owned-by-root.patch
Patch3: 0004-python-Fix-build-on-Fedora-29.patch
%description
The sanlock daemon manages leases for applications on hosts using shared storage.
%prep
%setup -q
%patch0 -p1 -b .0001-Fix-libsanlock-build-on-Unubtu-Debian.patch
%patch1 -p1 -b .0002-fix-makefile-flags.patch
%patch2 -p1 -b .0003-lockfile-Keep-lockfile-owned-by-root.patch
%patch3 -p1 -b .0004-python-Fix-build-on-Fedora-29.patch
%build
%set_build_flags
@ -67,15 +48,10 @@ make -C reset \
DESTDIR=$RPM_BUILD_ROOT
%if %{with_systemd}
install -D -m 0644 init.d/sanlock.service.native $RPM_BUILD_ROOT/%{_unitdir}/sanlock.service
install -D -m 0755 init.d/wdmd $RPM_BUILD_ROOT/usr/lib/systemd/systemd-wdmd
install -D -m 0644 init.d/wdmd.service.native $RPM_BUILD_ROOT/%{_unitdir}/wdmd.service
install -D -m 0644 init.d/sanlk-resetd.service $RPM_BUILD_ROOT/%{_unitdir}/sanlk-resetd.service
%else
install -D -m 0755 init.d/sanlock $RPM_BUILD_ROOT/%{_initddir}/sanlock
install -D -m 0755 init.d/wdmd $RPM_BUILD_ROOT/%{_initddir}/wdmd
%endif
install -D -m 0644 src/logrotate.sanlock \
$RPM_BUILD_ROOT/etc/logrotate.d/sanlock
@ -99,29 +75,18 @@ getent passwd sanlock > /dev/null || /usr/sbin/useradd \
/usr/sbin/usermod -a -G disk sanlock
%post
%if %{with_systemd}
%systemd_post wdmd.service sanlock.service
%endif
%preun
%if %{with_systemd}
%systemd_preun wdmd.service sanlock.service
%endif
%postun
%if %{with_systemd}
%systemd_postun
%endif
%files
%if %{with_systemd}
/usr/lib/systemd/systemd-wdmd
%{_unitdir}/sanlock.service
%{_unitdir}/wdmd.service
%else
%{_initddir}/sanlock
%{_initddir}/wdmd
%endif
%{_sbindir}/sanlock
%{_sbindir}/wdmd
%dir %{_sysconfdir}/wdmd.d
@ -205,15 +170,16 @@ common sanlock lockspace.
%files -n sanlk-reset
%{_sbindir}/sanlk-reset
%{_sbindir}/sanlk-resetd
%if %{with_systemd}
%{_unitdir}/sanlk-resetd.service
%endif
%dir %attr(-,root,root) %{_localstatedir}/run/sanlk-resetd
%{_mandir}/man8/sanlk-reset*
%changelog
* Wed Mar 20 2019 Nir Soffer <nsoffer@redhat.com> - 3.7.0-1
- remove unneeded with_systemd macro
- update to sanlock 3.7.0
* Sat Feb 2 2019 Nir Soffer <nsoffer@redhat.com> - 3.6.0-8
- fix build on Fedora rawhide