]> git.ipfire.org Git - thirdparty/systemd.git/commit
logind: make "self" and "auto" magic strings when operating on seats + sessions
authorLennart Poettering <lennart@poettering.net>
Sun, 28 Apr 2019 15:55:36 +0000 (17:55 +0200)
committerLennart Poettering <lennart@poettering.net>
Fri, 24 May 2019 13:05:27 +0000 (15:05 +0200)
commit3b92c086a8d5338e2164ffa0ae48b3d03d10cfb5
treea8aaf4ad9f5778566018a63fd95cf37b69aa06e7
parent469df514c7e10fbfdc3abb243e0458fd44084fc2
logind: make "self" and "auto" magic strings when operating on seats + sessions

Most of the operations one can do on sessions so far accepted an empty
session name as a shortcut for the caller's session. This is quite
useful traditionally, but much less useful than it used to be, since
most user code now (rightfully) runs in --user context, not in a
session.

With this change we tweak the logic a bit: we introduce the two special
session and seat names "self" and "auto". The former refers to the
session/seat the client is in, and is hence mostly equivalent to te
empty string "" as before. However, the latter refers to the
session/seat the client is in if that exists, with a fallback of the
user's display session if not. Clients can hence reference "auto"
instead of the empty string if they really don't want to think much
about sessions.

Why "self" btw? Previously, we'd already expose a special dbus object
with the path /org/freedesktop/login1/session/self (and similar for the
seat), matching what the empty string did for bus calls that took a
session name. With this scheme we reuse this identifier and introduce
"auto" in a similar way.

Of course this means real-life seats and sessions can never be named
"self" or "auto", but they aren't anyway: valid seat names have to start
with "seat" anyway, and sessions are generated server-side as either a
numeric value or "c" suffixed with a counter ID.

Fixes: #12399
src/login/logind-dbus.c
src/login/logind-seat-dbus.c
src/login/logind-seat.h
src/login/logind-session-dbus.c
src/login/logind-session.h