From d49da2f96efb35df7d43e61ea479ace079d379de Mon Sep 17 00:00:00 2001 From: Timo Makinen Date: Mon, 20 May 2019 23:07:35 +0300 Subject: [PATCH] initial version of rsync module which supports running rsynd server on top of tls --- roles/rsync/client/files/rsync-ssl | 3 ++ roles/rsync/client/files/rsync-ssl-tunnel | 35 +++++++++++++++++ roles/rsync/client/tasks/main.yml | 25 ++++++++++++ roles/rsync/server/files/systemd-stunnel.conf | 3 ++ roles/rsync/server/meta/main.yml | 3 ++ roles/rsync/server/tasks/main.yml | 38 +++++++++++++++++++ .../server/templates/rsyncd-stunnel.conf.j2 | 10 +++++ roles/rsync/server/templates/rsyncd.conf.j2 | 11 ++++++ 8 files changed, 128 insertions(+) create mode 100755 roles/rsync/client/files/rsync-ssl create mode 100755 roles/rsync/client/files/rsync-ssl-tunnel create mode 100644 roles/rsync/client/tasks/main.yml create mode 100644 roles/rsync/server/files/systemd-stunnel.conf create mode 100644 roles/rsync/server/meta/main.yml create mode 100644 roles/rsync/server/tasks/main.yml create mode 100644 roles/rsync/server/templates/rsyncd-stunnel.conf.j2 create mode 100644 roles/rsync/server/templates/rsyncd.conf.j2 diff --git a/roles/rsync/client/files/rsync-ssl b/roles/rsync/client/files/rsync-ssl new file mode 100755 index 0000000..8b50e7b --- /dev/null +++ b/roles/rsync/client/files/rsync-ssl @@ -0,0 +1,3 @@ +#!/bin/sh + +/usr/bin/rsync --rsh /usr/local/libexec/rsync-ssl-tunnel "$@" diff --git a/roles/rsync/client/files/rsync-ssl-tunnel b/roles/rsync/client/files/rsync-ssl-tunnel new file mode 100755 index 0000000..ae2d509 --- /dev/null +++ b/roles/rsync/client/files/rsync-ssl-tunnel @@ -0,0 +1,35 @@ +#!/bin/bash + +echo "$@" > /tmp/foo.out + +key="/etc/pki/tls/private/$(hostname -f).key" +cert="/etc/pki/tls/certs/$(hostname -f).crt" +cafile="/etc/pki/tls/certs/ca.crt" +port=${RSYNC_SSL_PORT:-873} + +# If the user specified USER@HOSTNAME::module, then rsync passes us +# the -l USER option too, so we must be prepared to ignore it. +if [ x"$1" = x"-l" ]; then + shift 2 +fi + +hostname=$1 +shift + +if [ x"$hostname" = x -o x"$1" != x"rsync" -o x"$2" != x"--server" -o x"$3" != x"--daemon" ]; then + echo "Usage: stunnel-rsync HOSTNAME rsync --server --daemon ." 1>&2 + exit 1 +fi + +# devzero@web.de came up with this no-tmpfile calling syntax: +stunnel -fd 10 11<&0 <