Subject: [bug#50808] [PATCH] services: rsync: support binding rsync to a specific IP address

From: Jacob Adams <[email-masked]>
Date: Sat, 25 Sep 2021 23:05:11 -0400

* gnu/services/rsync.scm: Support IP address configuration
 * doc/guix.texi: Document new address rsync configuration option
---
 doc/guix.texi          | 4 ++++
 gnu/services/rsync.scm | 5 ++++-
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index 4bf14014eb..9a858de2d9 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -17151,6 +17151,10 @@ Data type representing the configuration for @code{rsync-service}.
 @item @code{package} (default: @var{rsync})
 @code{rsync} package to use.
 
+@item @code{address} (default: @code{""})
+IP address on which @command{rsync} listens for incoming connections.
+If unspecified, it defaults to listening on all available addresses.
+
 @item @code{port-number} (default: @code{873})
 TCP port on which @command{rsync} listens for incoming connections.  If port
 is less than @code{1024} @command{rsync} needs to be started as the
diff --git a/gnu/services/rsync.scm b/gnu/services/rsync.scm
index 6c117bbda4..0a9ed82a42 100644
--- a/gnu/services/rsync.scm
+++ b/gnu/services/rsync.scm
@@ -45,6 +45,8 @@
   rsync-configuration?
   (package       rsync-configuration-package              ; package
                  (default rsync))
+  (address       rsync-configuration-address              ; string
+                 (default ""))
   (port-number   rsync-configuration-port-number          ; integer
                  (default 873))
   (pid-file      rsync-configuration-pid-file             ; string
@@ -110,7 +112,7 @@
 (define rsync-config-file
   ;; Return the rsync configuration file corresponding to CONFIG.
   (match-lambda
-    (($ <rsync-configuration> package port-number pid-file lock-file log-file
+    (($ <rsync-configuration> package address port-number pid-file lock-file log-file
                               use-chroot? share-path share-comment read-only?
                               timeout user group uid gid)
      (if (not (string=? user "root"))
@@ -132,6 +134,7 @@
       "pid file = " pid-file "\n"
       "lock file = " lock-file "\n"
       "log file = " log-file "\n"
+      (if (not (string=? address "")) (string-append "address = " address "\n") "")
       "port = " (number->string port-number) "\n"
       "use chroot = " (if use-chroot? "true" "false") "\n"
       (if uid (string-append "uid = " uid "\n") "")
-- 
2.30.2