[systemd-devel] [PATCH 2/3] core: Put transient user units in XDG_RUNTIME_DIR instead of XDG_CONFIG_HOME.

Kay Sievers kay at vrfy.org
Fri Mar 28 11:52:43 PDT 2014


On Fri, Mar 28, 2014 at 7:43 PM, Hristo Venev <hristo at venev.name> wrote:
> On Fri, 2014-03-28 at 19:02 +0100, Kay Sievers wrote:
>> On Fri, Mar 28, 2014 at 6:38 PM, Hristo Venev <hristo at venev.name> wrote:
>> > They are temporary and should not clutter the configuration directory.
>> > ---
>> >  src/core/unit.c | 32 +++++++++++++++-----------------
>> >  1 file changed, 15 insertions(+), 17 deletions(-)
>> >
>> > diff --git a/src/core/unit.c b/src/core/unit.c
>>
>> > +                        c = strappend(getenv("XDG_RUNTIME_DIR"), "/systemd/user");
>>
>> Nesting function calls without error checking should be avoided for
>> systemd code.
>>
>> Kay
>
> This is executed only if the manager is running as user. In case
> XDG_RUNTIME_DIR isn't set, systemd would fail to start.

It should still go into its own variable if you want to skip the
check. We should not rely on the behaviour of external functions like
that.

Even when it is not likely to ever fail, or never even to be called as
PID1, it's still the coding pattern that matters, and PID1 code has
stricter rules than usual user code.

Kay


More information about the systemd-devel mailing list