[PATCH] gnu: Add rsync service.

  • Done
  • quality assurance status badge
Details
3 participants
  • Oleg Pykhalov
  • Ludovic Courtès
  • Christopher Baines
Owner
unassigned
Submitted by
Oleg Pykhalov
Severity
normal
O
O
Oleg Pykhalov wrote on 28 Jul 2017 00:01
(address . guix-patches@gnu.org)(name . Oleg Pykhalov)(address . go.wigust@gmail.com)
20170727220151.2116-1-go.wigust@gmail.com
* doc/guix.texi (Incremental file transfer): Add documentation.
* gnu/services/rsync.scm (<rsync-configuration>): New record type.
(rsync-accounts, rsync-shepherd-service): New service extensions.
(rsync-service-type): New service type.
---
doc/guix.texi | 58 ++++++++++++++++++
gnu/local.mk | 1 +
gnu/services/rsync.scm | 162 +++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 221 insertions(+)
create mode 100644 gnu/services/rsync.scm

Toggle diff (251 lines)
diff --git a/doc/guix.texi b/doc/guix.texi
index e8c4e0eaf..a3745ae01 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -15661,6 +15661,64 @@ Extra options will be passed to @code{git daemon}, please run
@end table
@end deftp
+@subsubsection Incremental file transfer
+
+The @code{(gnu services rsync)} module provides the following services:
+
+@subsubheading Rsync service
+
+@deffn {Scheme Variable} rsync-service-type
+This is the type for the @uref{https://rsync.samba.org} rsync daemon,
+@command{rsync-configuration} record as in this example:
+
+@example
+(service rsync-service-type
+ (rsync-configuration))
+@end example
+
+See below for details about @code{rsync-configuration}.
+@end deffn
+
+@deftp {Data Type} rsync-configuration
+Data type representing the configuration for @code{rsync-service}.
+
+@table @asis
+@item @code{package} (default: @var{rsync})
+Package object of the Rsync utility for efficiently transferring and
+synchronizing files.
+
+@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} will be started as the
+@code{root} user and group.
+
+@item @code{pid-file} (default: @code{"/var/run/rsyncd.pid"})
+Name of the file where @command{rsync} writes its PID.
+
+@item @code{lock-file} (default: @code{"/var/run/rsyncd.lock"})
+Name of the file where @command{rsync} writes its lock file.
+
+@item @code{log-file} (default: @code{"/var/log/rsyncd.log"})
+Name of the file where @command{rsync} writes its log file.
+
+@item @code{use-choot?} (default: @var{#f})
+Whether to use chroot for @command{rsync} shared directory.
+
+@item @code{share-path} (default: @file{/srv/rsync})
+Location of the @command{rsync} shared directory.
+
+@item @code{share-comment} (default: @code{"Rsync share"})
+Comment of the @command{rsync} shared directory.
+
+@item @code{read-only?} (default: @var{#f})
+Read-write permissions to shared directory.
+
+@item @code{timeout} (default: @code{300})
+I/O timeout in seconds.
+
+@end table
+@end deftp
+
@node Setuid Programs
@subsection Setuid Programs
diff --git a/gnu/local.mk b/gnu/local.mk
index 724c6b675..fa514b278 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -444,6 +444,7 @@ GNU_SYSTEM_MODULES = \
%D%/services/shepherd.scm \
%D%/services/herd.scm \
%D%/services/pm.scm \
+ %D%/services/rsync.scm \
%D%/services/sddm.scm \
%D%/services/spice.scm \
%D%/services/ssh.scm \
diff --git a/gnu/services/rsync.scm b/gnu/services/rsync.scm
new file mode 100644
index 000000000..49c4cb7e2
--- /dev/null
+++ b/gnu/services/rsync.scm
@@ -0,0 +1,162 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2017 Oleg Pykhalov <go.wigust@gmail.com>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (gnu services rsync)
+ #:use-module (gnu services)
+ #:use-module (gnu services base)
+ #:use-module (gnu services shepherd)
+ #:use-module (gnu system shadow)
+ #:use-module (gnu packages rsync)
+ #:use-module (gnu packages admin)
+ #:use-module (guix records)
+ #:use-module (guix gexp)
+ #:use-module (srfi srfi-1)
+ #:use-module (srfi srfi-26)
+ #:use-module (ice-9 match)
+ #:export (rsync-configuration
+ rsync-configuration?
+ rsync-service-type))
+
+;;;
+;;; Rsync.
+;;;
+
+(define-record-type* <rsync-configuration>
+ rsync-configuration make-rsync-configuration
+ rsync-configuration?
+ ;; <package>
+ (package rsync-configuration-package
+ (default rsync))
+ ;; integer
+ (port-number rsync-configuration-port-number
+ (default 873))
+ ;; string
+ (pid-file rsync-configuration-pid-file
+ (default "/var/run/rsyncd.pid"))
+ ;; string
+ (lock-file rsync-configuration-lock-file
+ (default "/var/run/rsyncd.lock"))
+ ;; string
+ (log-file rsync-configuration-log-file
+ (default "/var/log/rsyncd.log"))
+ ;; Boolean
+ (use-chroot? rsync-configuration-use-chroot?
+ (default #f))
+ ;; string
+ (share-path rsync-configuration-share-path
+ (default "/srv/rsync"))
+ ;; string
+ (share-comment rsync-configuration-share-comment
+ (default "Rsync share"))
+ ;; Boolean
+ (read-only? rsync-configuration-read-only?
+ (default #f))
+ ;; integer
+ (timeout rsync-configuration-timeout
+ (default 300)))
+
+(define %rsync-accounts
+ ;; User account and group for rsync.
+ (list (user-group (name "rsyncd") (system? #t))
+ (user-account
+ (name "rsyncd")
+ (system? #t)
+ (group "rsyncd")
+ (comment "rsyncd privilege separation user")
+ (home-directory "/var/run/rsyncd")
+ (shell #~(string-append #$shadow "/sbin/nologin")))))
+
+(define (rsync-activation config)
+ "Return the activation GEXP for CONFIG."
+ #~(begin
+ (use-modules (guix build utils))
+ (let ((share-directory #$(rsync-configuration-share-path config))
+ (user (getpw "rsyncd")))
+ (and=> share-directory mkdir-p)
+ (chown share-directory
+ (passwd:uid user)
+ (group:gid user)))))
+
+(define (rsync-config-file config)
+ "Return the rsync configuration file corresponding to CONFIG."
+ (computed-file
+ "rsync.conf"
+ #~(begin
+ (call-with-output-file #$output
+ (lambda (port)
+ (display "# Generated by 'rsync-service'.\n" port)
+ (format port "pid file = ~a\n"
+ #$(rsync-configuration-pid-file config))
+ (format port "lock file = ~a\n"
+ #$(rsync-configuration-lock-file config))
+ (format port "log file = ~a\n"
+ #$(rsync-configuration-log-file config))
+ (format port "port = ~a\n"
+ #$(number->string
+ (rsync-configuration-port-number config)))
+ (format port "use chroot = ~a\n"
+ #$(if (rsync-configuration-use-chroot? config)
+ "true" "false"))
+ (display "[files]\n" port)
+ (format port "path = ~a\n"
+ #$(rsync-configuration-share-path config))
+ (format port "comment = ~a\n"
+ #$(rsync-configuration-share-comment config))
+ (format port "read only = ~a\n"
+ #$(if (rsync-configuration-read-only? config)
+ "true" "false"))
+ (format port "timeout = ~a\n"
+ #$(number->string
+ (rsync-configuration-timeout config)))
+ #t)))))
+
+(define (rsync-shepherd-service config)
+ "Return a <shepherd-service> for rsync with CONFIG."
+
+ (define rsync-command
+ #~(list (string-append #$(rsync-configuration-package config) "/bin/rsync")
+ "--daemon" "--config" #$(rsync-config-file config)))
+
+ (define pid-file
+ (rsync-configuration-pid-file config))
+
+ (define user
+ (let ((port (rsync-configuration-port-number config)))
+ (if (> port 1024)
+ "rsyncd"
+ "root")))
+
+ (list (shepherd-service
+ (provision '(rsync))
+ (documentation "Run rsync daemon.")
+ (start #~(make-forkexec-constructor #$rsync-command
+ #:pid-file #$pid-file
+ #:user #$user
+ #:group #$user))
+ (stop #~(make-kill-destructor)))))
+
+(define rsync-service-type
+ (service-type
+ (name 'rsync)
+ (extensions
+ (list (service-extension shepherd-root-service-type
+ rsync-shepherd-service)
+ (service-extension account-service-type
+ (const %rsync-accounts))
+ (service-extension activation-service-type
+ rsync-activation)))))
--
2.13.3
O
O
Oleg Pykhalov wrote on 28 Jul 2017 00:22
ERROR: rsync rsync://localhost/files
(address . 27855@debbugs.gnu.org)
878tj9msf0.fsf@gmail.com
(eval-when (expand load eval) (set! %load-path (cons "/gnu/store/xjv05kaa67glf1i639b3bhkib746f9ag-module-import" %load-path)) (set! %load-compiled-path (cons "/gnu/store/ya080134pjnk4jiw8j9g244rgrn8pfy9-module-import-compiled" %load-compiled-path)))(begin (use-modules (shepherd service) (oop goops) (guix build utils) (guix build syscalls)) (make <service> #:docstring (quote "Run rsync daemon.") #:provides (quote (rsync)) #:requires (quote ()) #:respawn? (quote #t) #:start (make-forkexec-constructor (list (string-append "/gnu/store/nfx98xdajm6fvnxhq8z3nmrzkb4421dl-rsync-3.1.2" "/bin/rsync") "--daemon" "--config" "/gnu/store/s2zk3kp2gjpfv61npr79rmwlp74r4yk0-rsync.conf") #:pid-file "/var/run/rsyncd.pid" #:user "root" #:group "root") #:stop (make-kill-destructor)))
natsu@magnolia /gnu/store$
@ERROR: invalid gid nobody
rsync error: error starting client-server protocol (code 5) at main.c(1648) [Receiver=3.1.2]
O
O
Oleg Pykhalov wrote on 28 Jul 2017 08:45
[PATCH] services: rsync: Fix invalid gid nobody.
(address . 27855@debbugs.gnu.org)(name . Oleg Pykhalov)(address . go.wigust@gmail.com)
20170728064542.992-1-go.wigust@gmail.com
---
gnu/services/rsync.scm | 1 +
1 file changed, 1 insertion(+)

Toggle diff (14 lines)
diff --git a/gnu/services/rsync.scm b/gnu/services/rsync.scm
index 49c4cb7e2..9cf2bc89a 100644
--- a/gnu/services/rsync.scm
+++ b/gnu/services/rsync.scm
@@ -112,6 +112,7 @@
(format port "use chroot = ~a\n"
#$(if (rsync-configuration-use-chroot? config)
"true" "false"))
+ (display "gid = rsyncd\n" port)
(display "[files]\n" port)
(format port "path = ~a\n"
#$(rsync-configuration-share-path config))
--
2.13.3
C
C
Christopher Baines wrote on 29 Jul 2017 00:17
Re: [bug#27855] [PATCH] gnu: Add rsync service.
(name . Oleg Pykhalov)(address . go.wigust@gmail.com)(address . 27855@debbugs.gnu.org)
20170728231747.5eae3af9@cbaines.net
Hello Oleg,

I've had a quick read through the patch, and I've made a few hopefully
helpful comments below.

On Fri, 28 Jul 2017 01:01:51 +0300
Oleg Pykhalov <go.wigust@gmail.com> wrote:

Toggle quote (25 lines)
> * doc/guix.texi (Incremental file transfer): Add documentation.
> * gnu/services/rsync.scm (<rsync-configuration>): New record type.
> (rsync-accounts, rsync-shepherd-service): New service extensions.
> (rsync-service-type): New service type.
> ---
> doc/guix.texi | 58 ++++++++++++++++++
> gnu/local.mk | 1 +
> gnu/services/rsync.scm | 162
> +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed,
> 221 insertions(+) create mode 100644 gnu/services/rsync.scm
>
> diff --git a/doc/guix.texi b/doc/guix.texi
> index e8c4e0eaf..a3745ae01 100644
> --- a/doc/guix.texi
> +++ b/doc/guix.texi
> @@ -15661,6 +15661,64 @@ Extra options will be passed to @code{git
> daemon}, please run @end table
> @end deftp
>
> +@subsubsection Incremental file transfer
> +
> +The @code{(gnu services rsync)} module provides the following
> services: +
> +@subsubheading Rsync service

It would be great to give a really short explanation of what this
service can be used for here. I know what Rsync does, but I'm not quite
sure what this service does.

Toggle quote (20 lines)
> +@deffn {Scheme Variable} rsync-service-type
> +This is the type for the @uref{https://rsync.samba.org} rsync daemon,
> +@command{rsync-configuration} record as in this example:
> +
> +@example
> +(service rsync-service-type
> + (rsync-configuration))
> +@end example
> +
> +See below for details about @code{rsync-configuration}.
> +@end deffn
> +
> +@deftp {Data Type} rsync-configuration
> +Data type representing the configuration for @code{rsync-service}.
> +
> +@table @asis
> +@item @code{package} (default: @var{rsync})
> +Package object of the Rsync utility for efficiently transferring and
> +synchronizing files.

Object doesn't really fit here, if anything its a record. Also, I don't
think this needs a description of what rsync does, it's probably
clearest to just say that this is the rsync package?

Toggle quote (182 lines)
> +@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} will be started as
> the +@code{root} user and group.
> +
> +@item @code{pid-file} (default: @code{"/var/run/rsyncd.pid"})
> +Name of the file where @command{rsync} writes its PID.
> +
> +@item @code{lock-file} (default: @code{"/var/run/rsyncd.lock"})
> +Name of the file where @command{rsync} writes its lock file.
> +
> +@item @code{log-file} (default: @code{"/var/log/rsyncd.log"})
> +Name of the file where @command{rsync} writes its log file.
> +
> +@item @code{use-choot?} (default: @var{#f})
> +Whether to use chroot for @command{rsync} shared directory.
> +
> +@item @code{share-path} (default: @file{/srv/rsync})
> +Location of the @command{rsync} shared directory.
> +
> +@item @code{share-comment} (default: @code{"Rsync share"})
> +Comment of the @command{rsync} shared directory.
> +
> +@item @code{read-only?} (default: @var{#f})
> +Read-write permissions to shared directory.
> +
> +@item @code{timeout} (default: @code{300})
> +I/O timeout in seconds.
> +
> +@end table
> +@end deftp
> +
> @node Setuid Programs
> @subsection Setuid Programs
>
> diff --git a/gnu/local.mk b/gnu/local.mk
> index 724c6b675..fa514b278 100644
> --- a/gnu/local.mk
> +++ b/gnu/local.mk
> @@ -444,6 +444,7 @@ GNU_SYSTEM_MODULES
> = \
> %D%/services/shepherd.scm \
> %D%/services/herd.scm \
> %D%/services/pm.scm \
> + %D%/services/rsync.scm \
> %D%/services/sddm.scm \
> %D%/services/spice.scm \
> %D%/services/ssh.scm \
> diff --git a/gnu/services/rsync.scm b/gnu/services/rsync.scm
> new file mode 100644
> index 000000000..49c4cb7e2
> --- /dev/null
> +++ b/gnu/services/rsync.scm
> @@ -0,0 +1,162 @@
> +;;; GNU Guix --- Functional package management for GNU
> +;;; Copyright © 2017 Oleg Pykhalov <go.wigust@gmail.com>
> +;;;
> +;;; This file is part of GNU Guix.
> +;;;
> +;;; GNU Guix is free software; you can redistribute it and/or modify
> it +;;; under the terms of the GNU General Public License as
> published by +;;; the Free Software Foundation; either version 3 of
> the License, or (at +;;; your option) any later version.
> +;;;
> +;;; GNU Guix is distributed in the hope that it will be useful, but
> +;;; WITHOUT ANY WARRANTY; without even the implied warranty of
> +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> +;;; GNU General Public License for more details.
> +;;;
> +;;; You should have received a copy of the GNU General Public License
> +;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
> +
> +(define-module (gnu services rsync)
> + #:use-module (gnu services)
> + #:use-module (gnu services base)
> + #:use-module (gnu services shepherd)
> + #:use-module (gnu system shadow)
> + #:use-module (gnu packages rsync)
> + #:use-module (gnu packages admin)
> + #:use-module (guix records)
> + #:use-module (guix gexp)
> + #:use-module (srfi srfi-1)
> + #:use-module (srfi srfi-26)
> + #:use-module (ice-9 match)
> + #:export (rsync-configuration
> + rsync-configuration?
> + rsync-service-type))
> +
> +;;;
> +;;; Rsync.
> +;;;
> +
> +(define-record-type* <rsync-configuration>
> + rsync-configuration make-rsync-configuration
> + rsync-configuration?
> + ;; <package>
> + (package rsync-configuration-package
> + (default rsync))
> + ;; integer
> + (port-number rsync-configuration-port-number
> + (default 873))
> + ;; string
> + (pid-file rsync-configuration-pid-file
> + (default "/var/run/rsyncd.pid"))
> + ;; string
> + (lock-file rsync-configuration-lock-file
> + (default "/var/run/rsyncd.lock"))
> + ;; string
> + (log-file rsync-configuration-log-file
> + (default "/var/log/rsyncd.log"))
> + ;; Boolean
> + (use-chroot? rsync-configuration-use-chroot?
> + (default #f))
> + ;; string
> + (share-path rsync-configuration-share-path
> + (default "/srv/rsync"))
> + ;; string
> + (share-comment rsync-configuration-share-comment
> + (default "Rsync share"))
> + ;; Boolean
> + (read-only? rsync-configuration-read-only?
> + (default #f))
> + ;; integer
> + (timeout rsync-configuration-timeout
> + (default 300)))
> +
> +(define %rsync-accounts
> + ;; User account and group for rsync.
> + (list (user-group (name "rsyncd") (system? #t))
> + (user-account
> + (name "rsyncd")
> + (system? #t)
> + (group "rsyncd")
> + (comment "rsyncd privilege separation user")
> + (home-directory "/var/run/rsyncd")
> + (shell #~(string-append #$shadow "/sbin/nologin")))))
> +
> +(define (rsync-activation config)
> + "Return the activation GEXP for CONFIG."
> + #~(begin
> + (use-modules (guix build utils))
> + (let ((share-directory #$(rsync-configuration-share-path
> config))
> + (user (getpw "rsyncd")))
> + (and=> share-directory mkdir-p)
> + (chown share-directory
> + (passwd:uid user)
> + (group:gid user)))))
> +
> +(define (rsync-config-file config)
> + "Return the rsync configuration file corresponding to CONFIG."
> + (computed-file
> + "rsync.conf"
> + #~(begin
> + (call-with-output-file #$output
> + (lambda (port)
> + (display "# Generated by 'rsync-service'.\n" port)
> + (format port "pid file = ~a\n"
> + #$(rsync-configuration-pid-file config))
> + (format port "lock file = ~a\n"
> + #$(rsync-configuration-lock-file config))
> + (format port "log file = ~a\n"
> + #$(rsync-configuration-log-file config))
> + (format port "port = ~a\n"
> + #$(number->string
> + (rsync-configuration-port-number config)))
> + (format port "use chroot = ~a\n"
> + #$(if (rsync-configuration-use-chroot? config)
> + "true" "false"))
> + (display "[files]\n" port)
> + (format port "path = ~a\n"
> + #$(rsync-configuration-share-path config))
> + (format port "comment = ~a\n"
> + #$(rsync-configuration-share-comment config))
> + (format port "read only = ~a\n"
> + #$(if (rsync-configuration-read-only? config)
> + "true" "false"))
> + (format port "timeout = ~a\n"
> + #$(number->string
> + (rsync-configuration-timeout config)))
> + #t)))))

It might be neater here to use mixed-text-file here. It might look
something like...

(define (rsync-config-file config)
"Return the rsync configuration file corresponding to CONFIG."
(match config
(($ <rsync-configuration> package port-number pid-file lock-file
log-file use-chroot? share-path
share-comment read-only? timeout)
(mixed text-file "rsync.conf"
"# Generated by 'rsync-service'.\n"
"pid file = " pid-file "\n"
"lock file = " lock-file "\n"
"log file = " log-file "\n"
"port = " (number->string port-number) "\n"
"use chroot = " (if use-chroot? "true" "false") "\n"
"[files]\n"
"path = " share-path "\n"
"comment = " share-comment "\n"
"read only = " (if read-only? "true" "false") "\n"
"timeout = " (number->string timeout) "\n"))))

One thing I tried with the Tailon service, was to define a
gexp-compiler for the record type representing the configuration file.
One really big advantage in the case of Tailon is that it easily allows
the use of a custom file, just by providing a different gexp.

Here however, I can see that you are using some values from the
configuration (the port-number, package and share-path), which don't
make that possible. The use of the port-number and package could
probably be elegantly separated out, but I can't figure out what could
be done about the share path, and its use in the service activation.

Toggle quote (38 lines)
> +
> +(define (rsync-shepherd-service config)
> + "Return a <shepherd-service> for rsync with CONFIG."
> +
> + (define rsync-command
> + #~(list (string-append #$(rsync-configuration-package config)
> "/bin/rsync")
> + "--daemon" "--config" #$(rsync-config-file config)))
> +
> + (define pid-file
> + (rsync-configuration-pid-file config))
> +
> + (define user
> + (let ((port (rsync-configuration-port-number config)))
> + (if (> port 1024)
> + "rsyncd"
> + "root")))
> +
> + (list (shepherd-service
> + (provision '(rsync))
> + (documentation "Run rsync daemon.")
> + (start #~(make-forkexec-constructor #$rsync-command
> + #:pid-file #$pid-file
> + #:user #$user
> + #:group #$user))
> + (stop #~(make-kill-destructor)))))
> +
> +(define rsync-service-type
> + (service-type
> + (name 'rsync)
> + (extensions
> + (list (service-extension shepherd-root-service-type
> + rsync-shepherd-service)
> + (service-extension account-service-type
> + (const %rsync-accounts))
> + (service-extension activation-service-type
> + rsync-activation)))))

As I understand it, the service might not use the rsyncd user, if it is
configured to bind to a low port? If that is the case, then it might be
neater to include a check for this in the account-service-type
extension, so that these only get created if they are needed?
-----BEGIN PGP SIGNATURE-----

iQKTBAEBCgB9FiEEPonu50WOcg2XVOCyXiijOwuE9XcFAll7uAtfFIAAAAAALgAo
aXNzdWVyLWZwckBub3RhdGlvbnMub3BlbnBncC5maWZ0aGhvcnNlbWFuLm5ldDNF
ODlFRUU3NDU4RTcyMEQ5NzU0RTBCMjVFMjhBMzNCMEI4NEY1NzcACgkQXiijOwuE
9XcCcBAApSSPCr9nBDtEKqVJyeur0ZuAL0Rtp5XJn/7m4vYDiRE8AZK9j6mTc19T
QqL4E/b6IRLG82G2/iGt6yuul8gEiMomU65YrcrWuDNSpc7/Q5JCDI5U7q5tsd01
wGjS7mobLoBXdT3Va5BauiSMNawgkfKdKX3slWXmYDHjhFmyzvWaFSbjxph+hYxK
sMA0m10twBoJ0rGtRo0JQ3lQGvxe0Z4kCEeTRRs2rpa+yiBQoqlFntjsxNPDBulo
Fs3M8w+m4J5fKU9V8oFk7POETuXa8LwpOAQ+XxIhZi9Bg5z8r05ZXL52DM326zhz
17j03dAxD5F6gDsQRo+aAkbWfOmqsWzSzJ7NSYRRF1jd+Ct+bnOUMXEZPViQ7c6v
eeoM7qLby9lT4vGctjQPG8kycPlkRHIw5o3HrbE3l5BhnCCcQ2TUqG5fDk40XoMM
6kuqGiVnEhppmp3sLMTrb3+ah/OOP3J4y0/ZwcKg4baif9BWCFuMmv6x29aKypd/
JFNPu+Rhvw9XtY5TjB8XZtbpqGgZ0LvvEWowkLfEI7Q8ojnLvi5cK0FsUwcwQfWC
vuyc83RxIfrwf1U1xJp2h5Wr0sQWZ49tK/2GQuZ9GfIpBLBeFvFQ8ClO8aOrk8oq
q1ZOJRnCA9ZNYxeTdDyhPeCknnuw9AngHcGMaPdCeaEiSsT33H8=
=X2LI
-----END PGP SIGNATURE-----


O
O
Oleg Pykhalov wrote on 29 Jul 2017 13:03
(name . Christopher Baines)(address . mail@cbaines.net)(address . 27855@debbugs.gnu.org)
874ltvh5d6.fsf@gmail.com
Hello Christopher,

Christopher Baines <mail@cbaines.net> writes:

Toggle quote (37 lines)
> Hello Oleg,
>
> I've had a quick read through the patch, and I've made a few hopefully
> helpful comments below.
>
> On Fri, 28 Jul 2017 01:01:51 +0300
> Oleg Pykhalov <go.wigust@gmail.com> wrote:
>
>> * doc/guix.texi (Incremental file transfer): Add documentation.
>> * gnu/services/rsync.scm (<rsync-configuration>): New record type.
>> (rsync-accounts, rsync-shepherd-service): New service extensions.
>> (rsync-service-type): New service type.
>> ---
>> doc/guix.texi | 58 ++++++++++++++++++
>> gnu/local.mk | 1 +
>> gnu/services/rsync.scm | 162
>> +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed,
>> 221 insertions(+) create mode 100644 gnu/services/rsync.scm
>>
>> diff --git a/doc/guix.texi b/doc/guix.texi
>> index e8c4e0eaf..a3745ae01 100644
>> --- a/doc/guix.texi
>> +++ b/doc/guix.texi
>> @@ -15661,6 +15661,64 @@ Extra options will be passed to @code{git
>> daemon}, please run @end table
>> @end deftp
>>
>> +@subsubsection Incremental file transfer
>> +
>> +The @code{(gnu services rsync)} module provides the following
>> services: +
>> +@subsubheading Rsync service
>
> It would be great to give a really short explanation of what this
> service can be used for here. I know what Rsync does, but I'm not quite
> sure what this service does.

OK, I add a little description.

You might want an rsync daemon if you have files that you want
available so anyone (or just yourself) can download existing files
or upload new files.

Toggle quote (24 lines)
>> +@deffn {Scheme Variable} rsync-service-type
>> +This is the type for the @uref{https://rsync.samba.org} rsync daemon,
>> +@command{rsync-configuration} record as in this example:
>> +
>> +@example
>> +(service rsync-service-type
>> + (rsync-configuration))
>> +@end example
>> +
>> +See below for details about @code{rsync-configuration}.
>> +@end deffn
>> +
>> +@deftp {Data Type} rsync-configuration
>> +Data type representing the configuration for @code{rsync-service}.
>> +
>> +@table @asis
>> +@item @code{package} (default: @var{rsync})
>> +Package object of the Rsync utility for efficiently transferring and
>> +synchronizing files.
>
> Object doesn't really fit here, if anything its a record. Also, I don't
> think this needs a description of what rsync does, it's probably
> clearest to just say that this is the rsync package?

OK, is it good?

@code{rsync} package to use.

Toggle quote (210 lines)
>> +@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} will be started as
>> the +@code{root} user and group.
>> +
>> +@item @code{pid-file} (default: @code{"/var/run/rsyncd.pid"})
>> +Name of the file where @command{rsync} writes its PID.
>> +
>> +@item @code{lock-file} (default: @code{"/var/run/rsyncd.lock"})
>> +Name of the file where @command{rsync} writes its lock file.
>> +
>> +@item @code{log-file} (default: @code{"/var/log/rsyncd.log"})
>> +Name of the file where @command{rsync} writes its log file.
>> +
>> +@item @code{use-choot?} (default: @var{#f})
>> +Whether to use chroot for @command{rsync} shared directory.
>> +
>> +@item @code{share-path} (default: @file{/srv/rsync})
>> +Location of the @command{rsync} shared directory.
>> +
>> +@item @code{share-comment} (default: @code{"Rsync share"})
>> +Comment of the @command{rsync} shared directory.
>> +
>> +@item @code{read-only?} (default: @var{#f})
>> +Read-write permissions to shared directory.
>> +
>> +@item @code{timeout} (default: @code{300})
>> +I/O timeout in seconds.
>> +
>> +@end table
>> +@end deftp
>> +
>> @node Setuid Programs
>> @subsection Setuid Programs
>>
>> diff --git a/gnu/local.mk b/gnu/local.mk
>> index 724c6b675..fa514b278 100644
>> --- a/gnu/local.mk
>> +++ b/gnu/local.mk
>> @@ -444,6 +444,7 @@ GNU_SYSTEM_MODULES
>> = \
>> %D%/services/shepherd.scm \
>> %D%/services/herd.scm \
>> %D%/services/pm.scm \
>> + %D%/services/rsync.scm \
>> %D%/services/sddm.scm \
>> %D%/services/spice.scm \
>> %D%/services/ssh.scm \
>> diff --git a/gnu/services/rsync.scm b/gnu/services/rsync.scm
>> new file mode 100644
>> index 000000000..49c4cb7e2
>> --- /dev/null
>> +++ b/gnu/services/rsync.scm
>> @@ -0,0 +1,162 @@
>> +;;; GNU Guix --- Functional package management for GNU
>> +;;; Copyright © 2017 Oleg Pykhalov <go.wigust@gmail.com>
>> +;;;
>> +;;; This file is part of GNU Guix.
>> +;;;
>> +;;; GNU Guix is free software; you can redistribute it and/or modify
>> it +;;; under the terms of the GNU General Public License as
>> published by +;;; the Free Software Foundation; either version 3 of
>> the License, or (at +;;; your option) any later version.
>> +;;;
>> +;;; GNU Guix is distributed in the hope that it will be useful, but
>> +;;; WITHOUT ANY WARRANTY; without even the implied warranty of
>> +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
>> +;;; GNU General Public License for more details.
>> +;;;
>> +;;; You should have received a copy of the GNU General Public License
>> +;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
>> +
>> +(define-module (gnu services rsync)
>> + #:use-module (gnu services)
>> + #:use-module (gnu services base)
>> + #:use-module (gnu services shepherd)
>> + #:use-module (gnu system shadow)
>> + #:use-module (gnu packages rsync)
>> + #:use-module (gnu packages admin)
>> + #:use-module (guix records)
>> + #:use-module (guix gexp)
>> + #:use-module (srfi srfi-1)
>> + #:use-module (srfi srfi-26)
>> + #:use-module (ice-9 match)
>> + #:export (rsync-configuration
>> + rsync-configuration?
>> + rsync-service-type))
>> +
>> +;;;
>> +;;; Rsync.
>> +;;;
>> +
>> +(define-record-type* <rsync-configuration>
>> + rsync-configuration make-rsync-configuration
>> + rsync-configuration?
>> + ;; <package>
>> + (package rsync-configuration-package
>> + (default rsync))
>> + ;; integer
>> + (port-number rsync-configuration-port-number
>> + (default 873))
>> + ;; string
>> + (pid-file rsync-configuration-pid-file
>> + (default "/var/run/rsyncd.pid"))
>> + ;; string
>> + (lock-file rsync-configuration-lock-file
>> + (default "/var/run/rsyncd.lock"))
>> + ;; string
>> + (log-file rsync-configuration-log-file
>> + (default "/var/log/rsyncd.log"))
>> + ;; Boolean
>> + (use-chroot? rsync-configuration-use-chroot?
>> + (default #f))
>> + ;; string
>> + (share-path rsync-configuration-share-path
>> + (default "/srv/rsync"))
>> + ;; string
>> + (share-comment rsync-configuration-share-comment
>> + (default "Rsync share"))
>> + ;; Boolean
>> + (read-only? rsync-configuration-read-only?
>> + (default #f))
>> + ;; integer
>> + (timeout rsync-configuration-timeout
>> + (default 300)))
>> +
>> +(define %rsync-accounts
>> + ;; User account and group for rsync.
>> + (list (user-group (name "rsyncd") (system? #t))
>> + (user-account
>> + (name "rsyncd")
>> + (system? #t)
>> + (group "rsyncd")
>> + (comment "rsyncd privilege separation user")
>> + (home-directory "/var/run/rsyncd")
>> + (shell #~(string-append #$shadow "/sbin/nologin")))))
>> +
>> +(define (rsync-activation config)
>> + "Return the activation GEXP for CONFIG."
>> + #~(begin
>> + (use-modules (guix build utils))
>> + (let ((share-directory #$(rsync-configuration-share-path
>> config))
>> + (user (getpw "rsyncd")))
>> + (and=> share-directory mkdir-p)
>> + (chown share-directory
>> + (passwd:uid user)
>> + (group:gid user)))))
>> +
>> +(define (rsync-config-file config)
>> + "Return the rsync configuration file corresponding to CONFIG."
>> + (computed-file
>> + "rsync.conf"
>> + #~(begin
>> + (call-with-output-file #$output
>> + (lambda (port)
>> + (display "# Generated by 'rsync-service'.\n" port)
>> + (format port "pid file = ~a\n"
>> + #$(rsync-configuration-pid-file config))
>> + (format port "lock file = ~a\n"
>> + #$(rsync-configuration-lock-file config))
>> + (format port "log file = ~a\n"
>> + #$(rsync-configuration-log-file config))
>> + (format port "port = ~a\n"
>> + #$(number->string
>> + (rsync-configuration-port-number config)))
>> + (format port "use chroot = ~a\n"
>> + #$(if (rsync-configuration-use-chroot? config)
>> + "true" "false"))
>> + (display "[files]\n" port)
>> + (format port "path = ~a\n"
>> + #$(rsync-configuration-share-path config))
>> + (format port "comment = ~a\n"
>> + #$(rsync-configuration-share-comment config))
>> + (format port "read only = ~a\n"
>> + #$(if (rsync-configuration-read-only? config)
>> + "true" "false"))
>> + (format port "timeout = ~a\n"
>> + #$(number->string
>> + (rsync-configuration-timeout config)))
>> + #t)))))
>
> It might be neater here to use mixed-text-file here. It might look
> something like...
>
> (define (rsync-config-file config)
> "Return the rsync configuration file corresponding to CONFIG."
> (match config
> (($ <rsync-configuration> package port-number pid-file lock-file
> log-file use-chroot? share-path
> share-comment read-only? timeout)
> (mixed text-file "rsync.conf"
> "# Generated by 'rsync-service'.\n"
> "pid file = " pid-file "\n"
> "lock file = " lock-file "\n"
> "log file = " log-file "\n"
> "port = " (number->string port-number) "\n"
> "use chroot = " (if use-chroot? "true" "false") "\n"
> "[files]\n"
> "path = " share-path "\n"
> "comment = " share-comment "\n"
> "read only = " (if read-only? "true" "false") "\n"
> "timeout = " (number->string timeout) "\n"))))
>
>
> One thing I tried with the Tailon service, was to define a
> gexp-compiler for the record type representing the configuration file.
> One really big advantage in the case of Tailon is that it easily allows
> the use of a custom file, just by providing a different gexp.

So, this way you could provide your existing Tailon config as a file in
system declaration? Nice.

Toggle quote (6 lines)
> Here however, I can see that you are using some values from the
> configuration (the port-number, package and share-path), which don't
> make that possible. The use of the port-number and package could
> probably be elegantly separated out, but I can't figure out what could
> be done about the share path, and its use in the service activation.

I made rsync service inspired by openssh service.

* “package” is not really needs to be configurable.
* “port-number” needs. It specifies will service be run by “root”.
* “share-path” needs to be configurable ofcourse.

Toggle quote (43 lines)
>> +
>> +(define (rsync-shepherd-service config)
>> + "Return a <shepherd-service> for rsync with CONFIG."
>> +
>> + (define rsync-command
>> + #~(list (string-append #$(rsync-configuration-package config)
>> "/bin/rsync")
>> + "--daemon" "--config" #$(rsync-config-file config)))
>> +
>> + (define pid-file
>> + (rsync-configuration-pid-file config))
>> +
>> + (define user
>> + (let ((port (rsync-configuration-port-number config)))
>> + (if (> port 1024)
>> + "rsyncd"
>> + "root")))
>> +
>> + (list (shepherd-service
>> + (provision '(rsync))
>> + (documentation "Run rsync daemon.")
>> + (start #~(make-forkexec-constructor #$rsync-command
>> + #:pid-file #$pid-file
>> + #:user #$user
>> + #:group #$user))
>> + (stop #~(make-kill-destructor)))))
>> +
>> +(define rsync-service-type
>> + (service-type
>> + (name 'rsync)
>> + (extensions
>> + (list (service-extension shepherd-root-service-type
>> + rsync-shepherd-service)
>> + (service-extension account-service-type
>> + (const %rsync-accounts))
>> + (service-extension activation-service-type
>> + rsync-activation)))))
>
> As I understand it, the service might not use the rsyncd user, if it is
> configured to bind to a low port? If that is the case, then it might be
> neater to include a check for this in the account-service-type
> extension, so that these only get created if they are needed?

Yes, if port lower than 1024 only “root” can bind.

I though about it. I will try to emplement it.


Thanks!
C
C
Christopher Baines wrote on 29 Jul 2017 13:55
(name . Oleg Pykhalov)(address . go.wigust@gmail.com)(address . 27855@debbugs.gnu.org)
20170729125554.29836b28@cbaines.net
On Sat, 29 Jul 2017 14:03:49 +0300
Oleg Pykhalov <go.wigust@gmail.com> wrote:

Toggle quote (28 lines)
> >> +@deffn {Scheme Variable} rsync-service-type
> >> +This is the type for the @uref{https://rsync.samba.org} rsync
> >> daemon, +@command{rsync-configuration} record as in this example:
> >> +
> >> +@example
> >> +(service rsync-service-type
> >> + (rsync-configuration))
> >> +@end example
> >> +
> >> +See below for details about @code{rsync-configuration}.
> >> +@end deffn
> >> +
> >> +@deftp {Data Type} rsync-configuration
> >> +Data type representing the configuration for @code{rsync-service}.
> >> +
> >> +@table @asis
> >> +@item @code{package} (default: @var{rsync})
> >> +Package object of the Rsync utility for efficiently transferring
> >> and +synchronizing files.
> >
> > Object doesn't really fit here, if anything its a record. Also, I
> > don't think this needs a description of what rsync does, it's
> > probably clearest to just say that this is the rsync package?
>
> OK, is it good?
>
> @code{rsync} package to use.

Yep, in my opinion, that is the right amount of information.

Toggle quote (65 lines)
> >> +(define (rsync-config-file config)
> >> + "Return the rsync configuration file corresponding to CONFIG."
> >> + (computed-file
> >> + "rsync.conf"
> >> + #~(begin
> >> + (call-with-output-file #$output
> >> + (lambda (port)
> >> + (display "# Generated by 'rsync-service'.\n" port)
> >> + (format port "pid file = ~a\n"
> >> + #$(rsync-configuration-pid-file config))
> >> + (format port "lock file = ~a\n"
> >> + #$(rsync-configuration-lock-file config))
> >> + (format port "log file = ~a\n"
> >> + #$(rsync-configuration-log-file config))
> >> + (format port "port = ~a\n"
> >> + #$(number->string
> >> + (rsync-configuration-port-number config)))
> >> + (format port "use chroot = ~a\n"
> >> + #$(if (rsync-configuration-use-chroot? config)
> >> + "true" "false"))
> >> + (display "[files]\n" port)
> >> + (format port "path = ~a\n"
> >> + #$(rsync-configuration-share-path config))
> >> + (format port "comment = ~a\n"
> >> + #$(rsync-configuration-share-comment config))
> >> + (format port "read only = ~a\n"
> >> + #$(if (rsync-configuration-read-only? config)
> >> + "true" "false"))
> >> + (format port "timeout = ~a\n"
> >> + #$(number->string
> >> + (rsync-configuration-timeout config)))
> >> + #t)))))
> >
> > It might be neater here to use mixed-text-file here. It might look
> > something like...
> >
> > (define (rsync-config-file config)
> > "Return the rsync configuration file corresponding to CONFIG."
> > (match config
> > (($ <rsync-configuration> package port-number pid-file lock-file
> > log-file use-chroot? share-path
> > share-comment read-only? timeout)
> > (mixed text-file "rsync.conf"
> > "# Generated by 'rsync-service'.\n"
> > "pid file = " pid-file "\n"
> > "lock file = " lock-file "\n"
> > "log file = " log-file "\n"
> > "port = " (number->string port-number) "\n"
> > "use chroot = " (if use-chroot? "true" "false") "\n"
> > "[files]\n"
> > "path = " share-path "\n"
> > "comment = " share-comment "\n"
> > "read only = " (if read-only? "true" "false") "\n"
> > "timeout = " (number->string timeout) "\n"))))
> >
> >
> > One thing I tried with the Tailon service, was to define a
> > gexp-compiler for the record type representing the configuration
> > file. One really big advantage in the case of Tailon is that it
> > easily allows the use of a custom file, just by providing a
> > different gexp.
>
> So, this way you could provide your existing Tailon config as a file
> in system declaration? Nice.

Yep, I think something like the following should just work, but I
haven't tested it yet.

(service tailon-service-type
(tailon-configuration
(config-file (local-file "../tailon.yml"))))

I bring this up, as I think it is great if this is a feature of all
services, I'm having trouble though working out how you might do that
in this case, with the use of values in the activation service
extension. I can see complicated approaches, but nothing simple and
clear enough.
-----BEGIN PGP SIGNATURE-----

iQKTBAEBCgB9FiEEPonu50WOcg2XVOCyXiijOwuE9XcFAll8d8pfFIAAAAAALgAo
aXNzdWVyLWZwckBub3RhdGlvbnMub3BlbnBncC5maWZ0aGhvcnNlbWFuLm5ldDNF
ODlFRUU3NDU4RTcyMEQ5NzU0RTBCMjVFMjhBMzNCMEI4NEY1NzcACgkQXiijOwuE
9XftkQ//SFk2cKd/elaQjfTivYWDn+/b/sJm1yZUNwWMPlTX0rg0ycAAN5xg7+Pm
1mbTvRXuV6eUwfxF7odhPEvRqzrEFawWyerbbZDuTl13/lfCupHVTkDipmyvAsZC
dYwDo4w2k5mKL1dhb0y1efUDQzxM58dCEG9Wlc0NCGPklGFeyWbVH5mO2yqy6YKE
fgXi1eqdcQ5kn8KYJ0BjQus+F3W7Sv8PIH3YhT/Td+ra7NswhNMnZNJjepDkPYBK
LmQ2vPrkxmaXSKHeo2vdROp7/NiJt0lpA9faMYxsHft1yK4NYhd8xMmxEUgjNXu3
N0nCs8BYL1haGnWBOplZdDFnvkpjGSQ3ns4M+HsZSoN9ac+5aqLRzRRpmWmdNV9M
bNuQWCFq0YsrUTkBIYfAIpdGgNPUxG2BhplGQxhz9v0RoOj+yCTsqeBjXmYPGoNa
wr/vwNFjC4tJpQUAZeHNewJFQ4dQurHjpXM8wCBURq9CwBupatucuQFM7zCkM4aO
VtwsDFherqe86P2mCzuDp0ptmPzTSZ3rSjf63ELUyad3RAbHnFVRXccQ8UsT1nOz
HxSFrb60bdOZV0Ip6noR9Iag8kcip7vhcJVfV+b3b9R8dhjiA+pB9tNpKmlupxL1
xE/JOrBxHwO5vWpr4SrzToDUzbFidLzXDgRWAwpCm6XRb7M53TI=
=kgxA
-----END PGP SIGNATURE-----


O
O
Oleg Pykhalov wrote on 3 Aug 2017 17:20
(name . Christopher Baines)(address . mail@cbaines.net)(address . 27855@debbugs.gnu.org)
87r2wszni8.fsf@gmail.com
Hello Christopher,

Christopher Baines <mail@cbaines.net> writes:

Toggle quote (88 lines)
> On Sat, 29 Jul 2017 14:03:49 +0300
> Oleg Pykhalov <go.wigust@gmail.com> wrote:
>
>> >> +@deffn {Scheme Variable} rsync-service-type
>> >> +This is the type for the @uref{https://rsync.samba.org} rsync
>> >> daemon, +@command{rsync-configuration} record as in this example:
>> >> +
>> >> +@example
>> >> +(service rsync-service-type
>> >> + (rsync-configuration))
>> >> +@end example
>> >> +
>> >> +See below for details about @code{rsync-configuration}.
>> >> +@end deffn
>> >> +
>> >> +@deftp {Data Type} rsync-configuration
>> >> +Data type representing the configuration for @code{rsync-service}.
>> >> +
>> >> +@table @asis
>> >> +@item @code{package} (default: @var{rsync})
>> >> +Package object of the Rsync utility for efficiently transferring
>> >> and +synchronizing files.
>> >
>> > Object doesn't really fit here, if anything its a record. Also, I
>> > don't think this needs a description of what rsync does, it's
>> > probably clearest to just say that this is the rsync package?
>>
>> OK, is it good?
>>
>> @code{rsync} package to use.
>
> Yep, in my opinion, that is the right amount of information.
>
>> >> +(define (rsync-config-file config)
>> >> + "Return the rsync configuration file corresponding to CONFIG."
>> >> + (computed-file
>> >> + "rsync.conf"
>> >> + #~(begin
>> >> + (call-with-output-file #$output
>> >> + (lambda (port)
>> >> + (display "# Generated by 'rsync-service'.\n" port)
>> >> + (format port "pid file = ~a\n"
>> >> + #$(rsync-configuration-pid-file config))
>> >> + (format port "lock file = ~a\n"
>> >> + #$(rsync-configuration-lock-file config))
>> >> + (format port "log file = ~a\n"
>> >> + #$(rsync-configuration-log-file config))
>> >> + (format port "port = ~a\n"
>> >> + #$(number->string
>> >> + (rsync-configuration-port-number config)))
>> >> + (format port "use chroot = ~a\n"
>> >> + #$(if (rsync-configuration-use-chroot? config)
>> >> + "true" "false"))
>> >> + (display "[files]\n" port)
>> >> + (format port "path = ~a\n"
>> >> + #$(rsync-configuration-share-path config))
>> >> + (format port "comment = ~a\n"
>> >> + #$(rsync-configuration-share-comment config))
>> >> + (format port "read only = ~a\n"
>> >> + #$(if (rsync-configuration-read-only? config)
>> >> + "true" "false"))
>> >> + (format port "timeout = ~a\n"
>> >> + #$(number->string
>> >> + (rsync-configuration-timeout config)))
>> >> + #t)))))
>> >
>> > It might be neater here to use mixed-text-file here. It might look
>> > something like...
>> >
>> > (define (rsync-config-file config)
>> > "Return the rsync configuration file corresponding to CONFIG."
>> > (match config
>> > (($ <rsync-configuration> package port-number pid-file lock-file
>> > log-file use-chroot? share-path
>> > share-comment read-only? timeout)
>> > (mixed text-file "rsync.conf"
>> > "# Generated by 'rsync-service'.\n"
>> > "pid file = " pid-file "\n"
>> > "lock file = " lock-file "\n"
>> > "log file = " log-file "\n"
>> > "port = " (number->string port-number) "\n"
>> > "use chroot = " (if use-chroot? "true" "false") "\n"
>> > "[files]\n"
>> > "path = " share-path "\n"
>> > "comment = " share-comment "\n"
>> > "read only = " (if read-only? "true" "false") "\n"
>> > "timeout = " (number->string timeout) "\n"))))

OK, patched.

Toggle quote (22 lines)
>> > One thing I tried with the Tailon service, was to define a
>> > gexp-compiler for the record type representing the configuration
>> > file. One really big advantage in the case of Tailon is that it
>> > easily allows the use of a custom file, just by providing a
>> > different gexp.
>>
>> So, this way you could provide your existing Tailon config as a file
>> in system declaration? Nice.
>
> Yep, I think something like the following should just work, but I
> haven't tested it yet.
>
> (service tailon-service-type
> (tailon-configuration
> (config-file (local-file "../tailon.yml"))))
>
> I bring this up, as I think it is great if this is a feature of all
> services, I'm having trouble though working out how you might do that
> in this case, with the use of values in the activation service
> extension. I can see complicated approaches, but nothing simple and
> clear enough.

I tried to apply your work in tailon service, but I have troubles as you
described. So I just cleaned up code little bit.
O
O
Oleg Pykhalov wrote on 3 Aug 2017 17:29
(name . Christopher Baines)(address . mail@cbaines.net)(address . 27855@debbugs.gnu.org)
87k22kzn4k.fsf@gmail.com
And I probably need to add this patch too.
From 468ebe35b2a2c75752661d1591d9e7f387aff83e Mon Sep 17 00:00:00 2001
From: Oleg Pykhalov <go.wigust@gmail.com>
Date: Thu, 3 Aug 2017 18:28:03 +0300
Subject: [PATCH] services: rsync: Clean up code.

* gnu/services/rsync.scm: Clean up.
---
gnu/services/rsync.scm | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)

Toggle diff (56 lines)
diff --git a/gnu/services/rsync.scm b/gnu/services/rsync.scm
index e1a014a63..0612a0ea6 100644
--- a/gnu/services/rsync.scm
+++ b/gnu/services/rsync.scm
@@ -69,12 +69,13 @@
(define (rsync-account config)
"Return the user accounts and user groups for CONFIG."
- (let ((rsync-user (rsync-configuration-user config)))
+ (let ((rsync-user (rsync-configuration-user config))
+ (rsync-group (rsync-configuration-group config)))
(list (user-group (name "rsyncd") (system? #t))
(user-account
(name rsync-user)
(system? #t)
- (group rsync-user)
+ (group rsync-group)
(comment "rsyncd privilege separation user")
(home-directory "/var/run/rsyncd")
(shell #~(string-append #$shadow "/sbin/nologin"))))))
@@ -84,11 +85,12 @@
#~(begin
(use-modules (guix build utils))
(let ((share-directory #$(rsync-configuration-share-path config))
- (user (getpw #$(rsync-configuration-user config))))
+ (user (getpw #$(rsync-configuration-user config)))
+ (group (getpw #$(rsync-configuration-group config))))
(and=> share-directory mkdir-p)
(chown share-directory
(passwd:uid user)
- (group:gid user)))))
+ (group:gid group)))))
(define (rsync-config-file config)
"Return the rsync configuration file corresponding to CONFIG."
@@ -115,7 +117,8 @@
(let* ((rsync (rsync-configuration-package config))
(pid-file (rsync-configuration-pid-file config))
(port (rsync-configuration-port-number config))
- (user (if (> port 1024) (rsync-configuration-user config) "root")))
+ (user (if (> port 1024) (rsync-configuration-user config) "root"))
+ (group (if (> port 1024) (rsync-configuration-group config) "root")))
(list (shepherd-service
(provision '(rsync))
(documentation "Run rsync daemon.")
@@ -125,7 +128,7 @@
"--daemon")
#:pid-file #$pid-file
#:user #$user
- #:group #$user))
+ #:group #$group))
(stop #~(make-kill-destructor))))))
(define rsync-service-type
--
2.13.3
C
C
Christopher Baines wrote on 3 Aug 2017 17:33
(name . Oleg Pykhalov)(address . go.wigust@gmail.com)(address . 27855@debbugs.gnu.org)
20170803163322.3e87b004@cbaines.net
On Thu, 03 Aug 2017 18:20:31 +0300
Oleg Pykhalov <go.wigust@gmail.com> wrote:

Toggle quote (124 lines)
> Hello Christopher,
>
> Christopher Baines <mail@cbaines.net> writes:
>
> > On Sat, 29 Jul 2017 14:03:49 +0300
> > Oleg Pykhalov <go.wigust@gmail.com> wrote:
> >
> >> >> +@deffn {Scheme Variable} rsync-service-type
> >> >> +This is the type for the @uref{https://rsync.samba.org} rsync
> >> >> daemon, +@command{rsync-configuration} record as in this
> >> >> example: +
> >> >> +@example
> >> >> +(service rsync-service-type
> >> >> + (rsync-configuration))
> >> >> +@end example
> >> >> +
> >> >> +See below for details about @code{rsync-configuration}.
> >> >> +@end deffn
> >> >> +
> >> >> +@deftp {Data Type} rsync-configuration
> >> >> +Data type representing the configuration for
> >> >> @code{rsync-service}. +
> >> >> +@table @asis
> >> >> +@item @code{package} (default: @var{rsync})
> >> >> +Package object of the Rsync utility for efficiently
> >> >> transferring and +synchronizing files.
> >> >
> >> > Object doesn't really fit here, if anything its a record. Also, I
> >> > don't think this needs a description of what rsync does, it's
> >> > probably clearest to just say that this is the rsync package?
> >>
> >> OK, is it good?
> >>
> >> @code{rsync} package to use.
> >
> > Yep, in my opinion, that is the right amount of information.
> >
> >> >> +(define (rsync-config-file config)
> >> >> + "Return the rsync configuration file corresponding to
> >> >> CONFIG."
> >> >> + (computed-file
> >> >> + "rsync.conf"
> >> >> + #~(begin
> >> >> + (call-with-output-file #$output
> >> >> + (lambda (port)
> >> >> + (display "# Generated by 'rsync-service'.\n" port)
> >> >> + (format port "pid file = ~a\n"
> >> >> + #$(rsync-configuration-pid-file config))
> >> >> + (format port "lock file = ~a\n"
> >> >> + #$(rsync-configuration-lock-file config))
> >> >> + (format port "log file = ~a\n"
> >> >> + #$(rsync-configuration-log-file config))
> >> >> + (format port "port = ~a\n"
> >> >> + #$(number->string
> >> >> + (rsync-configuration-port-number
> >> >> config)))
> >> >> + (format port "use chroot = ~a\n"
> >> >> + #$(if (rsync-configuration-use-chroot?
> >> >> config)
> >> >> + "true" "false"))
> >> >> + (display "[files]\n" port)
> >> >> + (format port "path = ~a\n"
> >> >> + #$(rsync-configuration-share-path config))
> >> >> + (format port "comment = ~a\n"
> >> >> + #$(rsync-configuration-share-comment
> >> >> config))
> >> >> + (format port "read only = ~a\n"
> >> >> + #$(if (rsync-configuration-read-only?
> >> >> config)
> >> >> + "true" "false"))
> >> >> + (format port "timeout = ~a\n"
> >> >> + #$(number->string
> >> >> + (rsync-configuration-timeout config)))
> >> >> + #t)))))
> >> >
> >> > It might be neater here to use mixed-text-file here. It might
> >> > look something like...
> >> >
> >> > (define (rsync-config-file config)
> >> > "Return the rsync configuration file corresponding to CONFIG."
> >> > (match config
> >> > (($ <rsync-configuration> package port-number pid-file
> >> > lock-file log-file use-chroot? share-path
> >> > share-comment read-only? timeout)
> >> > (mixed text-file "rsync.conf"
> >> > "# Generated by 'rsync-service'.\n"
> >> > "pid file = " pid-file "\n"
> >> > "lock file = " lock-file "\n"
> >> > "log file = " log-file "\n"
> >> > "port = " (number->string port-number) "\n"
> >> > "use chroot = " (if use-chroot? "true" "false") "\n"
> >> > "[files]\n"
> >> > "path = " share-path "\n"
> >> > "comment = " share-comment "\n"
> >> > "read only = " (if read-only? "true" "false") "\n"
> >> > "timeout = " (number->string timeout) "\n"))))
>
> OK, patched.
>
> >> > One thing I tried with the Tailon service, was to define a
> >> > gexp-compiler for the record type representing the configuration
> >> > file. One really big advantage in the case of Tailon is that it
> >> > easily allows the use of a custom file, just by providing a
> >> > different gexp.
> >>
> >> So, this way you could provide your existing Tailon config as a
> >> file in system declaration? Nice.
> >
> > Yep, I think something like the following should just work, but I
> > haven't tested it yet.
> >
> > (service tailon-service-type
> > (tailon-configuration
> > (config-file (local-file "../tailon.yml"))))
> >
> > I bring this up, as I think it is great if this is a feature of all
> > services, I'm having trouble though working out how you might do
> > that in this case, with the use of values in the activation service
> > extension. I can see complicated approaches, but nothing simple and
> > clear enough.
>
> I tried to apply your work in tailon service, but I have troubles as
> you described. So I just cleaned up code little bit.

Those changes are looking good :) Could you send the overall patch, as
that makes it easier at least for me to review and test?
-----BEGIN PGP SIGNATURE-----

iQKTBAEBCgB9FiEEPonu50WOcg2XVOCyXiijOwuE9XcFAlmDQkJfFIAAAAAALgAo
aXNzdWVyLWZwckBub3RhdGlvbnMub3BlbnBncC5maWZ0aGhvcnNlbWFuLm5ldDNF
ODlFRUU3NDU4RTcyMEQ5NzU0RTBCMjVFMjhBMzNCMEI4NEY1NzcACgkQXiijOwuE
9XeqrBAAqrQP1qPR/lVnng7lzBct0jQeyFej/diBT1zDRy2iuG0Lo/01B/OSOrfc
+jBiPRsQB5gT9odIwlL2LpaHzKJ+Za5ypiWV6VhEHJ8s/vnGLpPlyUNS/+Uu7n/h
rH0GA0S050vbumFU3Raig3Gr+Stgr5wOSFRCRbIIJKL9lj/eK2VCPyJdbIjwlD34
ek1SbR8JlF6JvfXGFhxhV6A9zBiL3xaN62q/CCCnglgOOeq6TOWyIjwoZ627peH9
YMXfuN/pMHjewSqUTRU18IBKQF6UBIzM1gNG5+9e/XZ12Hv1Zij9lnCWvks9AqE8
2GoX9Xw2ul8zwNqOX2f6N1z+ny977H861i+SqxSHhYWCvULHz8QVzkctcXxL6uFF
QUNQcCN4ItADpQhaoGxAToNYl6H+cMc8BUx+P2VJGjYKxOGXeu1KOvbBgeyWBNhz
GLBbo2VgfbxSL0uKV1IvaQLae5+5rNeewsMUYl0U9Loa8mswDBmTbFeffPEH+1Gc
BTnwMt2lUAFC5NfuGpyeUs/wrRTKr/DIqDjlDPEBhIk19M0jTeApWIHowR1XPeOw
fNZQ9Y3dvvtQfmpDqZGpboCJdtH5E2yF6MNvcqPYga4kQBEy/BIozqzkjbrbxI9h
Fj8eBrwUNn5sUV6KLjJ+A85daRfj5zfoa1QSsSVNsGQrc1IBsVM=
=25GT
-----END PGP SIGNATURE-----


O
O
O
Oleg Pykhalov wrote on 3 Aug 2017 18:34
(name . Christopher Baines)(address . mail@cbaines.net)(address . 27855@debbugs.gnu.org)
87bmnwzk37.fsf@gmail.com
Sorry, I forget to change commit message in “* doc/guix.texi”.

It must be:
* doc/guix.texi (File transfer): Add documentation.
C
C
Christopher Baines wrote on 10 Aug 2017 09:18
(name . Oleg Pykhalov)(address . go.wigust@gmail.com)(address . 27855@debbugs.gnu.org)
20170810081820.71b29b0a@cbaines.net
Attachment: file
From 88c54c9778e72a66741fe26627d6ed00f6efe773 Mon Sep 17 00:00:00 2001
From: Christopher Baines <mail@cbaines.net>
Date: Tue, 8 Aug 2017 06:56:54 +0100
Subject: [PATCH] Add test

---
gnu/tests/rsync.scm | 104 ++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 104 insertions(+)
create mode 100644 gnu/tests/rsync.scm

Toggle diff (112 lines)
diff --git a/gnu/tests/rsync.scm b/gnu/tests/rsync.scm
new file mode 100644
index 000000000..abd3ff15d
--- /dev/null
+++ b/gnu/tests/rsync.scm
@@ -0,0 +1,104 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2017 Christopher Baines <mail@cbaines.net>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (gnu tests rsync)
+ #:use-module (gnu packages rsync)
+ #:use-module (gnu tests)
+ #:use-module (gnu system)
+ #:use-module (gnu system file-systems)
+ #:use-module (gnu system shadow)
+ #:use-module (gnu system vm)
+ #:use-module (gnu services)
+ #:use-module (gnu services rsync)
+ #:use-module (gnu services networking)
+ #:use-module (guix gexp)
+ #:use-module (guix store)
+ #:export (%test-rsync))
+
+(define %rsync-os
+ ;; Operating system under test.
+ (let ((base-os
+ (simple-operating-system
+ (dhcp-client-service)
+ (service rsync-service-type))))
+ (operating-system
+ (inherit base-os)
+ (packages (cons* rsync
+ (operating-system-packages base-os))))))
+
+(define* (run-rsync-test #:optional (port 8873))
+ "Run tests in %RSYNC-OS, which has rsync running and listening on
+PORT."
+ (define os
+ (marionette-operating-system
+ %rsync-os
+ #:imported-modules '((gnu services herd)
+ (guix combinators))))
+
+ (define vm
+ (virtual-machine
+ (operating-system os)
+ (port-forwardings `((,port . 873)))))
+
+ (define test
+ (with-imported-modules '((gnu build marionette))
+ #~(begin
+ (use-modules (srfi srfi-11) (srfi srfi-64)
+ (gnu build marionette)
+ (web uri)
+ (web client)
+ (web response))
+
+ (define marionette
+ (make-marionette (list #$vm)))
+
+ (mkdir #$output)
+ (chdir #$output)
+
+ (test-begin "rsync")
+
+ ;; rsync foo localhost::files/
+
+ ;; Wait for rsync to be up and running.
+ (test-eq "service running"
+ 'running!
+ (marionette-eval
+ '(begin
+ (use-modules (gnu services herd))
+ (start-service 'rsync)
+ 'running!)
+ marionette))
+
+ ;; Make sure the PID file is created.
+ (test-assert "PID file"
+ (marionette-eval
+ '(file-exists? "/var/run/rsyncd.pid")
+ marionette))
+
+ (test-end)
+ (exit (= (test-runner-fail-count (test-runner-current)) 0)))))
+
+ (gexp->derivation "rsync-test" test))
+
+(define %test-rsync
+ (system-test
+ (name "rsync")
+ (description "Connect to a running RSYNC server.")
+ (value (run-rsync-test))))
+
+%rsync-os
--
2.14.0
-----BEGIN PGP SIGNATURE-----

iQKTBAEBCgB9FiEEPonu50WOcg2XVOCyXiijOwuE9XcFAlmMCLxfFIAAAAAALgAo
aXNzdWVyLWZwckBub3RhdGlvbnMub3BlbnBncC5maWZ0aGhvcnNlbWFuLm5ldDNF
ODlFRUU3NDU4RTcyMEQ5NzU0RTBCMjVFMjhBMzNCMEI4NEY1NzcACgkQXiijOwuE
9XcKfRAApCVjUmiz+BvcOS8JJrI9KfsJMA2QgqgSh+eK8lY31PqrS/SNzBTzKIyC
aoBfWL3J5u0hx2yk3bueRPz3vDYweeKdCoPH9zSryW4vmXU+FmIm5PMSf37PTfTm
6Ws1rCYAaKMGZ22rr3zT7/II8MAf6762rE/mDEBwtvsgcdEfNFxpuwgBm+wFfKtn
YGaaBbjVbS5YuWKKoxRgxSCiWv7AAR89ioyb89S5zNjkUrpsXX7XYrQKwDAIgT0g
RhrOH6qo1QRdwWaPfDszpN+2++8tLwWUJHMfpqK0yg5vih+lGGbrJrOxtBUPJzWz
k+sEMhAHJoBw1+bML0d4vG9XfvxzN6FEHz0zHW8cpeF0BuzOAGXtZsDSOb9BnG47
ozEL05EaOI0fObx+JAwK/dWSSGgI01jzSMAasGFyuqsZmO/yFoWbuO378DvAkyxX
RMECiNtTTHWmchNXq5BRgxdeJR3Sa8LZeAiScluLC+nksBjEw48ffp8nPRZKK+A/
rdw9oat2VFxGQP7oygOyzSmlFhoxuUiCsBMyYUbBVM9ASMh9Kst0ZnibUsvtNTkz
vd0RxOJTISSjORqDqBZXmrp89cbP3sJO9dq1U+fT9z4JISNP5Q5iAFpFj4xDMkPF
QdERHMWXX7BtJmSEh0Q6zydKk1rjEShCnKeVnsWHBBmmzI7iyBk=
=78Wc
-----END PGP SIGNATURE-----


C
C
Christopher Baines wrote on 10 Aug 2017 20:21
(name . Oleg Pykhalov)(address . go.wigust@gmail.com)(address . 27855@debbugs.gnu.org)
20170810192139.2c3f04da@cbaines.net
On Thu, 10 Aug 2017 08:18:20 +0100
Christopher Baines <mail@cbaines.net> wrote:

Toggle quote (11 lines)
> I've attached the beginnings of a system test for this. I haven't got
> as far as actually testing the service directly yet, but I'm going to
> try testing it, both when running as root, and when not running as
> root.
>
> A VM start script can be created from this rsync.scm file, by running:
> guix system vm gnu/tests/rsync.scm
>
> Also, the test itself can be run by doing:
> make check-system TESTS=rsync

I've now got around to actually testing the service. I've attached a
patch which creates two system tests. One which tests the service with
the default port, and one with a higher port (I randomly picked 2000).

The default port test currently passes, but the higher port one
currently fails as the rsync service can't create the PID file.

One option to fix this would be to create a /var/run/rsync directory
which is owned by the rsyncd user, and then create the PID file
as /var/run/rsync/pid.

Just let me know if you have any questions?
-----BEGIN PGP SIGNATURE-----

iQKTBAEBCgB9FiEEPonu50WOcg2XVOCyXiijOwuE9XcFAlmMpDNfFIAAAAAALgAo
aXNzdWVyLWZwckBub3RhdGlvbnMub3BlbnBncC5maWZ0aGhvcnNlbWFuLm5ldDNF
ODlFRUU3NDU4RTcyMEQ5NzU0RTBCMjVFMjhBMzNCMEI4NEY1NzcACgkQXiijOwuE
9XeqpA/8DW1Ku3xPP7yE9i1rsH7IgTzxshxwYfCkqcyqpXhJet+KhJdkGHO7WKYx
4cvCR33MUrWPSkdoh2zOl7xKzpJxtKAJzpGnMx9uIYEH8OimfL5hueBE4QWjFXqj
sGk/WVdNsAOlhaLE7GI97sESE6rEtmprEg8w2xhLvEOK0iR7XrzTtY+WpPqD5SR9
Y2HtYHPGNHPRQrITlavfQRWx04Qn9AG8ZBg7IagOxQ9netN8AOdyv6GQ2BkY19mn
IOHD05FGzPb0/Mq6tw6QOcQJDmbbCJHtvFi3vCX6nUvppriYetatBHr6BxUcIDWX
2eDR1nN33mSPweM2VW4eqHuMN0nwS0INXVH9ca0AM97O3Wzih9z5QTgHNTKxVTpT
QIDqOXwPdM9m3cAVV2+6E/y+DPNyFkNFSGtSojevu5EdOJlb+kyoZ11YlWepqBtA
xwGxA7haTFqAxebjxAoDi84lnY+NpJew2JB80Kp7atTAOSgMPHCovBLURkc7ahy+
Tp/dt0ZwuDTMjh15vFz63Iglvo6d2JHjt4pYWIBltb0bhpkZkezQPaB3GAlrRthR
xeMdQLXhoIoT2GTe8GMObaGCeoVjpUbwCd0eQf1D49+djldmuk71kJJ9UMMXibFB
fNRGUePdWopXZYFqOUjBWZF2c3jIxf9L3jBpC7lFuNPNxA31xzo=
=ksgE
-----END PGP SIGNATURE-----


O
O
Oleg Pykhalov wrote on 10 Aug 2017 20:56
(name . Christopher Baines)(address . mail@cbaines.net)(address . 27855@debbugs.gnu.org)
87mv778d66.fsf@gmail.com
Hello Christopher,

Thank you for supporting this patch!

Christopher Baines <mail@cbaines.net> writes:

Toggle quote (25 lines)
> On Thu, 10 Aug 2017 08:18:20 +0100
> Christopher Baines <mail@cbaines.net> wrote:
>
>> I've attached the beginnings of a system test for this. I haven't got
>> as far as actually testing the service directly yet, but I'm going to
>> try testing it, both when running as root, and when not running as
>> root.
>>
>> A VM start script can be created from this rsync.scm file, by running:
>> guix system vm gnu/tests/rsync.scm
>>
>> Also, the test itself can be run by doing:
>> make check-system TESTS=rsync
>
> I've now got around to actually testing the service. I've attached a
> patch which creates two system tests. One which tests the service with
> the default port, and one with a higher port (I randomly picked 2000).
>
> The default port test currently passes, but the higher port one
> currently fails as the rsync service can't create the PID file.
>
> One option to fix this would be to create a /var/run/rsync directory
> which is owned by the rsyncd user, and then create the PID file
> as /var/run/rsync/pid.

I'll check it later, if you'll not be faster than me. :-)

Toggle quote (1 lines)
> Just let me know if you have any questions?

I successfully passed you previous patch test, but the new patch one
with two “ports” fails.
Attachment: file
O
O
Oleg Pykhalov wrote on 11 Aug 2017 21:28
(name . Christopher Baines)(address . mail@cbaines.net)(address . 27855@debbugs.gnu.org)
87y3qprjjd.fsf@gmail.com
Hello,

Toggle quote (39 lines)
> Hello Christopher,
>
> Thank you for supporting this patch!
>
> Christopher Baines <mail@cbaines.net> writes:
>
>> On Thu, 10 Aug 2017 08:18:20 +0100
>> Christopher Baines <mail@cbaines.net> wrote:
>>
>>> I've attached the beginnings of a system test for this. I haven't got
>>> as far as actually testing the service directly yet, but I'm going to
>>> try testing it, both when running as root, and when not running as
>>> root.
>>>
>>> A VM start script can be created from this rsync.scm file, by running:
>>> guix system vm gnu/tests/rsync.scm
>>>
>>> Also, the test itself can be run by doing:
>>> make check-system TESTS=rsync
>>
>> I've now got around to actually testing the service. I've attached a
>> patch which creates two system tests. One which tests the service with
>> the default port, and one with a higher port (I randomly picked 2000).
>>
>> The default port test currently passes, but the higher port one
>> currently fails as the rsync service can't create the PID file.
>>
>> One option to fix this would be to create a /var/run/rsync directory
>> which is owned by the rsyncd user, and then create the PID file
>> as /var/run/rsync/pid.
>
> I'll check it later, if you'll not be faster than me. :-)
>
>> Just let me know if you have any questions?
> …
>
> I successfully passed you previous patch test, but the new patch one
> with two “ports” fails.

Trying to understand what is going on. Working on your latest test
patch.

This is what I currently have. It's not differ from your patch except
commented test below. guix/gnu/tests/rsync.scm

I fully commented
(test-equal "Test file correctly received from share" …).

(test-assert "Test file copied to share"
(zero? ; ERROR HERE
(system* "rsync" "/tmp/input" "localhost::files/")))

Bottom of test log:
Toggle snippet (19 lines)
rsync: mkstemp ".input.Y6OhRW" (in files) failed: Permission denied (13)
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1178) [sender=3.1.2]
QEMU runs as PID 5
connected to QEMU's monitor
read QEMU monitor prompt
connected to guest REPL
%%%% Starting test rsync (Writing full log to "rsync.log")
marionette is ready
/gnu/store/bm3kvdwh8q3spvhxbmpmcjwz3fng8z5f-rsync-test-builder:1: FAIL Test file copied to share
# of expected passes 2
# of unexpected failures 1
note: keeping build directory `/tmp/guix-build-rsync-test.drv-9'
builder for `/gnu/store/1hv9c616m9xkgi549hgbn1y2vr8mnzfr-rsync-test.drv' failed with exit code 1
@ build-failed /gnu/store/1hv9c616m9xkgi549hgbn1y2vr8mnzfr-rsync-test.drv - 1 builder for `/gnu/store/1hv9c616m9xkgi549hgbn1y2vr8mnzfr-rsync-test.drv' failed with exit code 1
TOTAL: 1
FAIL: /gnu/store/s0rwmr3iha48jbw2b9xkzcqqsamdl21q-rsync-test
make: *** [Makefile:5217: check-system] Error 1

Also, I have (is related?) error on top of test log.
Toggle snippet (6 lines)
natsu@magnolia ~/src/guix$ ./pre-inst-env make check-system TESTS=rsync-with-default-port
Compiling Scheme modules...
warning: failed to load '(gnu tests admin)':
ERROR: In procedure allocate-struct: Wrong type argument in position 2: 8

Best wishes,

Oleg.
C
C
Christopher Baines wrote on 12 Aug 2017 08:59
(name . Oleg Pykhalov)(address . go.wigust@gmail.com)(address . 27855@debbugs.gnu.org)
20170812075903.0dc36c0c@cbaines.net
On Fri, 11 Aug 2017 22:28:22 +0300
Oleg Pykhalov <go.wigust@gmail.com> wrote:

Toggle quote (82 lines)
> Hello,
>
> > Hello Christopher,
> >
> > Thank you for supporting this patch!
> >
> > Christopher Baines <mail@cbaines.net> writes:
> >
> >> On Thu, 10 Aug 2017 08:18:20 +0100
> >> Christopher Baines <mail@cbaines.net> wrote:
> >>
> >>> I've attached the beginnings of a system test for this. I haven't
> >>> got as far as actually testing the service directly yet, but I'm
> >>> going to try testing it, both when running as root, and when not
> >>> running as root.
> >>>
> >>> A VM start script can be created from this rsync.scm file, by
> >>> running: guix system vm gnu/tests/rsync.scm
> >>>
> >>> Also, the test itself can be run by doing:
> >>> make check-system TESTS=rsync
> >>
> >> I've now got around to actually testing the service. I've attached
> >> a patch which creates two system tests. One which tests the
> >> service with the default port, and one with a higher port (I
> >> randomly picked 2000).
> >>
> >> The default port test currently passes, but the higher port one
> >> currently fails as the rsync service can't create the PID file.
> >>
> >> One option to fix this would be to create a /var/run/rsync
> >> directory which is owned by the rsyncd user, and then create the
> >> PID file as /var/run/rsync/pid.
> >
> > I'll check it later, if you'll not be faster than me. :-)
> >
> >> Just let me know if you have any questions?
> > …
> >
> > I successfully passed you previous patch test, but the new patch one
> > with two “ports” fails.
>
> Trying to understand what is going on. Working on your latest test
> patch.
>
> This is what I currently have. It's not differ from your patch except
> commented test below. guix/gnu/tests/rsync.scm
> https://paste.pound-python.org/raw/ZyfPIvOWAbPd7blPRXf7/
>
> I fully commented
> (test-equal "Test file correctly received from share" …).
>
> (test-assert "Test file copied to share"
> …
> (zero? ; ERROR HERE
> (system* "rsync" "/tmp/input" "localhost::files/")))
>
> Bottom of test log:
> --8<---------------cut here---------------start------------->8---
> rsync: mkstemp ".input.Y6OhRW" (in files) failed: Permission denied
> (13) rsync error: some files/attrs were not transferred (see previous
> errors) (code 23) at main.c(1178) [sender=3.1.2] QEMU runs as PID 5
> connected to QEMU's monitor
> read QEMU monitor prompt
> connected to guest REPL
> %%%% Starting test rsync (Writing full log to "rsync.log")
> marionette is ready
> /gnu/store/bm3kvdwh8q3spvhxbmpmcjwz3fng8z5f-rsync-test-builder:1:
> FAIL Test file copied to share # of expected passes 2
> # of unexpected failures 1
> note: keeping build directory `/tmp/guix-build-rsync-test.drv-9'
> builder for
> `/gnu/store/1hv9c616m9xkgi549hgbn1y2vr8mnzfr-rsync-test.drv' failed
> with exit code 1 @
> build-failed /gnu/store/1hv9c616m9xkgi549hgbn1y2vr8mnzfr-rsync-test.drv
> - 1 builder for
> `/gnu/store/1hv9c616m9xkgi549hgbn1y2vr8mnzfr-rsync-test.drv' failed
> with exit code 1 TOTAL: 1
> FAIL: /gnu/store/s0rwmr3iha48jbw2b9xkzcqqsamdl21q-rsync-test make:
> *** [Makefile:5217: check-system] Error 1 --8<---------------cut
> here---------------end--------------->8---

With the change to add the uid to the rsync configuration file, the
rsync-with-default-port passes for me. What test are you running here?


Toggle quote (8 lines)
> Also, I have (is related?) error on top of test log.
> --8<---------------cut here---------------start------------->8---
> natsu@magnolia ~/src/guix$ ./pre-inst-env make check-system
> TESTS=rsync-with-default-port Compiling Scheme modules...
> warning: failed to load '(gnu tests admin)':
> ERROR: In procedure allocate-struct: Wrong type argument in position
> 2: 8 --8<---------------cut here---------------end--------------->8---

I think I may have seen this error too, no idea what it relates to
though.
-----BEGIN PGP SIGNATURE-----

iQKTBAEBCgB9FiEEPonu50WOcg2XVOCyXiijOwuE9XcFAlmOpzdfFIAAAAAALgAo
aXNzdWVyLWZwckBub3RhdGlvbnMub3BlbnBncC5maWZ0aGhvcnNlbWFuLm5ldDNF
ODlFRUU3NDU4RTcyMEQ5NzU0RTBCMjVFMjhBMzNCMEI4NEY1NzcACgkQXiijOwuE
9XeLMA/+NDvstSJFyD/hXSNjeUblcVdrVRPHD6cXn5femSkImZQVQBoUSEERQG8w
WDFlVcM6yeDe0jBbbqruHnpBbvxvjQ40kcq0OPJNtdLsQvmYm6rNJP6axTBNBNgs
HZkJMAf6o7S7I1R76JaDHEsCodbppGw81GuRCaH/s1HlDdukswDO1h2iXAu3KzxJ
JsKIY1MzJ85revxtyC76SnyeH48wSRKm6QBOnw23JudwGKkTunJ2l70r+XpKiho4
A6EyUnDvhbsuirWfF/NU6gB1TBg67DtvFkYzRxuB/iUg0toUYHxmVlHcp1qn50si
C7YcYGEDvRnJRZ+g3ejw3SP94WWud5/NKBwu8X5RDD62ye3w/mbdMjYK5OEeB0iV
jLSNe8lhf/IMv7NyeYJJu+30r9HM6cAV5FJg/uYnVpWo4Fqvxc8WStYZjgVPTp68
FW+rpmf2apcx2q03XDZ1APDOpa0pShGYcBYPAPAOJnzMGKuJ7wyBJWpJpOjI2IaL
xTROr9ATLbZJBkLv1hHmyAYWJTEjeJl9nC394oeuLjiodmAP7JQcsNwRlCVBc1/k
Sszk5UIkgr02np4lkxqHXFvI2s5H5m8hVAeIUgyRwetyT2eODB0JY+2iXdqrT07q
AryVDolBX3jTxVJY74nySyx918i7RfWN2KDwCQVJhVgIHF0PeJo=
=V3bK
-----END PGP SIGNATURE-----


O
O
Oleg Pykhalov wrote on 12 Aug 2017 15:13
(name . Christopher Baines)(address . mail@cbaines.net)(address . 27855@debbugs.gnu.org)
87valtylnc.fsf@gmail.com
Hello Christopher,

Christopher Baines <mail@cbaines.net> writes:

Toggle quote (77 lines)
>> >> On Thu, 10 Aug 2017 08:18:20 +0100
>> >> Christopher Baines <mail@cbaines.net> wrote:
>> >>
>> >>> I've attached the beginnings of a system test for this. I haven't
>> >>> got as far as actually testing the service directly yet, but I'm
>> >>> going to try testing it, both when running as root, and when not
>> >>> running as root.
>> >>>
>> >>> A VM start script can be created from this rsync.scm file, by
>> >>> running: guix system vm gnu/tests/rsync.scm
>> >>>
>> >>> Also, the test itself can be run by doing:
>> >>> make check-system TESTS=rsync
>> >>
>> >> I've now got around to actually testing the service. I've attached
>> >> a patch which creates two system tests. One which tests the
>> >> service with the default port, and one with a higher port (I
>> >> randomly picked 2000).
>> >>
>> >> The default port test currently passes, but the higher port one
>> >> currently fails as the rsync service can't create the PID file.
>> >>
>> >> One option to fix this would be to create a /var/run/rsync
>> >> directory which is owned by the rsyncd user, and then create the
>> >> PID file as /var/run/rsync/pid.
>> >
>> > I'll check it later, if you'll not be faster than me. :-)
>> >
>> >> Just let me know if you have any questions?
>> > …
>> >
>> > I successfully passed you previous patch test, but the new patch one
>> > with two “ports” fails.
>>
>> Trying to understand what is going on. Working on your latest test
>> patch.
>>
>> This is what I currently have. It's not differ from your patch except
>> commented test below. guix/gnu/tests/rsync.scm
>> https://paste.pound-python.org/raw/ZyfPIvOWAbPd7blPRXf7/
>>
>> I fully commented
>> (test-equal "Test file correctly received from share" …).
>>
>> (test-assert "Test file copied to share"
>> …
>> (zero? ; ERROR HERE
>> (system* "rsync" "/tmp/input" "localhost::files/")))
>>
>> Bottom of test log:
>> --8<---------------cut here---------------start------------->8---
>> rsync: mkstemp ".input.Y6OhRW" (in files) failed: Permission denied
>> (13) rsync error: some files/attrs were not transferred (see previous
>> errors) (code 23) at main.c(1178) [sender=3.1.2] QEMU runs as PID 5
>> connected to QEMU's monitor
>> read QEMU monitor prompt
>> connected to guest REPL
>> %%%% Starting test rsync (Writing full log to "rsync.log")
>> marionette is ready
>> /gnu/store/bm3kvdwh8q3spvhxbmpmcjwz3fng8z5f-rsync-test-builder:1:
>> FAIL Test file copied to share # of expected passes 2
>> # of unexpected failures 1
>> note: keeping build directory `/tmp/guix-build-rsync-test.drv-9'
>> builder for
>> `/gnu/store/1hv9c616m9xkgi549hgbn1y2vr8mnzfr-rsync-test.drv' failed
>> with exit code 1 @
>> build-failed /gnu/store/1hv9c616m9xkgi549hgbn1y2vr8mnzfr-rsync-test.drv
>> - 1 builder for
>> `/gnu/store/1hv9c616m9xkgi549hgbn1y2vr8mnzfr-rsync-test.drv' failed
>> with exit code 1 TOTAL: 1
>> FAIL: /gnu/store/s0rwmr3iha48jbw2b9xkzcqqsamdl21q-rsync-test make:
>> *** [Makefile:5217: check-system] Error 1 --8<---------------cut
>> here---------------end--------------->8---
>
> With the change to add the uid to the rsync configuration file, the
> rsync-with-default-port passes for me. What test are you running here?

It was “rsync-with-default-port”. With “uid” passed successfully all
tests in “rsync-with-default-port”.

Test 2000 port
==============

The “test-rsync-with-port-2000” fails, because we sync with default
rsync protocol port in this test but we need 2000.

Toggle snippet (5 lines)
(test-assert "Test file copied to share"
(system* "rsync" "/tmp/input" "localhost::files/"))

Why I thought about this:
Toggle snippet (6 lines)
rsync: failed to connect to localhost (127.0.0.1): Connection refused (111)
rsync error: error in socket IO (code 10) at clientserver.c(125) [sender=3.1.2]
rsync: failed to connect to localhost (127.0.0.1): Connection refused (111)
rsync error: error in socket IO (code 10) at clientserver.c(125) [Receiver=3.1.2]

Next lines:
Toggle snippet (20 lines)
ice-9/eval.scm:387:11: In procedure eval:
ice-9/eval.scm:387:11: In procedure open-file: No such file or directory: "/tmp/output"
QEMU runs as PID 5
connected to QEMU's monitor
read QEMU monitor prompt
connected to guest REPL
%%%% Starting test rsync (Writing full log to "rsync.log")
marionette is ready
/gnu/store/ahmg6h2fnap2znwhl6b4jrjgp830h4dv-rsync-test-builder:1: FAIL Test file copied to share
/gnu/store/ahmg6h2fnap2znwhl6b4jrjgp830h4dv-rsync-test-builder:1: FAIL Test file correctly received from share
# of expected passes 2
# of unexpected failures 2
note: keeping build directory `/tmp/guix-build-rsync-test.drv-13'
builder for `/gnu/store/9fakmd8dqzdw1ybff6gb00qfzhrwqdis-rsync-test.drv' failed with exit code 1
@ build-failed /gnu/store/9fakmd8dqzdw1ybff6gb00qfzhrwqdis-rsync-test.drv - 1 builder for `/gnu/store/9fakmd8dqzdw1ybff6gb00qfzhrwqdis-rsync-test.drv' failed with exit code 1
TOTAL: 1
FAIL: /gnu/store/rmb3hywspr34fwp5xinphaml7c4xjpvk-rsync-test
make: *** [Makefile:5217: check-system] Error 1

I only fixed PID error in current moment.

gnu/tests/rsync.scm

gnu/services/rsync.scm

Toggle quote (11 lines)
>> Also, I have (is related?) error on top of test log.
>> --8<---------------cut here---------------start------------->8---
>> natsu@magnolia ~/src/guix$ ./pre-inst-env make check-system
>> TESTS=rsync-with-default-port Compiling Scheme modules...
>> warning: failed to load '(gnu tests admin)':
>> ERROR: In procedure allocate-struct: Wrong type argument in position
>> 2: 8 --8<---------------cut here---------------end--------------->8---
>
> I think I may have seen this error too, no idea what it relates to
> though.

Should we report this as a bug?
C
C
Christopher Baines wrote on 12 Aug 2017 19:46
(name . Oleg Pykhalov)(address . go.wigust@gmail.com)(address . 27855@debbugs.gnu.org)
20170812184649.2003677a@cbaines.net
On Sat, 12 Aug 2017 16:13:11 +0300
Oleg Pykhalov <go.wigust@gmail.com> wrote:

Toggle quote (141 lines)
> Hello Christopher,
>
> Christopher Baines <mail@cbaines.net> writes:
>
> …
> >> >> On Thu, 10 Aug 2017 08:18:20 +0100
> >> >> Christopher Baines <mail@cbaines.net> wrote:
> >> >>
> >> >>> I've attached the beginnings of a system test for this. I
> >> >>> haven't got as far as actually testing the service directly
> >> >>> yet, but I'm going to try testing it, both when running as
> >> >>> root, and when not running as root.
> >> >>>
> >> >>> A VM start script can be created from this rsync.scm file, by
> >> >>> running: guix system vm gnu/tests/rsync.scm
> >> >>>
> >> >>> Also, the test itself can be run by doing:
> >> >>> make check-system TESTS=rsync
> >> >>
> >> >> I've now got around to actually testing the service. I've
> >> >> attached a patch which creates two system tests. One which
> >> >> tests the service with the default port, and one with a higher
> >> >> port (I randomly picked 2000).
> >> >>
> >> >> The default port test currently passes, but the higher port one
> >> >> currently fails as the rsync service can't create the PID file.
> >> >>
> >> >> One option to fix this would be to create a /var/run/rsync
> >> >> directory which is owned by the rsyncd user, and then create the
> >> >> PID file as /var/run/rsync/pid.
> >> >
> >> > I'll check it later, if you'll not be faster than me. :-)
> >> >
> >> >> Just let me know if you have any questions?
> >> > …
> >> >
> >> > I successfully passed you previous patch test, but the new patch
> >> > one with two “ports” fails.
> >>
> >> Trying to understand what is going on. Working on your latest test
> >> patch.
> >>
> >> This is what I currently have. It's not differ from your patch
> >> except commented test below. guix/gnu/tests/rsync.scm
> >> https://paste.pound-python.org/raw/ZyfPIvOWAbPd7blPRXf7/
> >>
> >> I fully commented
> >> (test-equal "Test file correctly received from share" …).
> >>
> >> (test-assert "Test file copied to share"
> >> …
> >> (zero? ; ERROR HERE
> >> (system* "rsync" "/tmp/input" "localhost::files/")))
> >>
> >> Bottom of test log:
> >> --8<---------------cut here---------------start------------->8---
> >> rsync: mkstemp ".input.Y6OhRW" (in files) failed: Permission denied
> >> (13) rsync error: some files/attrs were not transferred (see
> >> previous errors) (code 23) at main.c(1178) [sender=3.1.2] QEMU
> >> runs as PID 5 connected to QEMU's monitor
> >> read QEMU monitor prompt
> >> connected to guest REPL
> >> %%%% Starting test rsync (Writing full log to "rsync.log")
> >> marionette is ready
> >> /gnu/store/bm3kvdwh8q3spvhxbmpmcjwz3fng8z5f-rsync-test-builder:1:
> >> FAIL Test file copied to share # of expected passes 2
> >> # of unexpected failures 1
> >> note: keeping build directory `/tmp/guix-build-rsync-test.drv-9'
> >> builder for
> >> `/gnu/store/1hv9c616m9xkgi549hgbn1y2vr8mnzfr-rsync-test.drv' failed
> >> with exit code 1 @
> >> build-failed /gnu/store/1hv9c616m9xkgi549hgbn1y2vr8mnzfr-rsync-test.drv
> >> - 1 builder for
> >> `/gnu/store/1hv9c616m9xkgi549hgbn1y2vr8mnzfr-rsync-test.drv' failed
> >> with exit code 1 TOTAL: 1
> >> FAIL: /gnu/store/s0rwmr3iha48jbw2b9xkzcqqsamdl21q-rsync-test make:
> >> *** [Makefile:5217: check-system] Error 1 --8<---------------cut
> >> here---------------end--------------->8---
> >
> > With the change to add the uid to the rsync configuration file, the
> > rsync-with-default-port passes for me. What test are you running
> > here?
>
> It was “rsync-with-default-port”. With “uid” passed successfully all
> tests in “rsync-with-default-port”.
>
> Test 2000 port
> ==============
>
> The “test-rsync-with-port-2000” fails, because we sync with default
> rsync protocol port in this test but we need 2000.
>
> --8<---------------cut here---------------start------------->8---
> (test-assert "Test file copied to share"
> …
> (system* "rsync" "/tmp/input" "localhost::files/"))
> --8<---------------cut here---------------end--------------->8---
>
> Why I thought about this:
> --8<---------------cut here---------------start------------->8---
> rsync: failed to connect to localhost (127.0.0.1): Connection refused
> (111) rsync error: error in socket IO (code 10) at
> clientserver.c(125) [sender=3.1.2] rsync: failed to connect to
> localhost (127.0.0.1): Connection refused (111) rsync error: error in
> socket IO (code 10) at clientserver.c(125) [Receiver=3.1.2]
> --8<---------------cut here---------------end--------------->8---
>
> Next lines:
> --8<---------------cut here---------------start------------->8---
> ice-9/eval.scm:387:11: In procedure eval:
> ice-9/eval.scm:387:11: In procedure open-file: No such file or
> directory: "/tmp/output" QEMU runs as PID 5
> connected to QEMU's monitor
> read QEMU monitor prompt
> connected to guest REPL
> %%%% Starting test rsync (Writing full log to "rsync.log")
> marionette is ready
> /gnu/store/ahmg6h2fnap2znwhl6b4jrjgp830h4dv-rsync-test-builder:1:
> FAIL Test file copied to
> share /gnu/store/ahmg6h2fnap2znwhl6b4jrjgp830h4dv-rsync-test-builder:1:
> FAIL Test file correctly received from share # of expected
> passes 2 # of unexpected failures 2 note: keeping build
> directory `/tmp/guix-build-rsync-test.drv-13' builder for
> `/gnu/store/9fakmd8dqzdw1ybff6gb00qfzhrwqdis-rsync-test.drv' failed
> with exit code 1 @
> build-failed /gnu/store/9fakmd8dqzdw1ybff6gb00qfzhrwqdis-rsync-test.drv
> - 1 builder for
> `/gnu/store/9fakmd8dqzdw1ybff6gb00qfzhrwqdis-rsync-test.drv' failed
> with exit code 1 TOTAL: 1
> FAIL: /gnu/store/rmb3hywspr34fwp5xinphaml7c4xjpvk-rsync-test make:
> *** [Makefile:5217: check-system] Error 1 --8<---------------cut
> here---------------end--------------->8---
>
> I only fixed PID error in current moment.
>
> gnu/tests/rsync.scm
> https://paste.pound-python.org/raw/D4ccInuJG0g0899GCdy2/
>
> gnu/services/rsync.scm
> https://paste.pound-python.org/raw/URDLeIV3XFZ29SjcZYc6/

Yep, I think I just stopped writing the test after finding the issue
with the PID file.

I haven't looked in to how to fix this in the test, so if you could,
that would be great. Otherwise, I'll probably have time to look at this
again within a week or so.

You'll probably need to refactor the test a bit, as at the moment, the
information regarding the port isn't available where you run the
commands.

Toggle quote (14 lines)
> >> Also, I have (is related?) error on top of test log.
> >> --8<---------------cut here---------------start------------->8---
> >> natsu@magnolia ~/src/guix$ ./pre-inst-env make check-system
> >> TESTS=rsync-with-default-port Compiling Scheme modules...
> >> warning: failed to load '(gnu tests admin)':
> >> ERROR: In procedure allocate-struct: Wrong type argument in
> >> position 2: 8 --8<---------------cut
> >> here---------------end--------------->8---
> >
> > I think I may have seen this error too, no idea what it relates to
> > though.
>
> Should we report this as a bug?

Ideally yes, but I have no idea where the bug might be. I guess it
might be Guile, as I didn't find anything named allocate-struct in Guix.
-----BEGIN PGP SIGNATURE-----

iQKTBAEBCgB9FiEEPonu50WOcg2XVOCyXiijOwuE9XcFAlmPPwlfFIAAAAAALgAo
aXNzdWVyLWZwckBub3RhdGlvbnMub3BlbnBncC5maWZ0aGhvcnNlbWFuLm5ldDNF
ODlFRUU3NDU4RTcyMEQ5NzU0RTBCMjVFMjhBMzNCMEI4NEY1NzcACgkQXiijOwuE
9XdbTg//RF4YlWsZR3CcMVyjpnXMML2O5nM3kOjce+1pRsRGXG0+Fz3lyHCavXVn
7MxHto/ymyFm/4iZMPiOtDEJqxL7e+rYgBGH0nn/T+9QyjeGZyDK8ZuFGTDS9WH8
5psZnSRQfhgJ3aMOvUTj1ObvZhudg3dhkYmkSwzxo+tmuS7eRhc6t00wpkLtzVaX
BtRn9DyPAslGA1XZ7bGKALIafmSLEJGl+r/owMx9R7tvEY14ynfK+VzuqXDHAzV3
1ooh16Au3bnKDAzSDRy6HJ11j2xm1ykbHmP7+jIflYh5/CIOiG7R22YHxX0DmWgp
ancr9KX00yjqftubqtFQL1fg5LiUpK+7iAhVQ8AS3/PwrOmsB/YheXyiuHtdtNzq
F2z71Po/6mX6CmbHkio6kkXSxjTIXC0q5w5idK9B4Sm5OwqujbnzBWBSqHMuoVir
BTzlQeBEaNksPqEgBF6CTL6yvnFNRjnWn80giZ9wh4LDTZuCqtrgCg76OMwsiT4n
kaOgVtcHD0LaC9NBPo1EIjjXf4iQMNSLUKe7z1Kbnz2J5sciAIGmj5k1SmzB/v93
DfUTUIlIEQVfoL6a3zyOx+K4bk/bZRpcayY2jPbFQDthEDqCGXWBoviTTb+2o99z
l+kVMhR+TAgQmN1c4WX1wpZdiWcIwAL/4IsU92QHGa0eZwSFCUA=
=ixoM
-----END PGP SIGNATURE-----


O
O
Oleg Pykhalov wrote on 12 Aug 2017 22:19
(name . Christopher Baines)(address . mail@cbaines.net)(address . 27855@debbugs.gnu.org)
87wp68wnbz.fsf@gmail.com
Christopher Baines <mail@cbaines.net> writes:


Toggle quote (11 lines)
> Yep, I think I just stopped writing the test after finding the issue
> with the PID file.
>
> I haven't looked in to how to fix this in the test, so if you could,
> that would be great. Otherwise, I'll probably have time to look at this
> again within a week or so.
>
> You'll probably need to refactor the test a bit, as at the moment, the
> information regarding the port isn't available where you run the
> commands.

Of course I'll try. By the way, how to run a “vm”? Previous method
“./pre-inst-env guix system vm gnu/tests/rsync.scm” doesn't work for me.

Toggle snippet (39 lines)
Backtrace:
5 (primitive-load "/home/natsu/src/guix/scripts/guix")
In guix/ui.scm:
1331:12 4 (run-guix-command _ . _)
In ice-9/boot-9.scm:
837:9 3 (catch _ _ #<procedure 7f61aed3b8c0 at guix/ui.scm:448:2 (key c)> _)
837:9 2 (catch _ _ #<procedure 7f61aed3b8d8 at guix/ui.scm:536:6 (key pro…> …)
In guix/scripts/system.scm:
1026:8 1 (_)
905:28 0 (process-action vm _ ((argument . "gnu/tests/rsync.scm") (# . vm) …))

guix/scripts/system.scm:905:28: In procedure process-action:
guix/scripts/system.scm:905:28: In procedure struct_vtable: Wrong type argument in position 1 (expecting struct): #<unspecified>--8<---------------cut here---------------end--------------->8---

>> >> Also, I have (is related?) error on top of test log.
>> >> --8<---------------cut here---------------start------------->8---
>> >> natsu@magnolia ~/src/guix$ ./pre-inst-env make check-system
>> >> TESTS=rsync-with-default-port Compiling Scheme modules...
>> >> warning: failed to load '(gnu tests admin)':
>> >> ERROR: In procedure allocate-struct: Wrong type argument in
>> >> position 2: 8 --8<---------------cut
>> >> here---------------end--------------->8---
>> >
>> > I think I may have seen this error too, no idea what it relates to
>> > though.
>>
>> Should we report this as a bug?
>
> Ideally yes, but I have no idea where the bug might be. I guess it
> might be Guile, as I didn't find anything named allocate-struct in Guix.

Also for a good bug report we need to understand “What fails” and “What
you expect”, I guess. Will be a challenge. :-)

--
Best regards,

Oleg.
C
C
Christopher Baines wrote on 12 Aug 2017 23:19
(name . Oleg Pykhalov)(address . go.wigust@gmail.com)(address . 27855@debbugs.gnu.org)
20170812221817.3f04b061@cbaines.net
On Sat, 12 Aug 2017 23:19:44 +0300
Oleg Pykhalov <go.wigust@gmail.com> wrote:

Toggle quote (19 lines)
> Christopher Baines <mail@cbaines.net> writes:
>
> …
>
> > Yep, I think I just stopped writing the test after finding the issue
> > with the PID file.
> >
> > I haven't looked in to how to fix this in the test, so if you could,
> > that would be great. Otherwise, I'll probably have time to look at
> > this again within a week or so.
> >
> > You'll probably need to refactor the test a bit, as at the moment,
> > the information regarding the port isn't available where you run the
> > commands.
>
> Of course I'll try. By the way, how to run a “vm”? Previous method
> “./pre-inst-env guix system vm gnu/tests/rsync.scm” doesn't work for
> me.

I'm guessing that you'll need to make the file evaluate (I'm not sure if
that is the right word here) to an operating-system, e.g. put
%rsync-os-with-port-2000 right at the bottom of the file, and then guix
system vm should give you a start script that will start a VM for that
OS.
-----BEGIN PGP SIGNATURE-----

iQKTBAEBCgB9FiEEPonu50WOcg2XVOCyXiijOwuE9XcFAlmPcMRfFIAAAAAALgAo
aXNzdWVyLWZwckBub3RhdGlvbnMub3BlbnBncC5maWZ0aGhvcnNlbWFuLm5ldDNF
ODlFRUU3NDU4RTcyMEQ5NzU0RTBCMjVFMjhBMzNCMEI4NEY1NzcACgkQXiijOwuE
9XeArA//ekvkKBN/Pz8dRERLVJCDXSRwgmTh09W9JH6AjeZokfr1VhORfTXxlg1m
gsMVF4lX/Jfg9460K94JpH6UUPw5FAOvoPB90AR09+n4rYjk/s9eFbW0Y9KvtbSo
QJ0TPGTD95ZY4ChQnGLs4Pi6n1IhRPAwhvH+tjzhGyqgi/JbqOVHVv/ioIt8NKsF
nXgGotUMhx9eGexcPtzh13lRbPdGMaifrOmWTvD4kQP0HZ1K2L/16mbT1XllOrjF
z7sP/yZLNLIWPdlKdRBPwRuWvHJJQgsV8yl1CMhEUAkOWzZUq/tHt1uofWsz6Gwf
EctZb6JioLRWH3je5QgvoFhoAKxCm8YBmkQ3/+ZyMK3oCvw5dW3kj7A+i719M0By
Tke6/ls1T65LUgYZjZGS9O4uhWZpqiYA8M93uvqlKtOtC4b63fg2O3dW7ksPuO8t
mVvS0G2z1RKaXCs0b0j1tXK091GOtwSgAW+pk015Jc0X001Dq+F/E/3ZJ1JKOAkY
qcqYs+BqpksSXnnxeEXUT62skI483TR2+oBrCmqbFiN/fTNmOoq0WvVlH/BqJBgF
vUqqgBqWnfSXoQDRaqhERT9H+DalwI9npT3/aoMzl0cbzEnu/yysXH6K2KByIsQQ
KmX0BAu38XhW+H4ENtfaoEG3Hebgk3JA4FxLtk0q4PVLY1FXli0=
=8rWH
-----END PGP SIGNATURE-----


O
O
Oleg Pykhalov wrote on 19 Aug 2017 22:34
(name . Christopher Baines)(address . mail@cbaines.net)(address . 27855@debbugs.gnu.org)
87o9rb8fg3.fsf@gmail.com
Hello Christopher,

Christopher Baines <mail@cbaines.net> writes:

Toggle quote (21 lines)
>> > Yep, I think I just stopped writing the test after finding the issue
>> > with the PID file.
>> >
>> > I haven't looked in to how to fix this in the test, so if you could,
>> > that would be great. Otherwise, I'll probably have time to look at
>> > this again within a week or so.
>> >
>> > You'll probably need to refactor the test a bit, as at the moment,
>> > the information regarding the port isn't available where you run the
>> > commands.
>>
>> Of course I'll try. By the way, how to run a “vm”? Previous method
>> “./pre-inst-env guix system vm gnu/tests/rsync.scm” doesn't work for
>> me.
>
> I'm guessing that you'll need to make the file evaluate (I'm not sure if
> that is the right word here) to an operating-system, e.g. put
> %rsync-os-with-port-2000 right at the bottom of the file, and then guix
> system vm should give you a start script that will start a VM for that
> OS.

I did some work on rsync service:

- Fixed PID and synchronization to specific port.
- Merged two rsync oses in one with optional port.
- Added ports to rsync synchronization tests and change protocol from
ssh to rsync.
- Added some logic to config: chroot (can use only root), user and
group.

All tests passed successfully for me.
C
C
Christopher Baines wrote on 20 Aug 2017 00:19
(name . Oleg Pykhalov)(address . go.wigust@gmail.com)(address . 27855@debbugs.gnu.org)
20170819231949.0ce64135@cbaines.net
On Sat, 19 Aug 2017 23:34:20 +0300
Oleg Pykhalov <go.wigust@gmail.com> wrote:

Toggle quote (36 lines)
> Hello Christopher,
>
> Christopher Baines <mail@cbaines.net> writes:
>
> >> > Yep, I think I just stopped writing the test after finding the
> >> > issue with the PID file.
> >> >
> >> > I haven't looked in to how to fix this in the test, so if you
> >> > could, that would be great. Otherwise, I'll probably have time
> >> > to look at this again within a week or so.
> >> >
> >> > You'll probably need to refactor the test a bit, as at the
> >> > moment, the information regarding the port isn't available where
> >> > you run the commands.
> >>
> >> Of course I'll try. By the way, how to run a “vm”? Previous
> >> method “./pre-inst-env guix system vm gnu/tests/rsync.scm” doesn't
> >> work for me.
> >
> > I'm guessing that you'll need to make the file evaluate (I'm not
> > sure if that is the right word here) to an operating-system, e.g.
> > put %rsync-os-with-port-2000 right at the bottom of the file, and
> > then guix system vm should give you a start script that will start
> > a VM for that OS.
>
> I did some work on rsync service:
>
> - Fixed PID and synchronization to specific port.
> - Merged two rsync oses in one with optional port.
> - Added ports to rsync synchronization tests and change protocol from
> ssh to rsync.
> - Added some logic to config: chroot (can use only root), user and
> group.
>
> All tests passed successfully for me.

Great :) Now that the tests pass at least, I don't see any reason to
not merge this soonish.

I've still done some thingking about how the configuration works
though, and I've been considering a few ways of tweaking this so that
its harder to break, and clear in how it works.

One way I've managed to break the service so far is setting the user
and group to root in the configuration. This causes the tests to fail,
and in a odd way, as I think the problem is that the creation of
the /var/run/rsync directory relies on the account service, but I'm
guessing that the account service does nothing in this case, as root is
already an account.

One way of making this harder to break would be to explicitly create
the necessary directories when this service is activated, e.g.:

(mkdir-p (dirname #$(rsync-configuration-pid-file config)))
(mkdir-p (dirname #$(rsync-configuration-lock-file config)))

I think there is also the opportunity to make the service configuration
clearer here, as considering the default port test, the default
configuration says it will run as the rsync user, but the service will
actually run as the root user.

This could be improved by making the configuration more uncertain by
default, e.g. user defaults to #f, which means the correct user is
decided based on the port.

Also on the subject of clarity, the use-chroot? option is something
that can be specified, but the value might not be used. My preference
would be to change the "logic" in the configuration file generation, to
validation, e.g.:

(if (and use-chroot? (not (eq? user "root")))
(error "rsync-service: to run rsync in a chroot, the user must be root"))

The use-chroot? option might also benefit from making the user default
to #f, as then the service could decide the user based on the port and
use-chroot? settings, without contradicting the configuration.
-----BEGIN PGP SIGNATURE-----

iQKTBAEBCgB9FiEEPonu50WOcg2XVOCyXiijOwuE9XcFAlmYuYVfFIAAAAAALgAo
aXNzdWVyLWZwckBub3RhdGlvbnMub3BlbnBncC5maWZ0aGhvcnNlbWFuLm5ldDNF
ODlFRUU3NDU4RTcyMEQ5NzU0RTBCMjVFMjhBMzNCMEI4NEY1NzcACgkQXiijOwuE
9Xd/RRAAg3IylWaNFdF0woe2zEzuQp3bN7GsNn+PEpdFuHXQVF7XtK1A14NKukM8
ATc+HgrZv6SUHOo+5nvopdHN3++a8/6jdnO7dj/OTWOQKrpMeGVFayUizXoqpg6r
JjjxzMTrRi7eFE611wFiMRyLUH+nSaUBAmgHN01u+qQAarRcV1ej5vWIgd2WwLDO
9XDm/58uDT0EbVqRoQMbG5lqUVyfWnQLMzhUAQi83C0JxSDtZO5soW2H+vsu6HC6
24dhsvItdkRHIN92UBnfu5t4qN2LZy3qBwrwjnxBmHrsItb/zJQseBS5NPk0Lji2
0lFBvIuHemJJRckcyhPd4msNTn97GtrALH7ZvqbtzVb5sAVrm4kkhPmmrqa7Eo8I
AQ9TFm4D+nzW7zpXOfiCy9U8ZtqL8i6AQrix6xG09ufkoK71v4uHVRtQAT28NIfN
52K8G7HVpjZnx3Q48JnZZdWI5iqE9daLTKWyllPNVoBKBby1F/CtgYDnmpTfJgIP
PhgJWCBMTnthFv0UkzTS4rkjgW39LBpSXeyXP6Ir/TGXmF7PgeASOmm4hbnBAsRM
BNg6VNDnjk/T3IYR7T526vGcQBDAjOApV3RFBtmwS5ZJD/ue5WRNlkno595CNyKW
0mjVP5JXP7Lryy4g3zPQst9iMh5rTuD0D0EZVraZXDGEmaXGBL0=
=4Gep
-----END PGP SIGNATURE-----


O
O
Oleg Pykhalov wrote on 25 Aug 2017 00:40
(name . Christopher Baines)(address . mail@cbaines.net)(address . 27855@debbugs.gnu.org)
87d17kh9n8.fsf@gmail.com
Hello Christopher,

Christopher Baines <mail@cbaines.net> writes:

Toggle quote (73 lines)
>> >> > Yep, I think I just stopped writing the test after finding the
>> >> > issue with the PID file.
>> >> >
>> >> > I haven't looked in to how to fix this in the test, so if you
>> >> > could, that would be great. Otherwise, I'll probably have time
>> >> > to look at this again within a week or so.
>> >> >
>> >> > You'll probably need to refactor the test a bit, as at the
>> >> > moment, the information regarding the port isn't available where
>> >> > you run the commands.
>> >>
>> >> Of course I'll try. By the way, how to run a “vm”? Previous
>> >> method “./pre-inst-env guix system vm gnu/tests/rsync.scm” doesn't
>> >> work for me.
>> >
>> > I'm guessing that you'll need to make the file evaluate (I'm not
>> > sure if that is the right word here) to an operating-system, e.g.
>> > put %rsync-os-with-port-2000 right at the bottom of the file, and
>> > then guix system vm should give you a start script that will start
>> > a VM for that OS.
>>
>> I did some work on rsync service:
>>
>> - Fixed PID and synchronization to specific port.
>> - Merged two rsync oses in one with optional port.
>> - Added ports to rsync synchronization tests and change protocol from
>> ssh to rsync.
>> - Added some logic to config: chroot (can use only root), user and
>> group.
>>
>> All tests passed successfully for me.
>
> Great :) Now that the tests pass at least, I don't see any reason to
> not merge this soonish.
>
> I've still done some thingking about how the configuration works
> though, and I've been considering a few ways of tweaking this so that
> its harder to break, and clear in how it works.
>
> One way I've managed to break the service so far is setting the user
> and group to root in the configuration. This causes the tests to fail,
> and in a odd way, as I think the problem is that the creation of
> the /var/run/rsync directory relies on the account service, but I'm
> guessing that the account service does nothing in this case, as root is
> already an account.
>
> One way of making this harder to break would be to explicitly create
> the necessary directories when this service is activated, e.g.:
>
> (mkdir-p (dirname #$(rsync-configuration-pid-file config)))
> (mkdir-p (dirname #$(rsync-configuration-lock-file config)))
>
> I think there is also the opportunity to make the service configuration
> clearer here, as considering the default port test, the default
> configuration says it will run as the rsync user, but the service will
> actually run as the root user.
>
> This could be improved by making the configuration more uncertain by
> default, e.g. user defaults to #f, which means the correct user is
> decided based on the port.
>
> Also on the subject of clarity, the use-chroot? option is something
> that can be specified, but the value might not be used. My preference
> would be to change the "logic" in the configuration file generation, to
> validation, e.g.:
>
> (if (and use-chroot? (not (eq? user "root")))
> (error "rsync-service: to run rsync in a chroot, the user must be root"))
>
> The use-chroot? option might also benefit from making the user default
> to #f, as then the service could decide the user based on the port and
> use-chroot? settings, without contradicting the configuration.

I tried to apply all your suggestion, but I really don't know why
'rsync-configuration-user' is ignored (it's always set to "rsyncd").

I use 'pk' to debug this, but still confused.

Toggle snippet (2 lines)
;;; (rsync-config-file-config #<<rsync-configuration> package: #<package rsync@3.1.2 gnu/packages/rsync.scm:32 216af00> port-number: 581 pid-file: "/var/run/rsyncd/rsyncd.pid" lock-file: "/var/run/rsyncd/rsyncd.lock" log-file: "/var/log/rsyncd.log" use-chroot?: #f share-path: "/srv/rsyncd" share-comment: "Rsync share" read-only?: #f timeout: 300 user: "rsyncd" group: "rsyncd" uid: #f gid: #f>)
C
C
Christopher Baines wrote on 31 Aug 2017 01:59
(name . Oleg Pykhalov)(address . go.wigust@gmail.com)(address . 27855@debbugs.gnu.org)
20170831005936.79ac99e3@cbaines.net
On Fri, 25 Aug 2017 01:40:43 +0300
Oleg Pykhalov <go.wigust@gmail.com> wrote:
Toggle quote (5 lines)
> I tried to apply all your suggestion, but I really don't know why
> 'rsync-configuration-user' is ignored (it's always set to "rsyncd").
>
> I use 'pk' to debug this, but still confused.

For comparing strings in Guile, I think its more reliable to use equal?
rather than eq?, and I think this is the cause of the issues with the
validation. I don't get validation failures when using (equal? user
"root").
-----BEGIN PGP SIGNATURE-----

iQKTBAEBCgB9FiEEPonu50WOcg2XVOCyXiijOwuE9XcFAlmnUWhfFIAAAAAALgAo
aXNzdWVyLWZwckBub3RhdGlvbnMub3BlbnBncC5maWZ0aGhvcnNlbWFuLm5ldDNF
ODlFRUU3NDU4RTcyMEQ5NzU0RTBCMjVFMjhBMzNCMEI4NEY1NzcACgkQXiijOwuE
9XeeVBAApURqLbp5elQYZkfBSMd2GiXfONk2wa7ltt2nb0frfKHZhmprLLEVtdw6
O63K/IoT9EeneXxtJNa4olt44Fw8Gj4HuPeRInPzbjS1LbLygk1o2+cD61SP6qEi
ycnQ3S2wsSBS6DwzxoHk69BmNdreOK/+6Em9RvNlCdxySEJhWKqpCMlryyp+GOBF
Meyyt+pnbM7wqgD6gt0JhVM8Zj8ASusZuISOo6iaQJtjZGVk8yw1FO0j9+yHUmwB
TuSO/k4hCfpoaRZ2HUn7oOTu0JxPPkeCoOq17EufMTfb/T++Dhtr0SGA/1GRm+r3
u/I9dXz2C62H2j6rmsXYLs23UFmv3Jg6W0ncxRQpowCWgWwzgV2M08M435kA1LA/
FiPXXg1TufKoiZZahOIMuLRqj1Cxc+4PKDID2M64dhpH1r5QOxPx7qHcmYcZH7kE
0tQIhI9qhmGqiud75t2l5Psszlr7DYEkxJ5+fVWZK09gdv/OyzOM6Zg6FIJFixBv
2S8zXJBG9jvqN89o98eTsyt1ljVdZdz1Y9r7rPUsJs34T8wc7ptWM6hBnqWlzAaI
9SxS7OiGql/FZJ14U5f3CI2jPFkUWnfGmVxXtONb5yccnSGbEDFAm03p3PEO7GRP
hiP4i9aZ/aho8EXKSm9PkjpwHeVReCqP4i/voiKG9g1CaAWdr0o=
=6sHu
-----END PGP SIGNATURE-----


L
L
Ludovic Courtès wrote on 31 Aug 2017 15:04
(name . Christopher Baines)(address . mail@cbaines.net)
877exjsxaf.fsf@gnu.org
Christopher Baines <mail@cbaines.net> skribis:

Toggle quote (12 lines)
> On Fri, 25 Aug 2017 01:40:43 +0300
> Oleg Pykhalov <go.wigust@gmail.com> wrote:
>> I tried to apply all your suggestion, but I really don't know why
>> 'rsync-configuration-user' is ignored (it's always set to "rsyncd").
>>
>> I use 'pk' to debug this, but still confused.
>
> For comparing strings in Guile, I think its more reliable to use equal?
> rather than eq?, and I think this is the cause of the issues with the
> validation. I don't get validation failures when using (equal? user
> "root").

Right, ‘eq?’ checks for pointer equality, so you shouldn’t use it unless
you really know what you’re doing.

As a rule of thumb, I recommend using type-specific predicates as much
as possible. So if you’re comparing strings, use ‘string=?’; for
bytevectors, use ‘bytevector=?’; and so on.

This makes the intent clearer, and in a future with type inference and
the like, it will make it easier for the compiler to see whether we’re
doing the right thing.

Ludo’.
O
O
Oleg Pykhalov wrote on 17 Sep 2017 00:44
(name . Ludovic Courtès)(address . ludo@gnu.org)
87lgle9sbn.fsf@gmail.com
Hello Guix,

apologies for a such big pause.

I replaced switching user depending on port with error messages, because
I think it's much clear and easy to support in future.
Toggle snippet (17 lines)
(define (rsync-config-file config)
(if (not (string=? user "root"))
(cond
((<= port-number 1024)
(error (string-append "rsync-service: to run on port "
(number->string port-number)
", user must be root.")))
(use-chroot?
(error (string-append "rsync-service: to run in a chroot"
", user must be root.")))
(uid
(error "rsync-service: to use uid, user must be root."))
(gid
(error "rsync-service: to use gid, user must be root.")))))

I also add creating directory depending on uid/gid are specified:
Toggle snippet (14 lines)
(define (rsync-activation config)
"Return the activation GEXP for CONFIG."
#~(begin
(use-modules (guix build utils))
(let ((share-directory #$(rsync-configuration-share-path config))
(user (getpw (if #$(rsync-configuration-uid config)
#$(rsync-configuration-uid config)
#$(rsync-configuration-user config))))
(group (getpw (if #$(rsync-configuration-gid config)
#$(rsync-configuration-gid config)
#$(rsync-configuration-group config)))))
…)))

User and group set to "root", "uid" and gid set to "rsyncd" by default,
chroot is enabled.
Toggle snippet (14 lines)
(define-record-type* <rsync-configuration>
(use-chroot? rsync-configuration-use-chroot? ; boolean
(default #t))
(user rsync-configuration-user ; string
(default "root"))
(group rsync-configuration-group ; string
(default "root"))
(uid rsync-configuration-uid ; string
(default "rsyncd"))
(gid rsync-configuration-gid ; string
(default "rsyncd")))

2000 port test removed.

%test-rsync passed.
O
O
Oleg Pykhalov wrote on 17 Sep 2017 00:49
(name . Ludovic Courtès)(address . ludo@gnu.org)
87efr69s3t.fsf@gmail.com
And if it's good enough now, I'll fix documentation with new changes.
Forgot to do it and mention about it, sorry.
O
O
Oleg Pykhalov wrote on 17 Sep 2017 10:40
Re: Status: [PATCH] gnu: Add rsync service.
(name . bug#27855)(address . 27855@debbugs.gnu.org)
87a81tafaj.fsf@gmail.com
Hello Guix,

here are some improvements.

Remove all (pk) from service.

Set home directory according to rsync-user.
Toggle snippet (6 lines)
(define (rsync-account config)
(list …
(home-directory (string-append "/var/run/"
rsync-user)))))

Change name in test.
Toggle snippet (5 lines)
(define %test-rsync
(system-test
(name "rsync")
…))
C
C
Christopher Baines wrote on 18 Sep 2017 08:20
[bug#27855] [PATCH] gnu: Add rsync service.
(name . Oleg Pykhalov)(address . go.wigust@gmail.com)(address . 27855@debbugs.gnu.org)
20170918072004.10337804@cbaines.net
Toggle quote (20 lines)
> From 85ce8270afdfe4255ee5ebf0e185e99dcef8ad13 Mon Sep 17 00:00:00 2001
> From: Oleg Pykhalov <go.wigust <at> gmail.com>
> Date: Thu, 27 Jul 2017 04:01:01 +0300
> Subject: [PATCH] gnu: Add rsync service.
>
> * doc/guix.texi (Incremental file transfer): Add documentation.
> * gnu/services/rsync.scm (<rsync-configuration>): New record type.
> (rsync-accounts, rsync-shepherd-service): New service extensions.
> (rsync-service-type): New service type.
> * gnu/tests/rsync.scm: New file.
> * gnu/local.mk (GNU_SYSTEM_MODULES): Add it.
> ---
> doc/guix.texi | 74 ++++++++++++++++++++
> gnu/local.mk | 2 +
> gnu/services/rsync.scm | 181
> +++++++++++++++++++++++++++++++++++++++++++++++++
> gnu/tests/rsync.scm | 128 ++++++++++++++++++++++++++++++++++ 4
> files changed, 385 insertions(+) create mode 100644
> gnu/services/rsync.scm create mode 100644 gnu/tests/rsync.scm

Thanks for picking this up again Oleg, the changes you've made look
really good.

Toggle quote (10 lines)
> diff --git a/doc/guix.texi b/doc/guix.texi
> index 1356a357c..77c99e069 100644
> --- a/doc/guix.texi
> +++ b/doc/guix.texi
> @@ -16869,6 +16869,80 @@ Extra options will be passed to @code{git
> daemon}, please run @end table
> @end deftp
>
> +@subsubsection Incremental file transfer

Ideally this wouldn't be in Miscellaneous Services as I don't think
that is very helpful for users discovering what services Guix offers.
I think Networking Services might be better, what do you think? It
includes things like Tor, which are about using networks, and not
about core networking.

Toggle quote (13 lines)
> +
> +The @code{(gnu services rsync)} module provides the following
> services: +
> +@subsubheading Rsync service
> +
> +You might want an rsync daemon if you have files that you want
> available +so anyone (or just yourself) can download existing files
> or upload new +files.
> +
> +@deffn {Scheme Variable} rsync-service-type
> +This is the type for the @uref{https://rsync.samba.org} rsync daemon,
> +@command{rsync-configuration} record as in this example:

@uref{https://rsync.samba.org, rsync} looks nicer to me here.

Toggle quote (6 lines)
> +
> +@example
> +(service rsync-service-type
> + (rsync-configuration))
> +@end example

You may as well give the simpler (service rsync-service-type) version
here now that the service-type has a default value.

Toggle quote (16 lines)
> +
> +See below for details about @code{rsync-configuration}.
> +@end deffn
> +
> +@deftp {Data Type} rsync-configuration
> +Data type representing the configuration for @code{rsync-service}.
> +
> +@table @asis
> +@item @code{package} (default: @var{rsync})
> +@code{rsync} package to use.
> +
> +@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} will be started as
> the +@code{root} user and group.

I think this needs to read "needs to be" rather than "will be".

Toggle quote (39 lines)
> +
> +@item @code{pid-file} (default: @code{"/var/run/rsyncd/rsyncd.pid"})
> +Name of the file where @command{rsync} writes its PID.
> +
> +@item @code{lock-file} (default:
> @code{"/var/run/rsyncd/rsyncd.lock"}) +Name of the file where
> @command{rsync} writes its lock file. +
> +@item @code{log-file} (default: @code{"/var/log/rsyncd.log"})
> +Name of the file where @command{rsync} writes its log file.
> +
> +@item @code{use-chroot?} (default: @var{#t})
> +Whether to use chroot for @command{rsync} shared directory.
> +
> +@item @code{share-path} (default: @file{/srv/rsync})
> +Location of the @command{rsync} shared directory.
> +
> +@item @code{share-comment} (default: @code{"Rsync share"})
> +Comment of the @command{rsync} shared directory.
> +
> +@item @code{read-only?} (default: @var{#f})
> +Read-write permissions to shared directory.
> +
> +@item @code{timeout} (default: @code{300})
> +I/O timeout in seconds.
> +
> +@item @code{user} (default: @var{"root"})
> +Owner of the @code{rsync} process.
> +
> +@item @code{group} (default: @var{"root"})
> +Group of the @code{rsync} process.
> +
> +@item @code{uid} (default: @var{"rsyncd"})
> +User name or user ID that file transfers to and from that module
> should take +place as when the daemon was run as @code{root}.
> +
> +@item @code{gid} (default: @var{"rsyncd"})
> +Group name or group ID that will be used when accessing the
> module.

I'm not sure what "module" is here.

Toggle quote (131 lines)
> +@end table
> +@end deftp
> +
> @node Setuid Programs
> @subsection Setuid Programs
>
> diff --git a/gnu/local.mk b/gnu/local.mk
> index 418cc5e2a..fd252118d 100644
> --- a/gnu/local.mk
> +++ b/gnu/local.mk
> @@ -451,6 +451,7 @@ GNU_SYSTEM_MODULES
> = \
> %D%/services/shepherd.scm \
> %D%/services/herd.scm \
> %D%/services/pm.scm \
> + %D%/services/rsync.scm \
> %D%/services/sddm.scm \
> %D%/services/spice.scm \
> %D%/services/ssh.scm \
> @@ -497,6 +498,7 @@ GNU_SYSTEM_MODULES
> = \
> %D%/tests/mail.scm \
> %D%/tests/messaging.scm \
> %D%/tests/networking.scm \
> + %D%/tests/rsync.scm \
> %D%/tests/ssh.scm \
> %D%/tests/virtualization.scm \
> %D%/tests/web.scm
> diff --git a/gnu/services/rsync.scm b/gnu/services/rsync.scm
> new file mode 100644
> index 000000000..18c46ecfb
> --- /dev/null
> +++ b/gnu/services/rsync.scm
> @@ -0,0 +1,181 @@
> +;;; GNU Guix --- Functional package management for GNU
> +;;; Copyright © 2017 Oleg Pykhalov <go.wigust <at> gmail.com>
> +;;;
> +;;; This file is part of GNU Guix.
> +;;;
> +;;; GNU Guix is free software; you can redistribute it and/or modify
> it +;;; under the terms of the GNU General Public License as
> published by +;;; the Free Software Foundation; either version 3 of
> the License, or (at +;;; your option) any later version.
> +;;;
> +;;; GNU Guix is distributed in the hope that it will be useful, but
> +;;; WITHOUT ANY WARRANTY; without even the implied warranty of
> +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> +;;; GNU General Public License for more details.
> +;;;
> +;;; You should have received a copy of the GNU General Public License
> +;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
> +
> +(define-module (gnu services rsync)
> + #:use-module (gnu services)
> + #:use-module (gnu services base)
> + #:use-module (gnu services shepherd)
> + #:use-module (gnu system shadow)
> + #:use-module (gnu packages rsync)
> + #:use-module (gnu packages admin)
> + #:use-module (guix records)
> + #:use-module (guix gexp)
> + #:use-module (srfi srfi-1)
> + #:use-module (srfi srfi-26)
> + #:use-module (ice-9 match)
> + #:export (rsync-configuration
> + rsync-configuration?
> + rsync-service-type))
> +
> +;;;; Commentary:
> +;;;
> +;;; This module implements a service that to run instance of Rsync,
> +;;; files synchronization tool.
> +;;;
> +;;;; Code:
> +
> +(define-record-type* <rsync-configuration>
> + rsync-configuration
> + make-rsync-configuration
> + rsync-configuration?
> + (package rsync-configuration-package ; package
> + (default rsync))
> + (port-number rsync-configuration-port-number ; integer
> + (default 873))
> + (pid-file rsync-configuration-pid-file ; string
> + (default "/var/run/rsyncd/rsyncd.pid"))
> + (lock-file rsync-configuration-lock-file ; string
> + (default "/var/run/rsyncd/rsyncd.lock"))
> + (log-file rsync-configuration-log-file ; string
> + (default "/var/log/rsyncd.log"))
> + (use-chroot? rsync-configuration-use-chroot? ; boolean
> + (default #t))
> + (share-path rsync-configuration-share-path ; string
> + (default "/srv/rsyncd"))
> + (share-comment rsync-configuration-share-comment ; string
> + (default "Rsync share"))
> + (read-only? rsync-configuration-read-only? ; boolean
> + (default #f))
> + (timeout rsync-configuration-timeout ; integer
> + (default 300))
> + (user rsync-configuration-user ; string
> + (default "root"))
> + (group rsync-configuration-group ; string
> + (default "root"))
> + (uid rsync-configuration-uid ; string
> + (default "rsyncd"))
> + (gid rsync-configuration-gid ; string
> + (default "rsyncd")))
> +
> +(define (rsync-account config)
> + "Return the user accounts and user groups for CONFIG."
> + (let ((rsync-user (if (rsync-configuration-uid config)
> + (rsync-configuration-uid config)
> + (rsync-configuration-user config)))
> + (rsync-group (if (rsync-configuration-gid config)
> + (rsync-configuration-gid config)
> + (rsync-configuration-group config))))
> + (list (user-group (name rsync-group) (system? #t))
> + (user-account
> + (name rsync-user)
> + (system? #t)
> + (group rsync-group)
> + (comment "rsyncd privilege separation user")
> + (home-directory (string-append "/var/run/"
> + rsync-user))
> + (shell #~(string-append #$shadow "/sbin/nologin"))))))
> +
> +(define (rsync-activation config)
> + "Return the activation GEXP for CONFIG."
> + #~(begin
> + (use-modules (guix build utils))

Using with-imported-modules with this gexp here would be good, to
ensure it has the (guix build utils) module.

Toggle quote (31 lines)
> + (let ((share-directory #$(rsync-configuration-share-path
> config))
> + (user (getpw (if #$(rsync-configuration-uid config)
> + #$(rsync-configuration-uid config)
> + #$(rsync-configuration-user config))))
> + (group (getpw (if #$(rsync-configuration-gid config)
> + #$(rsync-configuration-gid config)
> + #$(rsync-configuration-group
> config)))))
> + (mkdir-p (dirname #$(rsync-configuration-pid-file config)))
> + (and=> share-directory mkdir-p)
> + (chown share-directory
> + (passwd:uid user)
> + (group:gid group)))))
> +
> +(define (rsync-config-file config)
> + "Return the rsync configuration file corresponding to CONFIG."
> + (let ((port-number (rsync-configuration-port-number config))
> + (pid-file (rsync-configuration-pid-file config))
> + (lock-file (rsync-configuration-lock-file config))
> + (log-file (rsync-configuration-log-file config))
> + (use-chroot? (rsync-configuration-use-chroot? config))
> + (share-path (rsync-configuration-share-path config))
> + (share-comment (rsync-configuration-share-comment config))
> + (read-only? (rsync-configuration-read-only? config))
> + (timeout (rsync-configuration-timeout config))
> + (user (rsync-configuration-user config))
> + (group (rsync-configuration-group config))
> + (uid (rsync-configuration-uid config))
> + (gid (rsync-configuration-gid config)))

Using match, or match-lambda might neaten this up a bit. There are a
few examples of using this in Guix.

Toggle quote (67 lines)
> + (if (not (string=? user "root"))
> + (cond
> + ((<= port-number 1024)
> + (error (string-append "rsync-service: to run on port "
> + (number->string port-number)
> + ", user must be root.")))
> + (use-chroot?
> + (error (string-append "rsync-service: to run in a chroot"
> + ", user must be root.")))
> + (uid
> + (error "rsync-service: to use uid, user must be root."))
> + (gid
> + (error "rsync-service: to use gid, user must be root."))))
> + (mixed-text-file
> + "rsync.conf"
> + "# Generated by 'rsync-service'.\n\n"
> + "pid file = " pid-file "\n"
> + "lock file = " lock-file "\n"
> + "log file = " log-file "\n"
> + "port = " (number->string port-number) "\n"
> + "use chroot = " (if use-chroot? "true" "false") "\n"
> + (if uid (string-append "uid = " uid "\n") "")
> + "gid = " (if gid gid "nogroup") "\n" ; no group nobody
> + "\n"
> + "[files]\n"
> + "path = " share-path "\n"
> + "comment = " share-comment "\n"
> + "read only = " (if read-only? "true" "false") "\n"
> + "timeout = " (number->string timeout) "\n")))
> +
> +(define (rsync-shepherd-service config)
> + "Return a <shepherd-service> for rsync with CONFIG."
> + (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)))
> + (list (shepherd-service
> + (provision '(rsync))
> + (documentation "Run rsync daemon.")
> + (start #~(make-forkexec-constructor
> + (list (string-append #$rsync "/bin/rsync")
> + "--config" #$(rsync-config-file config)
> + "--daemon")
> + #:pid-file #$pid-file
> + #:user #$user
> + #:group #$group))
> + (stop #~(make-kill-destructor))))))
> +
> +(define rsync-service-type
> + (service-type
> + (name 'rsync)
> + (extensions
> + (list (service-extension shepherd-root-service-type
> rsync-shepherd-service)
> + (service-extension account-service-type rsync-account)
> + (service-extension activation-service-type
> rsync-activation)))
> + (default-value (rsync-configuration))))
> diff --git a/gnu/tests/rsync.scm b/gnu/tests/rsync.scm
> new file mode 100644
> index 000000000..691b88e0d
> --- /dev/null
> +++ b/gnu/tests/rsync.scm
> @@ -0,0 +1,128 @@
> +;;; GNU Guix --- Functional package management for GNU

[...]

Toggle quote (9 lines)
> +
> +(define %test-rsync
> + (system-test
> + (name "rsync")
> + (description "Connect to a running RSYNC server.")
> + (value (run-rsync-test (%rsync-os)))))
> --
> 2.14.1

I'm pretty happy with this now. I think updating the documentation to
match the recent changes in the service would be good to do before
merging this but that is all. Good job :)
-----BEGIN PGP SIGNATURE-----

iQKTBAEBCgB9FiEEPonu50WOcg2XVOCyXiijOwuE9XcFAlm/ZZRfFIAAAAAALgAo
aXNzdWVyLWZwckBub3RhdGlvbnMub3BlbnBncC5maWZ0aGhvcnNlbWFuLm5ldDNF
ODlFRUU3NDU4RTcyMEQ5NzU0RTBCMjVFMjhBMzNCMEI4NEY1NzcACgkQXiijOwuE
9XdF2A/+JxkPj0VBmsS+jMAklfXtkXIFHF1TSDrxyDm72HJNnlyUyCU8CI5RkhBS
mtMzFTJuqb05N74BL6xuKuQwWUKhapkQGu+Pjv/m15T4pLexKwL3kd8Zm6nBAN0f
6pO/OObIYjH7Ft0p3iTYrFs9T9mg8VMp50FeIGb3BDgiviVCL6fWX9tkA4qg8Ffo
gegaoqGg8utLGbsme1ErNlkNQEJfzv8luHRZbJirG8Df8yAWsg/obEFOgIaeiqTI
pMHZ6kReVtuyrkgbF1/9tEiOQfXZbn+YkLtdCZT2rkh8E0Wb457zQowcKSaJNljq
a60TXBEbywcslqVUzlAfqqmeAhRX8eXfHwQidzi+jAu14HAq2UBZWmbV2LCK7Gsn
bbYHOBFYQSwUJ+W/+0CcuzCvMWWXTBlQ3MZxwv/vIhaanPSnPWA0HVYzFJh58vio
HeIDruCQLTOb9FccZORtT9JzT/2zMp2c8LKm/y1K5wpR/NHRAkeE/0k1jL/cO3FB
kAOIQXFeNVOqFZ78hu5PGru/OXfo2QRU6HyKPBkDTX2UN6jLx6VjxP6cavwBmyzE
kHDwA80g6WiSvAVKpB9PeZmtgd1NXxx2oiH4OWEws6nOUV9Un7yDyc/woop9njaT
2bid8TGMN2lCQL7NoOp6X/36cLubkXdFcc6GP397BjFf8MZ7g+w=
=RIER
-----END PGP SIGNATURE-----


O
O
Oleg Pykhalov wrote on 23 Sep 2017 03:47
(name . Christopher Baines)(address . mail@cbaines.net)(address . 27855@debbugs.gnu.org)
87r2uyb2zl.fsf@gmail.com
Christopher Baines <mail@cbaines.net> writes:

Toggle quote (6 lines)
> Ideally this wouldn't be in Miscellaneous Services as I don't think
> that is very helpful for users discovering what services Guix offers.
> I think Networking Services might be better, what do you think? It
> includes things like Tor, which are about using networks, and not
> about core networking.

Done.

Toggle quote (6 lines)
>> +@deffn {Scheme Variable} rsync-service-type
>> +This is the type for the @uref{https://rsync.samba.org} rsync daemon,
>> +@command{rsync-configuration} record as in this example:
>
> @uref{https://rsync.samba.org, rsync} looks nicer to me here.

Done.

Toggle quote (8 lines)
>> +@example
>> +(service rsync-service-type
>> + (rsync-configuration))
>> +@end example
>
> You may as well give the simpler (service rsync-service-type) version
> here now that the service-type has a default value.

Done.

Toggle quote (7 lines)
>> +@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} will be started as
>> the +@code{root} user and group.
>
> I think this needs to read "needs to be" rather than "will be".

Done.

Toggle quote (10 lines)
>> +@item @code{uid} (default: @var{"rsyncd"})
>> +User name or user ID that file transfers to and from that module
>> should take +place as when the daemon was run as @code{root}.
>> +
>> +@item @code{gid} (default: @var{"rsyncd"})
>> +Group name or group ID that will be used when accessing the
>> module.
>
> I'm not sure what "module" is here.

I took this description from *Man 5 rsyncd.conf* MODULE PARAMETERS.

After the global parameters you should define a number of modules,
each module exports a directory tree as a symbolic name. Modules are
exported by specifying a module name in square brackets [module]
followed by the param? eters for that module. The module name cannot
contain a slash or a closing square bracket. If the name contains
whitespace, each internal sequence of whitespace will be changed into
a single space, while leading or trailing whitespace will be
discarded. Also, the name cannot be "global" as that exact name
indicates that global parameters follow (see above).

Toggle quote (8 lines)
>> +(define (rsync-activation config)
>> + "Return the activation GEXP for CONFIG."
>> + #~(begin
>> + (use-modules (guix build utils))
>
> Using with-imported-modules with this gexp here would be good, to
> ensure it has the (guix build utils) module.

Done.

Toggle quote (19 lines)
>> +(define (rsync-config-file config)
>> + "Return the rsync configuration file corresponding to CONFIG."
>> + (let ((port-number (rsync-configuration-port-number config))
>> + (pid-file (rsync-configuration-pid-file config))
>> + (lock-file (rsync-configuration-lock-file config))
>> + (log-file (rsync-configuration-log-file config))
>> + (use-chroot? (rsync-configuration-use-chroot? config))
>> + (share-path (rsync-configuration-share-path config))
>> + (share-comment (rsync-configuration-share-comment config))
>> + (read-only? (rsync-configuration-read-only? config))
>> + (timeout (rsync-configuration-timeout config))
>> + (user (rsync-configuration-user config))
>> + (group (rsync-configuration-group config))
>> + (uid (rsync-configuration-uid config))
>> + (gid (rsync-configuration-gid config)))
>
> Using match, or match-lambda might neaten this up a bit. There are a
> few examples of using this in Guix.

Done.

Toggle quote (4 lines)
> I'm pretty happy with this now. I think updating the documentation to
> match the recent changes in the service would be good to do before
> merging this but that is all. Good job :)

Thank you for support! I learned much new things.

Attached a patch. Tested successfully.
O
O
Oleg Pykhalov wrote on 23 Sep 2017 04:38
(name . Christopher Baines)(address . mail@cbaines.net)(address . 27855@debbugs.gnu.org)
87d16ib0lj.fsf@gmail.com
Also want to add to previous message. Changed rsync port to 873 by
default in test according to /etc/services and rsync service default
port in Guix in this patch. And cleaned up little bit.

Toggle snippet (16 lines)
-(define* (run-rsync-test rsync-os #:optional (rsync-port 581))
+(define* (run-rsync-test rsync-os #:optional (rsync-port 873))

-(define* (%rsync-os #:optional (rsync-port 581))
- "Return operating system under test."
+(define* %rsync-os
+ ;; Return operating system under test.

- (service rsync-service-type
- (rsync-configuration
- (port-number rsync-port))))))
+ (service rsync-service-type))))

(description "Connect to a running RSYNC server.")
- (value (run-rsync-test (%rsync-os)))))
C
C
Christopher Baines wrote on 23 Sep 2017 22:12
(name . Oleg Pykhalov)(address . go.wigust@gmail.com)(address . 27855-done@debbugs.gnu.org)
20170923211225.6d3b1e69@cbaines.net
On Sat, 23 Sep 2017 04:47:10 +0300
Oleg Pykhalov <go.wigust@gmail.com> wrote:

Toggle quote (2 lines)
> Thank you for support! I learned much new things.

Great :) The latest changes look good, and I've now pushed the latest
patch you sent (the email after this one). I've tweaked the commit
message a bit, I hope you don't mind.
-----BEGIN PGP SIGNATURE-----

iQKTBAEBCgB9FiEEPonu50WOcg2XVOCyXiijOwuE9XcFAlnGwClfFIAAAAAALgAo
aXNzdWVyLWZwckBub3RhdGlvbnMub3BlbnBncC5maWZ0aGhvcnNlbWFuLm5ldDNF
ODlFRUU3NDU4RTcyMEQ5NzU0RTBCMjVFMjhBMzNCMEI4NEY1NzcACgkQXiijOwuE
9XfDeA//UB9+MZLxz3AnAIVWiiICAEUg7qfHDqH3kc5M69ODcImow+5UuEZCFl52
3bB/Bog2y86C3Cm+snczWCGWdyxvrhXRMZS34Wo78W5G+qCveUGCL7xcVForoJnc
kpMoPj6mD2V4DPgCEXlRjlbwYTskoS0nHPUoKQsX8+EG8NupO3U9HpF+NgJWFBXE
ViwxpM7MFe/aAK1y/uaKHrKXOx2RZdJcxcxc72CdhdMckwDDQzLKflqH9+zyeV6H
hjNsz4/TS8ltCuF8ruDfAgzVCgg7Za7VVh9zS6LlY3kQ2F8ewe+SThhuNKjXiMSf
tnna/tQuPIb5+D/tFb5XZZKX3ST6TAxwQ9D8pVE2D+/qxTgBEh2LDwS7JSWiBuva
YkSA3uvuSTXfj9jiMNSFfaEtdiYn44fPYQ5f/ZMp65LS5oOtNkYhPtPSKE+sFfdj
YC5OF5XKPIOw2g2ySd+cEu5acnZCl8MvXGY9Z00UWCEMvVtKcRygZ4/OIXdqzklm
KBK7oqyMB7BHGny9xb9mvjvCq8xQeje8/BLbR2o1QWMABC53jWqs6AQvjPPASWrk
0/CNhaJWxjXp/ERRFnhtdvj1ODCUAmiTxlMsBKLpmMNABbyJgfro+kpMHtdsu9ka
aHHBuKXgmFq+QI09JXZezRqpqVNFD7OQPjOytsc/ZqmYn6DMR3E=
=fTOV
-----END PGP SIGNATURE-----


Closed
?