Mail archive
alpine-aports

Re: [alpine-aports] [PATCH] testing/csync2: some cleanups in strlcpy patch. post-install generate required certificate and setup inetd service

From: Sören Tempel <soeren_at_soeren-tempel.net>
Date: Wed, 30 Sep 2015 16:52:59 +0200

On 30.09.15, Valery Kartel wrote:
> --- a/testing/csync2/APKBUILD
> +++ b/testing/csync2/APKBUILD
> _at_@ -4,22 +4,21 @@
> # Maintainer: Natanael Copa <ncopa_at_alpinelinux.org>
> 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"
> +license="GPL-2+"
> +makedepends="autoconf automake librsync-dev gnutls-dev sqlite-dev mysql-dev postgresql-dev"
> 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"
> +install="$pkgname.post-install $pkgname.post-upgrade"
>
> _builddir="$srcdir"/$pkgname-$pkgver
> +
> prepare() {
> cd "$_builddir"
> for i in $source; do
> _at_@ -27,6 +26,7 @@ prepare() {
> *.patch) msg $i; patch -p1 -i "$srcdir"/$i || return 1;;
> esac
> done
> + autoreconf --install --force
> }
>
> build() {
> _at_@ -45,31 +45,26 @@ build() {
> package() {
> cd "$_builddir"
> make DESTDIR="$pkgdir" install || return 1
> - cp doc/* "$pkgdir"/usr/share/doc/$pkgname/ || return 1
> -
> - install -m755 -D "$srcdir"/$pkgname.initd \
> - "$pkgdir"/etc/init.d/$pkgname || return 1
> + install -m755 -D "$srcdir"/$pkgname.initd "$pkgdir"/etc/init.d/$pkgname
> + cp doc/* "$pkgdir"/usr/share/doc/$pkgname/
> }
>
> compare() {
> subpkgdesc="csync2 compare script"
> arch="noarch"
> - depends="bash perl-digest-md5"
> -
> + depents="bash perl-digest-md5"
> mkdir -p "$subpkgdir"/usr/sbin
> - mv "$pkgdir"/usr/sbin/$pkgname-compare \
> - "$subpkgdir"/usr/sbin/ || return 1
> + mv "$pkgdir"/usr/sbin/$pkgname-compare "$subpkgdir"/usr/sbin/
> }

This only seems to undo changes I explicitly committed in
b5ec9730c022a6686955a4648329868cfdd598af for instance you readded your
`depents` typo in the compare subpackage.

> --- /dev/null
> +++ b/testing/csync2/csync2.post-install
> _at_@ -0,0 +1,24 @@
> +#!/bin/sh
> +
> +SSL="/etc/csync2/csync2_ssl_"
> +SERV="/etc/services"
> +INETD="/etc/inetd.conf"
> +
> +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
> +
> +if [ ! -f ${SERV} ]; then
> + touch ${SERV}
> +fi
> +grep -q csync2 ${SERV} || echo -e "csync2\t\t30865/tcp" >> ${SERV}
> +
> +if [ ! -f ${INETD} ]; then
> + touch ${INETD}
> +fi
> +grep -q csync2 ${INETD} || echo "csync2 stream tcp nowait root /usr/sbin/csync2 csync2 -i" >> ${INETD}
> +
> +exit 0

The post-install script was removed by me for two reason: 1) You modify
existing configuration files in a post-install script thus .apk-new
files won't be created but you will write to the file directly therefore
changing user configuration even if the users doesn't want to have a
csync entry in his/her inetd.conf. 2) You create an openssl certificate
without a configuration file passed to openssl using `-config` since you
pipe it through yes(1) it will use the default values for all fields
which I dislike. Take a look at main/dovecot to see how to do this
correctly.

> index 0000000..4f2278b
> --- /dev/null
> +++ b/testing/csync2/have-strlcpy.patch
> _at_@ -0,0 +1,41 @@
> +--- old/config.h.in
> ++++ new/config.h.in
> +_at_@ -1,5 +1,8 @@
> + /* config.h.in. Generated from configure.ac by autoheader. */
> +
> ++/* Define to 1 if you have the `strlcpy' function. */
> ++#undef HAVE_STRLCPY
> ++
> + /* Define to 1 if you have the `fchmod' function. */
> + #undef HAVE_FCHMOD
> +
> +--- old/configure.ac
> ++++ new/configure.ac
> +_at_@ -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
> +_at_@ -38,7 +38,7 @@
> + #include <w32api/windows.h>
> + #endif
> +
> +-
> ++#ifndef HAVE_STRLCPY
> + /* This has been taken from rsync:lib/compat.c */
> +
> + /**
> +_at_@ -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
> _at_@ -1,20 +0,0 @@
> ---- old/rsync.c
> -+++ new/rsync.c
> -_at_@ -48,7 +48,7 @@
> - * _at_param bufsize is the size of the destination buffer.
> - *
> - * _at_return index of the terminating byte.
> -- **/
> -+ * disabled
> - static size_t strlcpy(char *d, const char *s, size_t bufsize)
> - {
> - size_t len = strlen(s);
> -_at_@ -61,7 +61,7 @@
> - }
> - return ret;
> - }
> --
> -+ **/
> - /* splits filepath at the last '/', if any, like so:
> - * dirname basename filepath
> - * "/" "" "/"

The patches look ok, please submit them without your APKBULID and
post-install script changes.

Sören.


---
Unsubscribe:  alpine-aports+unsubscribe_at_lists.alpinelinux.org
Help:         alpine-aports+help_at_lists.alpinelinux.org
---
Received on Wed Sep 30 2015 - 16:52:59 GMT