From a1d367d6ee8c1783ef94cebbc5f2ae3b7a08078d Mon Sep 17 00:00:00 2001
From: Sergio Pastor Pérez <sergio.pastorperez@outlook.es>
Date: Sun, 28 Jul 2024 19:09:41 +0200
Subject: services: syncthing: incorrect guessing of HOME variable
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Fixed the issue described here:
https://lists.gnu.org/archive/html/help-guix/2024-01/msg00034.html

Fix `syncthing-shepherd-service` failing to guess the correct `HOME`
environment variable when it's `<syncthing-configuration>` does not have a
value for the `home` or `user` fields.

* gnu/services/syncthing.scm (syncthing-shepherd-service): Change ‘HOME’
value in #:environment-variables argument.

Change-Id: I102bfe5feba1ebb349a0cde1c987c0c10ebbab7a
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
---
 gnu/services/syncthing.scm | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

(limited to 'gnu/services')

diff --git a/gnu/services/syncthing.scm b/gnu/services/syncthing.scm
index 9bb623186b..a7a9c6aadd 100644
--- a/gnu/services/syncthing.scm
+++ b/gnu/services/syncthing.scm
@@ -73,7 +73,15 @@ (define syncthing-shepherd-service
                 #:user #$(and (not home-service?) user)
                 #:group #$(and (not home-service?) group)
                 #:environment-variables
-                (append (list (string-append "HOME=" (or #$home (passwd:dir (getpw #$user))))
+                (append
+                 (list
+                  (string-append "HOME="
+                                 (or #$home
+                                     (passwd:dir
+                                      (getpw (if (and #$home-service?
+                                                      (not #$user))
+                                                 (getuid)
+                                                 #$user)))))
                               "SSL_CERT_DIR=/etc/ssl/certs"
                               "SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crt")
                         (filter (negate       ;XXX: 'remove' is not in (guile)
-- 
cgit v1.2.3