интерфейс D-Bus системы d-logind (The D-Bus interface of systemd-logind)
Объект менеджера (The manager object)
The service exposes the following interfaces on the Manager
object on the bus:
node /org/freedesktop/login1 {
interface org.freedesktop.login1.Manager {
methods:
GetSession(in s session_id,
out o object_path);
GetSessionByPID(in u pid,
out o object_path);
GetUser(in u uid,
out o object_path);
GetUserByPID(in u pid,
out o object_path);
GetSeat(in s seat_id,
out o object_path);
ListSessions(out a(susso) sessions);
ListUsers(out a(uso) users);
ListSeats(out a(so) seats);
ListInhibitors(out a(ssssuu) inhibitors);
CreateSession(in u uid,
in u pid,
in s service,
in s type,
in s class,
in s desktop,
in s seat_id,
in u vtnr,
in s tty,
in s display,
in b remote,
in s remote_user,
in s remote_host,
in a(sv) properties,
out s session_id,
out o object_path,
out s runtime_path,
out h fifo_fd,
out u uid,
out s seat_id,
out u vtnr,
out b existing);
ReleaseSession(in s session_id);
ActivateSession(in s session_id);
ActivateSessionOnSeat(in s session_id,
in s seat_id);
LockSession(in s session_id);
UnlockSession(in s session_id);
LockSessions();
UnlockSessions();
KillSession(in s session_id,
in s who,
in i signal_number);
KillUser(in u uid,
in i signal_number);
TerminateSession(in s session_id);
TerminateUser(in u uid);
TerminateSeat(in s seat_id);
SetUserLinger(in u uid,
in b enable,
in b interactive);
AttachDevice(in s seat_id,
in s sysfs_path,
in b interactive);
FlushDevices(in b interactive);
PowerOff(in b interactive);
PowerOffWithFlags(in t flags);
Reboot(in b interactive);
RebootWithFlags(in t flags);
Halt(in b interactive);
HaltWithFlags(in t flags);
Suspend(in b interactive);
SuspendWithFlags(in t flags);
Hibernate(in b interactive);
HibernateWithFlags(in t flags);
HybridSleep(in b interactive);
HybridSleepWithFlags(in t flags);
SuspendThenHibernate(in b interactive);
SuspendThenHibernateWithFlags(in t flags);
CanPowerOff(out s result);
CanReboot(out s result);
CanHalt(out s result);
CanSuspend(out s result);
CanHibernate(out s result);
CanHybridSleep(out s result);
CanSuspendThenHibernate(out s result);
ScheduleShutdown(in s type,
in t usec);
CancelScheduledShutdown(out b cancelled);
Inhibit(in s what,
in s who,
in s why,
in s mode,
out h pipe_fd);
CanRebootParameter(out s result);
SetRebootParameter(in s parameter);
CanRebootToFirmwareSetup(out s result);
SetRebootToFirmwareSetup(in b enable);
CanRebootToBootLoaderMenu(out s result);
SetRebootToBootLoaderMenu(in t timeout);
CanRebootToBootLoaderEntry(out s result);
SetRebootToBootLoaderEntry(in s boot_loader_entry);
SetWallMessage(in s wall_message,
in b enable);
signals:
SessionNew(s session_id,
o object_path);
SessionRemoved(s session_id,
o object_path);
UserNew(u uid,
o object_path);
UserRemoved(u uid,
o object_path);
SeatNew(s seat_id,
o object_path);
SeatRemoved(s seat_id,
o object_path);
PrepareForShutdown(b start);
PrepareForSleep(b start);
properties:
@org.freedesktop.DBus.Property.EmitsChangedSignal("false")
@org.freedesktop.systemd1.Privileged("true")
readwrite b EnableWallMessages = ...;
@org.freedesktop.DBus.Property.EmitsChangedSignal("false")
@org.freedesktop.systemd1.Privileged("true")
readwrite s WallMessage = '...';
@org.freedesktop.DBus.Property.EmitsChangedSignal("const")
readonly u NAutoVTs = ...;
@org.freedesktop.DBus.Property.EmitsChangedSignal("const")
readonly as KillOnlyUsers = ['...', ...];
@org.freedesktop.DBus.Property.EmitsChangedSignal("const")
readonly as KillExcludeUsers = ['...', ...];
@org.freedesktop.DBus.Property.EmitsChangedSignal("const")
readonly b KillUserProcesses = ...;
@org.freedesktop.DBus.Property.EmitsChangedSignal("false")
readonly s RebootParameter = '...';
@org.freedesktop.DBus.Property.EmitsChangedSignal("false")
readonly b RebootToFirmwareSetup = ...;
@org.freedesktop.DBus.Property.EmitsChangedSignal("false")
readonly t RebootToBootLoaderMenu = ...;
@org.freedesktop.DBus.Property.EmitsChangedSignal("false")
readonly s RebootToBootLoaderEntry = '...';
@org.freedesktop.DBus.Property.EmitsChangedSignal("const")
readonly as BootLoaderEntries = ['...', ...];
readonly b IdleHint = ...;
readonly t IdleSinceHint = ...;
readonly t IdleSinceHintMonotonic = ...;
readonly s BlockInhibited = '...';
readonly s DelayInhibited = '...';
@org.freedesktop.DBus.Property.EmitsChangedSignal("const")
readonly t InhibitDelayMaxUSec = ...;
@org.freedesktop.DBus.Property.EmitsChangedSignal("const")
readonly t UserStopDelayUSec = ...;
@org.freedesktop.DBus.Property.EmitsChangedSignal("const")
readonly s HandlePowerKey = '...';
@org.freedesktop.DBus.Property.EmitsChangedSignal("const")
readonly s HandleSuspendKey = '...';
@org.freedesktop.DBus.Property.EmitsChangedSignal("const")
readonly s HandleHibernateKey = '...';
@org.freedesktop.DBus.Property.EmitsChangedSignal("const")
readonly s HandleLidSwitch = '...';
@org.freedesktop.DBus.Property.EmitsChangedSignal("const")
readonly s HandleLidSwitchExternalPower = '...';
@org.freedesktop.DBus.Property.EmitsChangedSignal("const")
readonly s HandleLidSwitchDocked = '...';
@org.freedesktop.DBus.Property.EmitsChangedSignal("const")
readonly t HoldoffTimeoutUSec = ...;
@org.freedesktop.DBus.Property.EmitsChangedSignal("const")
readonly s IdleAction = '...';
@org.freedesktop.DBus.Property.EmitsChangedSignal("const")
readonly t IdleActionUSec = ...;
@org.freedesktop.DBus.Property.EmitsChangedSignal("false")
readonly b PreparingForShutdown = ...;
@org.freedesktop.DBus.Property.EmitsChangedSignal("false")
readonly b PreparingForSleep = ...;
@org.freedesktop.DBus.Property.EmitsChangedSignal("false")
readonly (st) ScheduledShutdown = ...;
@org.freedesktop.DBus.Property.EmitsChangedSignal("false")
readonly b Docked = ...;
@org.freedesktop.DBus.Property.EmitsChangedSignal("false")
readonly b LidClosed = ...;
@org.freedesktop.DBus.Property.EmitsChangedSignal("false")
readonly b OnExternalPower = ...;
@org.freedesktop.DBus.Property.EmitsChangedSignal("const")
readonly b RemoveIPC = ...;
@org.freedesktop.DBus.Property.EmitsChangedSignal("const")
readonly t RuntimeDirectorySize = ...;
@org.freedesktop.DBus.Property.EmitsChangedSignal("const")
readonly t RuntimeDirectoryInodesMax = ...;
@org.freedesktop.DBus.Property.EmitsChangedSignal("const")
readonly t InhibitorsMax = ...;
@org.freedesktop.DBus.Property.EmitsChangedSignal("false")
readonly t NCurrentInhibitors = ...;
@org.freedesktop.DBus.Property.EmitsChangedSignal("const")
readonly t SessionsMax = ...;
@org.freedesktop.DBus.Property.EmitsChangedSignal("false")
readonly t NCurrentSessions = ...;
};
interface org.freedesktop.DBus.Peer { ... };
interface org.freedesktop.DBus.Introspectable { ... };
interface org.freedesktop.DBus.Properties { ... };
};
Methods
GetSession() may be used to get the session object path for the
session with the specified ID. Similarly, GetUser() and GetSeat()
get the user and seat objects, respectively. GetSessionByPID()
and GetUserByPID() get the session/user object the specified PID
belongs to if there is any.
ListSessions() returns an array of all current sessions. The
structures in the array consist of the following fields: session
id, user id, user name, seat id, session object path. If a
session does not have a seat attached, the seat id field will be
an empty string.
ListUsers() returns an array of all currently logged in users.
The structures in the array consist of the following fields: user
id, user name, user object path.
ListSeats() returns an array of all currently available seats.
The structure in the array consists of the following fields: seat
id, seat object path.
ListInhibitors() lists all currently active inhibitors. It
returns an array of structures consisting of what, who, why,
mode, uid (user ID), and pid (process ID).
CreateSession() and ReleaseSession() may be used to open or close
login sessions. These calls should never be invoked directly by
clients. Creating/closing sessions is exclusively the job of PAM
and its pam_systemd(8) module.
ActivateSession() brings the session with the specified ID into
the foreground. ActivateSessionOnSeat() does the same, but only
if the seat id matches.
LockSession() asks the session with the specified ID to activate
the screen lock. UnlockSession() asks the session with the
specified ID to remove an active screen lock, if there is any.
This is implemented by sending out the Lock() and Unlock()
signals from the respective session object which session managers
are supposed to listen on.
LockSessions() asks all sessions to activate their screen locks.
This may be used to lock access to the entire machine in one
action. Similarly, UnlockSessions() asks all sessions to
deactivate their screen locks.
KillSession() may be used to send a Unix signal to one or all
processes of a session. As arguments it takes the session id,
either the string "leader" or "all" and a signal number. If
"leader" is passed only the session "leader" is killed. If "all"
is passed all processes of the session are killed.
KillUser() may be used to send a Unix signal to all processes of
a user. As arguments it takes the user id and a signal number.
TerminateSession(), TerminateUser(), TerminateSeat() may be used
to forcibly terminate one specific session, all processes of a
user, and all sessions attached to a specific seat, respectively.
The session, user, and seat are identified by their respective
IDs.
SetUserLinger() enables or disables user lingering. If enabled,
the runtime directory of a user is kept around and they may
continue to run processes while logged out. If disabled, the
runtime directory goes away as soon as they log out.
SetUserLinger() expects three arguments: the UID, a boolean
whether to enable/disable and a boolean controlling the polkit[1]
authorization interactivity (see below). Note that the user
linger state is persistently stored on disk.
AttachDevice() may be used to assign a specific device to a
specific seat. The device is identified by its /sys/ path and
must be eligible for seat assignments. AttachDevice() takes
three arguments: the seat id, the sysfs path, and a boolean for
controlling polkit interactivity (see below). Device assignments
are persistently stored on disk. To create a new seat, simply
specify a previously unused seat id. For more information about
the seat assignment logic see sd-login(3).
FlushDevices() removes all explicit seat assignments for devices,
resetting all assignments to the automatic defaults. The only
argument it takes is the polkit interactivity boolean (see
below).
PowerOff(), Reboot(), Halt(), Suspend(), and Hibernate() result
in the system being powered off, rebooted, halted (shut down
without turning off power), suspended (the system state is saved
to RAM and the CPU is turned off), or hibernated (the system
state is saved to disk and the machine is powered down).
HybridSleep() results in the system entering a hybrid-sleep mode,
i.e. the system is both hibernated and suspended.
SuspendThenHibernate() results in the system being suspended,
then later woken using an RTC timer and hibernated. The only
argument is the polkit interactivity boolean interactive (see
below). The main purpose of these calls is that they enforce
polkit policy and hence allow powering
off/rebooting/suspending/hibernating even by unprivileged users.
They also enforce inhibition locks for non-privileged users. UIs
should expose these calls as the primary mechanism to
poweroff/reboot/suspend/hibernate the machine. Methods
PowerOffWithFlags(), RebootWithFlags(), HaltWithFlags(),
SuspendWithFlags(), HibernateWithFlags(), HybridSleepWithFlags()
and SuspendThenHibernateWithFlags() add flags to allow for
extendability, defined as follows:
#define SD_LOGIND_ROOT_CHECK_INHIBITORS (UINT64_C(1) << 0)
#define SD_LOGIND_KEXEC_REBOOT (UINT64_C(1) << 1)
When the flags is 0 then these methods behave just like the
versions without flags. When SD_LOGIND_ROOT_CHECK_INHIBITORS
(0x01) is set, active inhibitors are honoured for privileged
users too. When SD_LOGIND_KEXEC_REBOOT (0x02) is set, then
RebootWithFlags() perform kexec reboot if kexec kernel is loaded.
SetRebootParameter() sets a parameter for a subsequent reboot
operation. See the description of reboot in systemctl(1) and
reboot(2) for more information.
SetRebootToFirmwareSetup(), SetRebootToBootLoaderMenu(), and
SetRebootToBootLoaderEntry() configure the action to be taken
from the boot loader after a reboot: respectively entering
firmware setup mode, the boot loader menu, or a specific boot
loader entry. See systemctl(1) for the corresponding command line
interface.
CanPowerOff(), CanReboot(), CanHalt(), CanSuspend(),
CanHibernate(), CanHybridSleep(), CanSuspendThenHibernate(),
CanRebootParameter(), CanRebootToFirmwareSetup(),
CanRebootToBootLoaderMenu(), and CanRebootToBootLoaderEntry()
test whether the system supports the respective operation and
whether the calling user is allowed to execute it. Returns one of
"na", "yes", "no", and "challenge". If "na" is returned, the
operation is not available because hardware, kernel, or drivers
do not support it. If "yes" is returned, the operation is
supported and the user may execute the operation without further
authentication. If "no" is returned, the operation is available
but the user is not allowed to execute the operation. If
"challenge" is returned, the operation is available but only
after authorization.
ScheduleShutdown() schedules a shutdown operation type at time
usec in microseconds since the UNIX epoch. type can be one of
"poweroff", "dry-poweroff", "reboot", "dry-reboot", "halt", and
"dry-halt". (The "dry-" variants do not actually execute the
shutdown action.) CancelScheduledShutdown() cancels a scheduled
shutdown. The output parameter cancelled is true if a shutdown
operation was scheduled.
SetWallMessage() sets the wall message (the message that will be
sent out to all terminals and stored in a utmp(5) record) for a
subsequent scheduled shutdown operation. The parameter
wall_message specifies the shutdown reason (and may be empty)
which will be included in the shutdown message. The parameter
enable specifies whether to print a wall message on shutdown.
Inhibit() creates an inhibition lock. It takes four parameters:
what, who, why, and mode. what is one or more of "shutdown",
"sleep", "idle", "handle-power-key", "handle-suspend-key",
"handle-hibernate-key", "handle-lid-switch", separated by colons,
for inhibiting poweroff/reboot, suspend/hibernate, the automatic
idle logic, or hardware key handling. who should be a short
human readable string identifying the application taking the
lock. why should be a short human readable string identifying
the reason why the lock is taken. Finally, mode is either "block"
or "delay" which encodes whether the inhibit shall be consider
mandatory or whether it should just delay the operation to a
certain maximum time. The method returns a file descriptor. The
lock is released the moment this file descriptor and all its
duplicates are closed. For more information on the inhibition
logic see Inhibitor Locks[2].
Signals
Whenever the inhibition state or idle hint changes,
PropertyChanged signals are sent out to which clients can
subscribe.
The SessionNew, SessionRemoved, UserNew, UserRemoved, SeatNew,
and SeatRemoved signals are sent each time a session is created
or removed, a user logs in or out, or a seat is added or removed.
They each contain the ID of the object plus the object path.
The PrepareForShutdown() and PrepareForSleep() signals are sent
right before (with the argument "true") or after (with the
argument "false") the system goes down for reboot/poweroff and
suspend/hibernate, respectively. This may be used by applications
to save data on disk, release memory, or do other jobs that
should be done shortly before shutdown/sleep, in conjunction with
delay inhibitor locks. After completion of this work they should
release their inhibition locks in order to not delay the
operation any further. For more information see Inhibitor
Locks[2].
Properties
Most properties simply reflect the configuration, see
logind.conf(5). This includes: NAutoVTs, KillOnlyUsers,
KillExcludeUsers, KillUserProcesses, IdleAction,
InhibitDelayMaxUSec, InhibitorsMax, UserStopDelayUSec,
HandlePowerKey, HandleSuspendKey, HandleHibernateKey,
HandleLidSwitch, HandleLidSwitchExternalPower,
HandleLidSwitchDocked, IdleActionUSec, HoldoffTimeoutUSec,
RemoveIPC, RuntimeDirectorySize, RuntimeDirectoryInodesMax,
InhibitorsMax, and SessionsMax.
The IdleHint property reflects the idle hint state of the system.
If the system is idle it might get into automatic suspend or
shutdown depending on the configuration.
IdleSinceHint and IdleSinceHintMonotonic encode the timestamps of
the last change of the idle hint boolean, in CLOCK_REALTIME and
CLOCK_MONOTONIC timestamps, respectively, in microseconds since
the epoch.
The BlockInhibited and DelayInhibited properties encode the
currently active locks of the respective modes. They are colon
separated lists of "shutdown", "sleep", and "idle" (see above).
NCurrentSessions and NCurrentInhibitors contain the number of
currently registered sessions and inhibitors.
The BootLoaderEntries property contains a list of boot loader
entries. This includes boot loader entries defined in
configuration and any additional loader entries reported by the
boot loader. See systemd-boot(7) for more information.
The PreparingForShutdown and PreparingForSleep boolean properties
are true during the interval between the two PrepareForShutdown
and PrepareForSleep signals respectively. Note that these
properties do not send out PropertyChanged signals.
The RebootParameter property shows the value set with the
SetRebootParameter() method described above.
ScheduledShutdown shows the value pair set with the
ScheduleShutdown() method described above.
RebootToFirmwareSetup, RebootToBootLoaderMenu, and
RebootToBootLoaderEntry are true when the resprective post-reboot
operation was selected with SetRebootToFirmwareSetup,
SetRebootToBootLoaderMenu, or SetRebootToBootLoaderEntry.
The WallMessage and EnableWallMessages properties reflect the
shutdown reason and wall message enablement switch which can be
set with the SetWallMessage() method described above.
Docked is true if the machine is connected to a dock. LidClosed
is true when the lid (of a laptop) is closed. OnExternalPower is
true when the machine is connected to an external power supply.
Security
A number of operations are protected via the polkit privilege
system. SetUserLinger() requires the
org.freedesktop.login1.set-user-linger privilege. AttachDevice()
requires org.freedesktop.login1.attach-device and FlushDevices()
requires org.freedesktop.login1.flush-devices. PowerOff(),
Reboot(), Halt(), Suspend(), Hibernate() require
org.freedesktop.login1.power-off,
org.freedesktop.login1.power-off-multiple-sessions,
org.freedesktop.login1.power-off-ignore-inhibit,
org.freedesktop.login1.reboot,
org.freedesktop.login1.reboot-multiple-sessions,
org.freedesktop.login1.reboot-ignore-inhibit,
org.freedesktop.login1.halt,
org.freedesktop.login1.halt-multiple-sessions,
org.freedesktop.login1.halt-ignore-inhibit,
org.freedesktop.login1.suspend,
org.freedesktop.login1.suspend-multiple-sessions,
org.freedesktop.login1.suspend-ignore-inhibit,
org.freedesktop.login1.hibernate,
org.freedesktop.login1.hibernate-multiple-sessions,
org.freedesktop.login1.hibernate-ignore-inhibit, respectively
depending on whether there are other sessions around or active
inhibits are present. HybridSleep() and SuspendThenHibernate()
use the same privileges as Hibernate(). SetRebootParameter()
requires org.freedesktop.login1.set-reboot-parameter.
SetRebootToFirmwareSetup requires
org.freedesktop.login1.set-reboot-to-firmware-setup.
SetRebootToBootLoaderMenu requires
org.freedesktop.login1.set-reboot-to-boot-loader-menu.
SetRebootToBootLoaderEntry requires
org.freedesktop.login1.set-reboot-to-boot-loader-entry.
ScheduleShutdown and CancelScheduledShutdown require the same
privileges (listed above) as the immediate poweroff/reboot/halt
operations.
Inhibit() is protected via one of
org.freedesktop.login1.inhibit-block-shutdown,
org.freedesktop.login1.inhibit-delay-shutdown,
org.freedesktop.login1.inhibit-block-sleep,
org.freedesktop.login1.inhibit-delay-sleep,
org.freedesktop.login1.inhibit-block-idle,
org.freedesktop.login1.inhibit-handle-power-key,
org.freedesktop.login1.inhibit-handle-suspend-key,
org.freedesktop.login1.inhibit-handle-hibernate-key,
org.freedesktop.login1.inhibit-handle-lid-switch depending on the
lock type and mode taken.
The interactive boolean parameters can be used to control whether
polkit should interactively ask the user for authentication
credentials if required.