Subject: [bug#75959] [PATCH v9] services: syncthing: Add support for config file generation.

From: Leo Famulari <[email-masked]>
Date: Sun, 16 Feb 2025 02:13:41 -0500

On Sat, Feb 15, 2025 at 08:06:42PM -0500, Zacchaeus Scheffer wrote:
> Subject: [PATCH v9] services: syncthing: Add support for config file
>  generation.

Thanks!

> +      (start #~(lambda _
> +                 ;; If we are managing the config, and it's not a home
> +                 ;; service, then exepect the config file at
> +                 ;; /var/lib/syncthing-<user>.  This makes sure the ownership
> +                 ;; is correct
> +                 (unless (or #$(not config-file) #$home-service?)
> +                   (chown (string-append "/var/lib/syncthing-" #$user)
> +                          (passwd:uid #$user)
> +                          (passwd:gid #$user))
> +                   (chmod (string-append "/var/lib/syncthing-" #$user) #o700))

This is making the service crash, not sure why:

------
# herd start syncthing-leo
Service user-homes has been started.
herd: error: exception caught while executing 'start' on service 'syncthing-leo':
In procedure vector-ref: Wrong argument in position 1 (expecting vector): "leo"
------

Of course my user's name is leo in the test VM.

I added some print-style tracing (attached diff) and it crashes in
chown.
diff --git a/gnu/services/syncthing.scm b/gnu/services/syncthing.scm
index cc88bf7925..9fbcf2c4de 100644
--- a/gnu/services/syncthing.scm
+++ b/gnu/services/syncthing.scm
@@ -492,10 +492,14 @@ (define syncthing-shepherd-service
                  ;; /var/lib/syncthing-<user>.  This makes sure the ownership
                  ;; is correct
                  (unless (or #$(not config-file) #$home-service?)
+                   (display "1 before chown") (newline)
                    (chown (string-append "/var/lib/syncthing-" #$user)
                           (passwd:uid #$user)
                           (passwd:gid #$user))
-                   (chmod (string-append "/var/lib/syncthing-" #$user) #o700))
+                   (display "2 before chmod") (newline)
+                   (chmod (string-append "/var/lib/syncthing-" #$user) #o700)
+                   (display "3 after chmod") (newline)
+)
                  (make-forkexec-constructor
                   (append (list (string-append #$syncthing "/bin/syncthing")
                                 ;; Do not try to try to lauch a browser on startup.