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

Lennart Poettering lennart at poettering.net
Tue Jul 10 06:59:03 PDT 2012


On Tue, 10.07.12 05:00, Kok, Auke-jan H (auke-jan.h.kok at intel.com) wrote:

> 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/...

We already have %t to refer to the runtime directory, which resolves to
/run for system services and $XDG_RUNTIME_DIRECTORY. We should probably
introduce %h or so which resolves to the home directory for user
instances, and to an error for system instance.

> 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.

I mentioned in that other mail that I think we should simply change the
default of WorkingDirectory= to getenv("HOME") if we are run as a user
session.

I'd prefer if systemd itself always uses / as current directory, in
order not to block any unmounts.

> So in short, I'd like to do both:
> 
> - have systemd chdir to $HOME if uid != 1

This bit of the plan i don't like. See above.

> 
> - 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.

Yupp, sounds like a good plan.

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

Yes, please, go ahead!

Lennart

-- 
Lennart Poettering - Red Hat, Inc.


More information about the systemd-devel mailing list