Skip to content

Authorization in XfceConsolekit and XfceSystemd

systemd-logind can return challenge for CanSuspend() et al. if systemd is compiled with polkit support, which is generally the case.

https://www.freedesktop.org/software/systemd/man/org.freedesktop.login1.html

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.

XfceSystemd only checks for yes:

https://gitlab.xfce.org/xfce/libxfce4util/-/blob/libxfce4util-4.19.1/libxfce4util/xfce-systemd.c#L151-191

XfceConsolekit on the other hand has challenge check for CanSuspend(), CanHibernate() and CanHybridSleep():

https://gitlab.xfce.org/xfce/libxfce4util/-/blob/libxfce4util-4.19.1/libxfce4util/xfce-consolekit.c#L183-231

Could this be generalized in xfce_consolekit_can_method() for all methods?