[systemd-devel] Proposal: extend support for user session unit features

Kok, Auke-jan H auke-jan.h.kok at intel.com
Mon Jul 9 22:00:43 PDT 2012


Lennart, Kay, all,

I've run into several issues with the basic support that is present in
systemd, and I think we need to extend some of the basic bits in
systemd to support additional specifiers, as well as changing cwd to
$HOME for a user session.

The rationale is simple. Take for instance a conditional service such
as xrdb and xmodmap. We can create global units for all users that are
part of an xorg.target and load global basic defaults from e.g.
/etc/X11/Xresources and /etc/X11/xmodmaprc. Since those paths are
absolute, no problem there.

But now consider a situation where we would support users optionally
creating a ~/.Xresources and ~/.xmodmaprc. There currently is no way
to make a global user session unit file for all users, since there is
no way to refer to $HOME from unit files. It's even worse if you want
to make simple constructs as ConditionFileExists=$HOME/...

I had thought about putting in a `chdir(getenv("HOME"))`, which sounds
sane to begin with, and possibly solves the problem since ".xmodmaprc"
is now a valid file path that could be used, but it's not the right
solution.

So in short, I'd like to do both:

- have systemd chdir to $HOME if uid != 1

- extend the printf specifier list for user sessions with a specifer
that can be used in various fields to refer to at minimum $HOME ("%h"
?) and possibly $UID ("%u") and $SHELL ("%s"), since these fields are
part of the struct *passwd, and might be useful at some point.

Comments? I'll post a patch gladly to implement this.

Auke


More information about the systemd-devel mailing list