diff --git a/bind-to-local-hostname.patch b/bind-to-local-hostname.patch deleted file mode 100644 index 39ffe34..0000000 --- a/bind-to-local-hostname.patch +++ /dev/null @@ -1,38 +0,0 @@ -Index: csync2-1.34/conn.c -=================================================================== ---- csync2-1.34.orig/conn.c -+++ csync2-1.34/conn.c -@@ -50,7 +50,9 @@ SSL *conn_ssl; - int conn_open(const char *peername) - { - struct sockaddr_in sin; -+ struct sockaddr_in sme; - struct hostent *hp; -+ struct hostent *me; - int on = 1; - - hp = gethostbyname(peername); -@@ -69,6 +71,23 @@ int conn_open(const char *peername) - bcopy(hp->h_addr, &sin.sin_addr, hp->h_length); - sin.sin_port = htons(csync_port); - -+ /* Try to bind to IP address of local hostname, else in cases where -+ * there's multiple local IPs on the same subnet, we might autobind -+ * to the wrong one, and the remote csync2 instance will fail because -+ * it verifies the expected hostname against the initiating IP. -+ * If the explicit bind fails for some reason though, we'll still -+ * try to connect (it might work, and it can't hurt...). -+ */ -+ me = gethostbyname(myhostname); -+ if (me) { -+ sme.sin_family = me->h_addrtype; -+ bcopy(me->h_addr, &sme.sin_addr, me->h_length); -+ sme.sin_port = 0; /* random port */ -+ if (bind(conn_fd_in, (struct sockaddr *)&sme, sizeof(sme)) < 0) { -+ csync_debug(1, "Can't bind local socket (attempting connect anyway).\n"); -+ } -+ } -+ - if (connect(conn_fd_in, (struct sockaddr *)&sin, sizeof (sin)) < 0) { - csync_debug(1, "Can't connect to remote host.\n"); - close(conn_fd_in); conn_fd_in = -1; diff --git a/csync2-fix-xinetd.patch b/csync2-fix-xinetd.patch index 3782eb6..67e9559 100644 --- a/csync2-fix-xinetd.patch +++ b/csync2-fix-xinetd.patch @@ -1,15 +1,17 @@ ---- csync2-1.33/csync2.xinetd.fix-xinetd 2007-01-24 21:18:04.000000000 +0100 -+++ csync2-1.33/csync2.xinetd 2007-01-24 21:19:47.000000000 +0100 +Index: csync2-2.0+git.1368794815.cf835a7/csync2.xinetd +=================================================================== +--- csync2-2.0+git.1368794815.cf835a7.orig/csync2.xinetd ++++ csync2-2.0+git.1368794815.cf835a7/csync2.xinetd @@ -1,4 +1,4 @@ -# default: on +# default: off # description: csync2 service csync2 { -@@ -9,7 +9,9 @@ +@@ -9,7 +9,9 @@ service csync2 group = root server = /usr/sbin/csync2 - server_args = -i + server_args = -i -l + port = 30865 + type = UNLISTED #log_on_failure += USERID diff --git a/csync2.socket b/csync2.socket new file mode 100644 index 0000000..80d7190 --- /dev/null +++ b/csync2.socket @@ -0,0 +1,6 @@ +[Socket] +ListenStream=30865 +Accept=yes + +[Install] +WantedBy=sockets.target diff --git a/csync2.spec b/csync2.spec index 41753bd..02c8cc5 100644 --- a/csync2.spec +++ b/csync2.spec @@ -28,29 +28,27 @@ Url: http://oss.linbit.com/csync2/ Source0: %{name}-%{version}.tar.bz2 Source1: csync2-README.quickstart Source2: csync2-rm-ssl-cert -# PATCH-MISSING-TAG -- See http://wiki.opensuse.org/openSUSE:Packaging_Patches_guidelines +Source3: csync2.socket +Source4: csync2@.service Patch0: csync2-fix-xinetd.patch -# PATCH-MISSING-TAG -- See http://wiki.opensuse.org/openSUSE:Packaging_Patches_guidelines -Patch3: force-debug-stderr-off-inetd.patch -# PATCH-MISSING-TAG -- See http://wiki.opensuse.org/openSUSE:Packaging_Patches_guidelines -Patch4: bind-to-local-hostname.patch Patch10: add-ac_prog_cpp.patch Patch11: fix-csync2_ssl_cert-filename.patch Patch12: fix-sonames.patch Requires: openssl Requires: sqlite3 +%{?systemd_requires} BuildRequires: autoconf BuildRequires: automake BuildRequires: bison BuildRequires: flex BuildRequires: libgnutls-devel -BuildRequires: libmysqlclient-devel -BuildRequires: librsync-devel BuildRequires: librsync-devel BuildRequires: pkgconfig -BuildRequires: postgresql-devel BuildRequires: sqlite3-devel +%if 0%{?suse_version} >= 1210 +BuildRequires: systemd +%endif # texlive is for pdflatex to build PDF version of the manual BuildRequires: texlive-latex BuildRequires: texlive-nopageno @@ -68,23 +66,18 @@ It is expedient for HA-clusters, HPC-clusters, COWs and server farms. # Is this next really necessary? %{?suse_update_config:%{suse_update_config}} -#%patch0 -p1 -b .fix-xinetd -# might actually want patch3 -#%patch3 -p1 -# patch4 needs rewriting, presumably -#%patch4 -p1 +%patch0 -p1 %patch10 -p1 %patch11 -p1 %patch12 -p1 %build -export CFLAGS="$RPM_OPT_FLAGS -I/usr/include/pgsql" +export CFLAGS="$RPM_OPT_FLAGS" if ! [ -f configure ]; then ./autogen.sh; fi -%configure --enable-mysql --enable-postgres --enable-sqlite3 \ +%configure --enable-sqlite3 \ --sysconfdir=%{_sysconfdir}/csync2 --docdir=%{_docdir}/%{name} -make all -#make %{?_smp_mflags} +make %{?_smp_mflags} %install %makeinstall @@ -92,11 +85,18 @@ mkdir -p %{buildroot}%{_localstatedir}/lib/csync2 install -p -D -m 644 csync2.xinetd %{buildroot}%{_sysconfdir}/xinetd.d/csync2 install -p -m 644 %{SOURCE1} %{buildroot}%{_docdir}/%{name}/README.quickstart install -p -m 755 %{SOURCE2} %{buildroot}%{_sbindir}/csync2-rm-ssl-cert +mkdir -p %{buildroot}%{_unitdir} +install -p -m 644 %{SOURCE3} %{buildroot}%{_unitdir}/ +install -p -m 644 %{SOURCE4} %{buildroot}%{_unitdir}/ # We need these empty files to be able to %%ghost them touch %{buildroot}%{_sysconfdir}/csync2/csync2_ssl_key.pem touch %{buildroot}%{_sysconfdir}/csync2/csync2_ssl_cert.pem +%pre +%service_add_pre csync2.socket + %post +%service_add_post csync2.socket umask 077 if [ ! -f %{_sysconfdir}/csync2/csync2_ssl_key.pem ]; then /usr/bin/openssl genrsa -rand /proc/apm:/proc/cpuinfo:/proc/dma:/proc/filesystems:/proc/interrupts:/proc/ioports:/proc/pci:/proc/rtc:/proc/uptime 1024 > %{_sysconfdir}/csync2/csync2_ssl_key.pem 2>/dev/null @@ -118,15 +118,21 @@ EOF fi %preun +%service_del_preun csync2.socket # Cleanup all databases upon last removal if [ $1 -eq 0 ]; then rm -f %{_localstatedir}/lib/csync2/* fi +%postun +%service_del_postun csync2.socket + %files %defattr(-,root,root) %{_sbindir}/csync2 %{_sbindir}/csync2-compare +%{_unitdir}/csync2.socket +%{_unitdir}/csync2@.service %dir %{_localstatedir}/lib/csync2/ %{_docdir}/%{name} %dir %{_sysconfdir}/csync2/ diff --git a/csync2@.service b/csync2@.service new file mode 100644 index 0000000..40c17d0 --- /dev/null +++ b/csync2@.service @@ -0,0 +1,9 @@ +[Unit] +Description=csync2 connection handler %I %f %u +After=syslog.target + +[Service] +ExecStart=-/usr/sbin/csync2 -i -v +StandardInput=socket +StandardOutput=socket + diff --git a/force-debug-stderr-off-inetd.patch b/force-debug-stderr-off-inetd.patch deleted file mode 100644 index b0ee06d..0000000 --- a/force-debug-stderr-off-inetd.patch +++ /dev/null @@ -1,21 +0,0 @@ -Index: csync2-1.34/csync2.c -=================================================================== ---- csync2-1.34.orig/csync2.c -+++ csync2-1.34/csync2.c -@@ -458,6 +458,16 @@ int main(int argc, char ** argv) - for (i=0; myhostname[i]; i++) - myhostname[i] = tolower(myhostname[i]); - -+ if ( mode == MODE_INETD ) { -+ /* Force debug level below zero when running under inetd, -+ * else stderr junk may be emitted back to some other host -+ * which breaks the protocol. One case is where a target -+ * directory does not exist resulting in allegations of -+ * I/O error during rsync write (bnc#752563) -+ */ -+ csync_debug_level = -1; -+ } -+ - /* Stand-alone server mode. This is a hack.. - */ - if ( mode == MODE_SERVER || mode == MODE_SINGLE ) {