emacs-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#63561: closed ([PATCH 1/2] services: rsync: Use make-inetd-construct


From: GNU bug Tracking System
Subject: bug#63561: closed ([PATCH 1/2] services: rsync: Use make-inetd-constructor.)
Date: Fri, 19 May 2023 03:21:02 +0000

Your message dated Thu, 18 May 2023 23:20:25 -0400
with message-id <87ttw9knwm.fsf@gmail.com>
and subject line Re: bug#63562: [PATCH 2/2] services: rsync: Use least 
authority wrapper.
has caused the debbugs.gnu.org bug report #63562,
regarding [PATCH 1/2] services: rsync: Use make-inetd-constructor.
to be marked as done.

(If you believe you have received this mail in error, please contact
help-debbugs@gnu.org.)


-- 
63562: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=63562
GNU Bug Tracking System
Contact help-debbugs@gnu.org with problems
--- Begin Message --- Subject: [PATCH 1/2] services: rsync: Use make-inetd-constructor. Date: Wed, 17 May 2023 21:56:17 -0400
* gnu/services/rsync.scm (rsync-shepherd-service): Use make-inetd-constructor
if available in start slot.
* gnu/tests/rsync.scm (run-rsync-test): Delete "PID file" test.
---
 gnu/services/rsync.scm | 44 ++++++++++++++++++++++++++++++++++--------
 gnu/tests/rsync.scm    |  6 ------
 2 files changed, 36 insertions(+), 14 deletions(-)

diff --git a/gnu/services/rsync.scm b/gnu/services/rsync.scm
index aeb4275031..826b757b1c 100644
--- a/gnu/services/rsync.scm
+++ b/gnu/services/rsync.scm
@@ -1,6 +1,7 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2017 Oleg Pykhalov <go.wigust@gmail.com>
 ;;; Copyright © 2021, 2023 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2023 Maxim Cournoyer <maxim.cournoyer@gmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -221,23 +222,50 @@ (define (rsync-config-file config)
 
 (define (rsync-shepherd-service config)
   "Return a <shepherd-service> for rsync with CONFIG."
+
+  ;; XXX: Predicates copied from (gnu services ssh).
+  (define inetd-style?
+    #~(and (defined? 'make-inetd-constructor)
+           (not (string=? (@ (shepherd config) Version) "0.9.0"))))
+
+  (define ipv6-support?
+    #~(catch 'system-error
+        (lambda ()
+          (let ((sock (socket AF_INET6 SOCK_STREAM 0)))
+            (close-port sock)
+            #t))
+        (const #f)))
+
   (let* ((rsync       (rsync-configuration-package config))
          (pid-file    (rsync-configuration-pid-file config))
          (port-number (rsync-configuration-port-number config))
          (user        (rsync-configuration-user config))
          (group       (rsync-configuration-group config))
-         (config-file (rsync-config-file config)))
+         (config-file (rsync-config-file config))
+         (rsync-command #~(list (string-append #$rsync "/bin/rsync")
+                                "--config" #$config-file "--daemon")))
     (list (shepherd-service
            (provision '(rsync))
            (documentation "Run rsync daemon.")
            (actions (list (shepherd-configuration-action config-file)))
-           (start #~(make-forkexec-constructor
-                     (list (string-append #$rsync "/bin/rsync")
-                           "--config" #$config-file
-                           "--daemon")
-                     #:pid-file #$pid-file
-                     #:user #$user
-                     #:group #$group))
+           (start #~(if #$inetd-style?
+                        (make-inetd-constructor
+                         #$rsync-command
+                         (cons (endpoint
+                                (make-socket-address AF_INET INADDR_ANY
+                                                     #$port-number))
+                               (if #$ipv6-support?
+                                   (list
+                                    (endpoint
+                                     (make-socket-address AF_INET6 IN6ADDR_ANY
+                                                          #$port-number)))
+                                   '()))
+                         #:user #$user
+                         #:group #$group)
+                        (make-forkexec-constructor #$rsync-command
+                                                   #:pid-file #$pid-file
+                                                   #:user #$user
+                                                   #:group #$group)))
            (stop #~(make-kill-destructor))))))
 
 (define rsync-service-type
diff --git a/gnu/tests/rsync.scm b/gnu/tests/rsync.scm
index ea53a157bb..182e5f76ff 100644
--- a/gnu/tests/rsync.scm
+++ b/gnu/tests/rsync.scm
@@ -70,12 +70,6 @@ (define* (run-rsync-test rsync-os #:optional (rsync-port 
873))
                 (start-service 'rsync))
              marionette))
 
-          ;; Make sure the PID file is created.
-          (test-assert "PID file"
-            (marionette-eval
-             '(file-exists? "/var/run/rsyncd/rsyncd.pid")
-             marionette))
-
           (test-assert "Test file copied to share"
             (marionette-eval
              '(begin

base-commit: 9c161c1f0def13676002ce34625ba023857b9ab2
-- 
2.39.2




--- End Message ---
--- Begin Message --- Subject: Re: bug#63562: [PATCH 2/2] services: rsync: Use least authority wrapper. Date: Thu, 18 May 2023 23:20:25 -0400 User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux)
Hi Ludo,

Ludovic Courtès <ludo@gnu.org> writes:

> Maxim Cournoyer <maxim.cournoyer@gmail.com> skribis:
>
>> * gnu/services/rsync.scm (rsync-shepherd-service) Wrap rsync command in a
>> least-authority-wrapper.
>
> Nice, LGTM!
>
> Since berlin relies on it for backups, we’ll have to double-check that
> it all goes well, in case we overlooked something.

Thanks for the review!  I've installed the change.

-- 
Thanks,
Maxim


--- End Message ---

reply via email to

[Prev in Thread] Current Thread [Next in Thread]