[bug#72342] services: syncthing: incorrect guessing of HOME variable

Message ID PAXP251MB034845EB100ABDE555E8B627F3B62@PAXP251MB0348.EURP251.PROD.OUTLOOK.COM
State New
Headers
Series [bug#72342] services: syncthing: incorrect guessing of HOME variable |

Commit Message

Sergio Pastor Pérez July 28, 2024, 5:09 p.m. UTC
  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.

Change-Id: I102bfe5feba1ebb349a0cde1c987c0c10ebbab7a
---
Hello.

Ludo asked[1] to send a patch to fix `home-syncthing-service-type` not guessing the correct value
for the `HOME` environment variable. Since the discussions seems stalled, here you
have the patch.

[1]https://lists.gnu.org/archive/html/help-guix/2024-01/msg00050.html

Have a great day!
Sergio.

 gnu/services/syncthing.scm | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)


base-commit: fdc6274de5b1d617fcabb3f3af9d2c0dd2a6520d
  

Comments

Ludovic Courtès Aug. 21, 2024, 5:04 p.m. UTC | #1
Sergio Pastor Pérez <sergio.pastorperez@outlook.es> skribis:

> 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.
>
> Change-Id: I102bfe5feba1ebb349a0cde1c987c0c10ebbab7a

I adjusted the commit log and applied it, thanks!

Ludo'.
  

Patch

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)