GNU bug report logs - #77220
[shepherd]: Timers do not set HOME environment variable correctly

Previous Next

Package: guix;

Reported by: Tomas Volf <~@wolfsden.cz>

Date: Sun, 23 Mar 2025 21:31:01 UTC

Severity: normal

Done: Tomas Volf <~@wolfsden.cz>

Bug is archived. No further changes may be made.

Full log


Message #25 received at 77220 <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: Tomas Volf <~@wolfsden.cz>
Cc: 77220 <at> debbugs.gnu.org
Subject: Re: bug#77220: [shepherd]: Timers do not set HOME environment
 variable correctly
Date: Tue, 08 Apr 2025 11:54:48 +0200
Hi,

Tomas Volf <~@wolfsden.cz> skribis:

> Would something like the attached work?  I placed the procedure directly
> into the (shepherd service) module, since the point is to reduce
> boilerplate, I thought it better to not having to specify (modules
> '((shepherd support))) every time someone wants to use it, but I can
> move it if you prefer.

Yeah, it’s fine this way.

> +@deffn {Procedure} user-environment-variables @
> +  [name-or-id (getuid)] @
> +  [environment-variables (default-environment-variables)]
> +
> +Take the list of environment variables, replace @env{HOME} with home

“Take the list @var{environment-variables}, …”

> +(define-module (test-service)
> +  #:use-module (shepherd service)
> +  #:use-module (srfi srfi-64))
> +
> +
> +(test-begin "user-environment-variables")

(test-begin "service"), to create ‘service.log’.

> +(let ((environment-variables '("USER=foo"
> +                               "HOME=/foo"
> +                               "USER=bar"
> +                               "HOME=/bar")))
> +  ;; Pretty much any system should have root in /etc/passwd.
> +  (test-equal "name sets variables"
> +    '("HOME=/root" "USER=root")
> +    (user-environment-variables "root" environment-variables))

Use (passwd:name (getpwuid (getuid))) rather than “root” because
/etc/passwd in the Guix build environment does not have “root”.  (You
can test with ‘guix build -f guix.scm’.)

OK with these changes, thank you!

Ludo’.




This bug report was last modified 92 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.