Subject: [alpine-aports] [PATCH] testing/csync2: cleanups in strlcpy patch. ssl key&cert MUST be generated or csync2 does not sync. ssl defaults must be configured in /etc/ssl/openssl.conf

From: Valery Kartel <[email-masked]>
Date: Mon, 5 Oct 2015 19:47:37 +0300

---
 testing/csync2/APKBUILD                    | 15 ++++++++-------
 testing/csync2/csync2.post-install         | 12 ++++++++++++
 testing/csync2/have-strlcpy.patch          | 30 ++++++++++++++++++++++++++++++
 testing/csync2/rsync-strlcpy-disable.patch | 20 --------------------
 4 files changed, 50 insertions(+), 27 deletions(-)
 create mode 100644 testing/csync2/csync2.post-install
 create mode 100644 testing/csync2/have-strlcpy.patch
 delete mode 100644 testing/csync2/rsync-strlcpy-disable.patch

diff --git a/testing/csync2/APKBUILD b/testing/csync2/APKBUILD
index ada4ab4..c01f881 100644
--- a/testing/csync2/APKBUILD
+++ b/testing/csync2/APKBUILD
@@ -4,19 +4,19 @@
 # Maintainer: Natanael Copa <[email-masked]>
 pkgname=csync2
 pkgver=2.0
-pkgrel=1
+pkgrel=2
 pkgdesc="Cluster synchronization tool"
 url="http://oss.linbit.com/csync2/"
 arch="all"
 license="GPL2+"
 depends=""
 depends_dev=""
-makedepends="librsync-dev gnutls-dev sqlite-dev mysql-dev postgresql-dev"
-install="$pkgname.post-upgrade"
+makedepends="autoconf automake librsync-dev gnutls-dev sqlite-dev mysql-dev postgresql-dev"
+install="$pkgname.post-install $pkgname.post-upgrade"
 subpackages="$pkgname-compare $pkgname-doc"
 source="http://oss.linbit.com/$pkgname/$pkgname-$pkgver.tar.gz
 	longlong-format.patch
-	rsync-strlcpy-disable.patch
+	have-strlcpy.patch
 	$pkgname.initd"
 
 _builddir="$srcdir"/$pkgname-$pkgver
@@ -27,6 +27,7 @@ prepare() {
 		*.patch) msg $i; patch -p1 -i "$srcdir"/$i || return 1;;
 		esac
 	done
+	autoreconf --install --force
 }
 
 build() {
@@ -63,13 +64,13 @@ compare() {
 
 md5sums="4069fc9e86e8508c392fe2862059eb91  csync2-2.0.tar.gz
 8fc73254db29316f9125761d18f1ed46  longlong-format.patch
-5908c4106d4866ab1c1f88f4c9482c9f  rsync-strlcpy-disable.patch
+19b69f88f78ef3faae0c5b5783da6aa2  have-strlcpy.patch
 bf77ad1534addbd596a08d1f7084e85e  csync2.initd"
 sha256sums="11cb37380fb185bce0c22b804fec9b01c385d9d83cc528cfd48d748453834fa2  csync2-2.0.tar.gz
 afb1317987cc4b81908bc437269162c7af23b34e6842306483da5b53efce2db3  longlong-format.patch
-339c7f5d91ff7ed3e63de5a5e39cf17efd7533f9c460eb81db76003acb164017  rsync-strlcpy-disable.patch
+342fd9ee3245a2ad5d68870450d2dcb6db78ff8c1558ff80b69e01c5e8d45752  have-strlcpy.patch
 0c1488e6bca746d8e5c5e3d893997b94e3c1766de69270d7c5c5a2282fb3b767  csync2.initd"
 sha512sums="f91fd222f67affe9634471d341b43ff67854a6ed25b620301a454e98a79a9fb80b2a66eb8713546758fd08300d52751e5ca7472c696daa20ee11779b87a830f8  csync2-2.0.tar.gz
 38a17cbf23cbccd4996ad1af049851e33179586e619e3f3edbfacbaa36662e44d916839acd59b1cfc67b3af9042c3258068ec9e5b57f7e26c00a41a0e6f0e148  longlong-format.patch
-c44ad7e7fb7093f66fd9582b5309e3929dfdf7b76ef4d234d346fa25158f088b9436db9a1989d036d739570459867210d053af62125facb66e4f5202448c7bea  rsync-strlcpy-disable.patch
+7e5493b3c6f61ea5eb4e67ef3e7f3551d1801f5ff4b2ab929e51753955137b36823937ec2031244c1d1151823f35a8e1865084b61a12896be5112230069e9b25  have-strlcpy.patch
 5050af0004679c7c63e0eb41a8dfed9ca1d92ce6acaee7c5e2150ce808474c61e6feb84f9b77185a282fbb36de9b981e1eab937ee0fb1ec045ab587960fda812  csync2.initd"
diff --git a/testing/csync2/csync2.post-install b/testing/csync2/csync2.post-install
new file mode 100644
index 0000000..8d6331f
--- /dev/null
+++ b/testing/csync2/csync2.post-install
@@ -0,0 +1,12 @@
+#!/bin/sh
+
+SSL="/etc/csync2/csync2_ssl_"
+
+if [ ! -f ${SSL}key.pem -o ! -f ${SSL}cert.pem ]; then
+        openssl genrsa -out ${SSL}key.pem 1024 >/dev/null 2>&1
+        yes '' | openssl req -new -key ${SSL}key.pem -out ${SSL}cert.csr >/dev/null 2>&1
+        openssl x509 -req -days 3600 -in ${SSL}cert.csr -out ${SSL}cert.pem -signkey ${SSL}key.pem >/dev/null 2>&1
+        rm ${SSL}cert.csr
+fi
+
+exit 0
diff --git a/testing/csync2/have-strlcpy.patch b/testing/csync2/have-strlcpy.patch
new file mode 100644
index 0000000..ba4221a
--- /dev/null
+++ b/testing/csync2/have-strlcpy.patch
@@ -0,0 +1,30 @@
+--- old/configure.ac
++++ new/configure.ac
+@@ -43,7 +43,7 @@
+
+
+ dnl inspired by rsync's configure.ac
+-AC_CHECK_FUNCS(fchmod setmode open64 mkstemp64)
++AC_CHECK_FUNCS(strlcpy fchmod setmode open64 mkstemp64)
+ AC_CACHE_CHECK([for secure mkstemp],csync_cv_HAVE_SECURE_MKSTEMP,[
+ AC_TRY_RUN([#include <stdlib.h>
+ #include <sys/types.h>
+--- old/rsync.c
++++ new/rsync.c
+@@ -38,7 +38,7 @@
+ #include <w32api/windows.h>
+ #endif
+
+-
++#ifndef HAVE_STRLCPY
+ /* This has been taken from rsync:lib/compat.c */
+
+ /**
+@@ -61,6 +61,7 @@
+         }
+         return ret;
+ }
++#endif
+
+ /* splits filepath at the last '/', if any, like so:
+  *     dirname         basename        filepath 
\ No newline at end of file
diff --git a/testing/csync2/rsync-strlcpy-disable.patch b/testing/csync2/rsync-strlcpy-disable.patch
deleted file mode 100644
index 5d28e1d..0000000
--- a/testing/csync2/rsync-strlcpy-disable.patch
+++ /dev/null
@@ -1,20 +0,0 @@
---- old/rsync.c
-+++ new/rsync.c
-@@ -48,7 +48,7 @@
-  * @param bufsize is the size of the destination buffer.
-  *
-  * @return index of the terminating byte.
-- **/
-+ * disabled
- static size_t strlcpy(char *d, const char *s, size_t bufsize)
- {
-         size_t len = strlen(s);
-@@ -61,7 +61,7 @@
-         }
-         return ret;
- }
--
-+ **/
- /* splits filepath at the last '/', if any, like so:
-  *	dirname		basename	filepath
-  *	"/"		""		"/"
-- 
2.5.3

---
Unsubscribe:  [email-masked]
Help:         [email-masked]
---

---

From: Sören Tempel <[email-masked]>
Date: Tue, 6 Oct 2015 16:10:52 +0200

> +++ b/testing/csync2/csync2.post-install

I told you this 3 times already: I doesn't make much sense to generate
an openssl certificate which uses the default values for all fields. The
fact that csync2 doesn't csync without an OpenSSL certificate doesn't
change my opinion on this. For other aports like testing/opensmtpd you
also have to generate your SSL cert manually, it's not that hard...

Sören.

---