[systemd-devel] user environment variables

Lennart Poettering lennart at poettering.net
Thu Nov 6 18:24:16 PST 2014


On Fri, 31.10.14 17:16, arnaud gaboury (arnaud.gaboury at gmail.com) wrote:

> For systemd be aware of certain environment variables, I usually use a
> drop-in config in /etc/systemd/system/user at service.d. This way, I can
> see the varibale when running
> $ systemctl --user show-environment
> 
> Now I am wondering why not using the /etc/systemd/user.conf for these
> variables. I tried this:
> 
> ......
> DefaultEnvironment=DISPLAY=:0
> RXVT_SOCKET=$XDG_RUNTIME_DIR/urxvt-hortensia TOTO=me
> ........
> 
> Unfortunately,
> -------------------------------------------------------------
> gabx at hortensia ➤➤ ~ % systemctl --user show-environment
> DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/dbus/user_bus_socket
> DISPLAY=:0
> TOTO=me
> HOME=/home/gabx
> LANG=en_US.UTF-8
> LC_COLLATE=C
> LOGNAME=gabx
> MAIL=/var/spool/mail/gabx
> PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin
> RXVT_SOCKET=$XDG_RUNTIME_DIR/urxvt-hortensia
> SHELL=/usr/bin/zsh
> USER=gabx
> XDG_RUNTIME_DIR=/run/user/1000
> ------------------------------------------------------------
> 
> the path is not recognized, even if XDG_RUNTIME_DIR is a known
> variable. Please note that DISPLAY and TOTO are recognized
> 
> I am wondering what I am doing wrong with RXVT_SOCKET ?

When systemd parses user.conf it does not resolve env vars in the shel
$foo syntax. In fact we don't do that for almost any field, except
ExecStart= and friends really.

We could probably at least open up DefaultEnvironment= to specifier
expansion, so that %t would work the same way as in unit files. I
added a TODO list item for this now.

Lennart

-- 
Lennart Poettering, Red Hat


More information about the systemd-devel mailing list