79.2. elogind-255.24
Standalone logind: seats, sessions, login1 on the system bus, pam_elogind and libelogind
| Version | 255.24, release 1 |
| Shelf | auth — Authentication, authorisation, accounts and directory services |
| Phase | 41_system (System), 48 of 1047 in build order |
| Licence | GPL-2.0-or-later AND LGPL-2.1-or-later |
| Homepage | https://github.com/elogind/elogind |
| Build time | 1.1 SBU |
| Installed size | 5.2 MiB in 601 files |
| Recipe | ports/core/auth/elogind/kpkgbuild |
About
elogind is systemd’s logind taken out of systemd and run as a daemon of its own. It owns org.freedesktop.login1 on the system bus: it records every login as a session on a seat, tells which session is the active one, hands the session’s compositor its display and input devices (TakeControl), announces a suspend or a power-off and lets programs delay or block one with an inhibitor. Besides the daemon this port installs pam_elogind.so, the PAM module through which a login registers its session, the client library libelogind and loginctl.
On KDOS it is the one logind. SDDM records each session through it and switches users through it; KWin opens the display and the input devices through the session it records, and has no other session backend that works here; PowerDevil suspends the machine and owns the lid through it; and the lock screen locks when it announces a sleep. polkit asks it whether a caller sits in the active local session, which is what the allow_active column of an action’s policy means. Why KDOS carries this one piece of systemd’s source tree, and what it costs, is in No systemd init, units or service manager.
The daemon is /usr/lib/elogind/elogind, started at boot by /etc/init.d/40_elogind.sh under ksvc, after D-Bus and before polkit and NetworkManager.
Sources
elogind-255.24.tar.gz(2.0 MiB)
sha2567737e13f409bdf6041bd1a1f5580ab197790f6641e26faf93e09c19c68f5dab8
upstream: https://github.com/elogind/elogind/archive/v255.24/elogind-v255.24.tar.gz
archive copy: sources-1/auth--elogind-255.24.tar.gz
Dependencies
Depends on: meson, ninja, pkgconf, coreutils, gperf, python3-jinja2, python3-lxml, libxslt, docbook-xsl, docbook-xml, libcap, acl, eudev, util-linux, dbus, pam.
Required by (12): accountsservice, fwupd, gnome-disk-utility, gvfs, kscreenlocker, networkmanager, pipewire, polkit, powerdevil, sddm, tlp, wireplumber.
Optional, off in KDOS
These switches in build.sh turn off a feature whose library is a port here. The recipe may turn each off on purpose, or because the library was not yet a port when the recipe was written; this list cannot tell which.
-Ddbus=disabled, line 38: dbus (explained with the switches below)
Patches
build.sh applies these; kpkg applies nothing by itself.
Ten of the patches are Alpine’s set for elogind 255.24 on musl, each carried as Alpine has it with a Subject: line first: 0001 to 0009 make the systemd-derived code compile and behave against musl (no <gshadow.h>, sh instead of bash in two generator scripts, the XSI strerror_r, getdents, a struct stat field the journal code cannot compile against musl, and three include fixes), and 0010 is a backport from systemd that collects a session when its leader process dies. no-runtime-dir.patch is Chimera Linux’s, and is what lets turnstile own the runtime directory (see Notes). lxml-resolve-entities.patch passes resolve_entities=True to the parser in tools/xml_helper.py: python3-lxml otherwise leaves custom-entities.ent unloaded, and the elogind.directives and elogind.index pages stop the build with Entity 'entities' not defined. Those two pages are built unconditionally whatever configure finds, so lxml is a build dependency, not an optional one. udevadm-path.patch writes /usr/sbin/udevadm into 71-seat.rules. The template takes the directory from bindir, which on KDOS holds no udevadm (see eudev), and udev logs the failed run only at debug level.
0001-shared-remove-gshadow.patch— shared: remove gshadowjust like the other part it's already patched in, not actually used
Carried from Alpine's elogind 255.24-r2 (aports community/elogind).
0002-basic-use-sh-instead-of-bash-in-the-shebang.patch— basic: use sh instead of bash in the shebangCarried from Alpine's elogind 255.24-r2 (aports community/elogind).
0003-shared-include-signal.h-in-async.h.patch— shared: include signal.h in async.hCarried from Alpine's elogind 255.24-r2 (aports community/elogind).
0004-add-missing-musl_missing.h.patch— add missing musl_missing.h../src/shared/wall.c:53:20: error: '_PATH_UTMPX' undeclared (first use in this function); did you mean 'PATH_MAX'?
Carried from Alpine's elogind 255.24-r2 (aports community/elogind).
0005-use-sys-prctl-instead-of-linux-prctl-to-avoid-duplic.patch— use sys/prctl instead of linux/prctl to avoid duplicate declarationCarried from Alpine's elogind 255.24-r2 (aports community/elogind).
0006-pass-correct-parameters-to-getdents64.patch— pass correct parameters to getdents64Fixes ../git/src/basic/recurse-dir.c:57:40: error: incompatible pointer types passing 'uint8_t *' (aka 'unsigned char *') to parameter of type 'struct dirent *' [-Werror,-Wincompatible-pointer-types] n = getdents64(dir_fd, (uint8_t*) de->buffer + de->buffer_size, bs - de->buffer_size); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../git/src/basic/stat-util.c:102:28: error: incompatible pointer types passing 'union (unnamed union at ../git/src/basic/stat-util.c:78:9) *' to parameter of type 'struct dirent *' [-Werror,-Wincompatible-pointer-types] n = getdents64(fd, &buffer, sizeof(buffer)); ^~~~~~~
Upstream-Status: Inappropriate [musl specific]
Carried from Alpine's elogind 255.24-r2 (aports community/elogind).
0007-errno-util-Make-STRERROR-portable-for-musl.patch— errno-util: Make STRERROR portable for muslSadly, systemd has decided to use yet another GNU extention in a macro lets make this such that we can use XSI compliant strerror_r() for non-glibc hosts
Upstream-Status: Inappropriate [musl specific]
Carried from Alpine's elogind 255.24-r2 (aports community/elogind).
0008-distinguish-XSI-compliant-strerror_r-from-GNU-specif.patch— distinguish XSI-compliant strerror_r from GNU-specifi strerror_rXSI-compliant strerror_r and GNU-specifi strerror_r are different.
int strerror_r(int errnum, char *buf, size_t buflen); /* XSI-compliant */
char *strerror_r(int errnum, char *buf, size_t buflen); /* GNU-specific */
We need to distinguish between them. Otherwise, we'll get an int value assigned to (char *) variable, resulting in segment fault.
Upstream-Status: Inappropriate [musl specific]
Carried from Alpine's elogind 255.24-r2 (aports community/elogind).
0009-sd-journal-remove-last_stat.patch— sd-journal: remove last_statIn file included from ../src/libelogind/sd-journal/journal-internal.h:13, from ../src/libelogind/sd-journal/sd-journal.c:32: ../src/libelogind/sd-journal/journal-file.h:80:21: error: field 'last_stat' has incomplete type 80 | struct stat last_stat; | ^~~~~~~~~
Carried from Alpine's elogind 255.24-r2 (aports community/elogind).
0010-login-Queue-session-for-garbage-collection-on-leader.patch— login: Queue session for garbage collection on leader deathThis ensures sessions are cleaned up properly in case the user service manager was manually stopped.
(cherry picked from commit a6bccda28d398925397d3a8f0c7491ba03941f23)
Carried from Alpine's elogind 255.24-r2 (aports community/elogind).
lxml-resolve-entities.patch— Ask lxml to resolve external entities when reading the manual pageslxml's XMLParser() defaults to resolve_entities='internal', which leaves the external parameter entity custom-entities.ent unloaded, so make-directive-index.py and make-man-index.py stop at the first page using it with "Entity 'entities' not defined".
no-runtime-dir.patch— leave the user runtime directory to turnstilepam_elogind does not export XDG_RUNTIME_DIR, and elogind neither mounts a tmpfs at /run/user/<uid> at a user's first login nor unmounts and removes it at the last logout. turnstile (manage_rundir) creates, exports and removes the directory instead, and keeps it for a lingering user, whose boxes and user services would otherwise lose their sockets when elogind removed it at logout.
Carried from Chimera Linux's elogind (cports main/elogind, no-runtime-dir.patch, by q66), with its hunks placed for 255.24.
udevadm-path.patch— Run udevadm from /usr/sbin, where eudev installs it
Installation
From the repository root, inside the build container, this is the line kdosbuild runs for the port:
script/chroot/exec.sh bash -c 'source script/phases/41_system/phase.env && kpkg install elogind'
What kpkg does
kpkg runs these steps, in this order, as root inside the chroot. The port directory is /ports/core/auth/elogind.
1. Verify every declared source. Each file a sha256 = line names, found in the port directory or in /var/cache/kpkg/sources, must hash to its line; a mismatch stops the build before anything is unpacked.
cd /ports/core/auth/elogind
echo '7737e13f409bdf6041bd1a1f5580ab197790f6641e26faf93e09c19c68f5dab8 elogind-255.24.tar.gz' | sha256sum -c -
2. Unpack. The work directory is emptied and the first source is unpacked into $SRC with its top directory stripped; any later tarball lands unstripped beside it in $SRC_ROOT, and a file that is not a tarball is copied into $SRC.
SRC_ROOT=/var/cache/kpkg/work/elogind
SRC=$SRC_ROOT/elogind-255.24
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf elogind-255.24.tar.gz -C "$SRC" --strip-components=1
Every config.guess and config.sub older than automake’s is then replaced with automake’s, so a configure script recognises the musl target.
3. Build. build.sh is sourced in a subshell under set -e, from $SRC, with name, version, release and the five paths PKGNAME, PORT_SRC, SRC_ROOT, SRC and PKG set as shell variables. Its body, verbatim:
for p in "$PORT_SRC"/0*.patch "$PORT_SRC/no-runtime-dir.patch" "$PORT_SRC/lxml-resolve-entities.patch" "$PORT_SRC/udevadm-path.patch"; do
patch -p1 --no-backup-if-mismatch -i "$p"
done
meson setup build \
--prefix=/usr --sysconfdir=/etc --libdir=lib --localstatedir=/var \
--libexecdir=/usr/lib/elogind \
--buildtype=release \
-Dmode=release \
-Dcgroup-controller=elogind \
-Ddefault-hierarchy=unified \
-Ddefault-kill-user-processes=false \
-Dhalt-path=/sbin/halt \
-Dpoweroff-path=/sbin/poweroff \
-Dreboot-path=/sbin/reboot \
-Dkexec-path=/usr/sbin/kexec \
-Dnologin-path=/usr/sbin/nologin \
-Dpamlibdir=/usr/lib/security \
-Dpam=enabled \
-Dpolkit=enabled \
-Dacl=enabled \
-Dutmp=false \
-Daudit=disabled \
-Dselinux=disabled \
-Dsmack=false \
-Dxenctrl=disabled \
-Ddbus=disabled \
-Dtranslations=false \
-Dman=enabled \
-Dhtml=disabled \
-Dtests=false
meson compile -C build
DESTDIR=$PKG meson install --no-rebuild -C build
rm "$PKG/usr/share/dbus-1/system-services/org.freedesktop.login1.service"
rmdir "$PKG/usr/share/dbus-1/system-services"
The switches, and why each is set:
--libexecdir=/usr/lib/elogind— The daemon,elogind-cgroups-agent,elogind-uaccess-commandand thesystem-sleepandsystem-shutdownhook directories go into/usr/lib/elogind, beside the privatelibelogind-sharedlibrary. elogind uses the value as the directory itself, not as a parent to addelogindto, so/usr/libwould make the daemon the file/usr/lib/elogindand collide with that directory. TLP’s sleep hook is installed into/usr/lib/elogind/system-sleepfor the same reason.-Dmode=release— The build mode. The option has no default value, so meson takes the first choice,developer, which adds-fno-omit-frame-pointerand turns on developer-only behaviour;releaseadds-ftrivial-auto-var-init=zeroinstead.-Dcgroup-controller=elogind— The name elogind gives the cgroup hierarchy it tracks sessions in. Left empty, configure runs a script that reads the build machine’s/proc/self/cgroupand takes whatever init that machine runs, so the value would depend on the builder.-Ddefault-hierarchy=unified— Pure cgroup2, the only hierarchy/etc/fstabmounts.DelegateSessionCgroups=yesin the shipped drop-in needs it. It is upstream’s default value, stated.-Ddefault-kill-user-processes=false— Compile inKillUserProcesses=no. The drop-in sets the same key; the compiled default decides when the drop-in is absent.-Dhalt-path=/sbin/halt,-Dpoweroff-path=/sbin/poweroff,-Dreboot-path=/sbin/reboot— sysvinit’s programs, so Shut Down and Restart from Plasma go through runlevel 0 or 6 andrcKlike any other shutdown. Left empty, each path is whatever the build machine has first in/usr/sbinor/sbin.-Dkexec-path=/usr/sbin/kexec,-Dnologin-path=/usr/sbin/nologin— Stated for the same reason: a fixed path instead of one probed on the builder. No port installskexec, so login1’s kexec reboot is not available.-Dpamlibdir=/usr/lib/security— Installpam_elogind.sowhere pam keeps its modules. It is the value the option would derive, stated.-Dpam=enabled— Buildpam_elogind.so, and make a missinglibpama configure error. Every login stack includes it through/etc/pam.d/system-login.-Dpolkit=enabled— Ask polkit before a caller may suspend, power off, reboot, take over a seat or set a user’s linger, and installorg.freedesktop.login1.policy. Without it elogind allows those calls only to root, and PowerDevil cannot suspend. The option needs no polkit library at build time: configure looks uppolkit-gobject-1only to decide whether to install the pre-0.106.pklafiles, and the checks go to polkit over D-Bus. So elogind does not depend on polkit, and polkit, built-Dsession_tracking=elogind, depends on elogind with no cycle.-Dacl=enabled— Link acl.elogind-uaccess-command, which theuaccessudev rule runs, grants the active session’s user an ACL on the seat’s device nodes (sound, video, DRM, input) and takes it back on a session switch.-Dutmp=false— Write no utmp or wtmp records. SDDM and util-linux’sloginwrite them through utmps; elogind would write through musl’sutmpxfunctions, which are stubs.-Daudit=disabled,-Dselinux=disabled,-Dsmack=false,-Dxenctrl=disabled— No Linux audit records, no SELinux or SMACK labels and no Xen kexec. None of the libraries is a port.-Ddbus=disabled— Do not link libdbus. elogind talks D-Bus through its own sd-bus; libdbus is used only by its test programs. The policy file goes to/usr/share/dbus-1/system.deither way.-Dtranslations=false— No message catalogues; English only (see Size and language policy).-Dman=enabled,-Dhtml=disabled— Build the manual pages (loginctl(1),logind.conf(5),pam_elogind(8), thesd-loginandsd-busAPI pages) from DocBook withxsltproc, through libxslt, docbook-xsl and docbook-xml, and no HTML copy of them.-Dtests=false— Build no test programs.
The common switches of each build system are explained in the Flag glossary.
4. Package. kpkg removes libtool archives, the info directory index, mimeinfo.cache and every fonts.dir from $PKG, copies the source’s licence files into /usr/share/licenses/elogind, prunes what the image does not ship, lints the tree and rolls it reproducibly:
tar --sort=name --format=gnu --numeric-owner --owner=0 --group=0 \
--mtime=@$SOURCE_DATE_EPOCH \
--use-compress-program='xz -9 -T0 --block-size=32MiB --no-adjust' \
-cf elogind-255.24-1.tar.xz -C "$PKG" .
5. Adopt. kpkgadd installs the package’s files over the root, refusing a path another package owns, records the file list in /var/lib/kpkg/db/elogind, and runs the triggers its paths call for.
Contents
Installed programs: busctl, elogind-inhibit, loginctl.
Installed libraries: libelogind.so.
Installed directories: /etc/elogind, /usr/include/elogind, /usr/lib/elogind/system-shutdown, /usr/share/doc/elogind, /usr/share/licenses/elogind, /var/lib/elogind.
Short descriptions
busctl |
Introspect the bus |
elogind-inhibit |
Execute a program with an inhibition lock taken |
loginctl |
Control the elogind login manager |
libelogind.pc |
elogind Library |
Notes
/run/user/<uid> belongs to turnstile. Unpatched, elogind mounts a tmpfs there at a user’s first login and unmounts and deletes it with everything in it at the last logout, and pam_elogind exports XDG_RUNTIME_DIR. KDOS boxes and the user’s services keep their sockets in that directory (the session bus at /run/user/<uid>/bus, which every box binds), and a user who lingers keeps them running after logging out, so a second owner removing the directory under them breaks every box. no-runtime-dir.patch takes both jobs out of elogind; turnstile, built with manage_rundir, creates, exports and removes the directory. With the patch and without turnstile in the PAM stack a login has no XDG_RUNTIME_DIR at all, and KWin, the greeter’s included, refuses to start.
Lingering is one directory for both. loginctl enable-linger writes /var/lib/elogind/linger/<user>. turnstile is built to read the same directory, so the linger elogind reports and the one turnstile acts on cannot disagree.
No D-Bus activation. The build installs /usr/share/dbus-1/system-services/org.freedesktop.login1.service, which would let the bus start a second, unsupervised elogind for any caller that asked for org.freedesktop.login1 before the supervised one held it. The recipe deletes it, as the polkit recipe deletes polkit’s; the init script waits until elogind owns the name before the scripts after it run.
Configuration. Two drop-ins, read after upstream’s 10-elogind.conf, come from the tree’s fs/ overlay, not from this package, so their comments carry the reasons beside the keys; a third is written at boot:
/etc/elogind/logind.conf.d/50-kdos.conf.KillUserProcesses=noandRemoveIPC=nokeep a user’s boxes, their processes and their POSIX shared memory alive across a logout.DelegateSessionCgroups=yesgives each session thesessionanddelegatedcgroups under/sys/fs/cgroup/<session>, owned by the user, which rootless podman needs to enforce a box’s memory and CPU limits. TheHandle*keys apply only where no session holds the matching inhibitor, which in a Plasma session PowerDevil does: at the greeter and at a console login, a closed lid suspends unless the machine is docked, and the power key powers off.InhibitDelayMaxSec=5bounds how long the lock screen and KWin may delay a suspend./etc/elogind/sleep.conf.d/50-kdos.conf. Hibernation, suspend-then-hibernate and hybrid sleep are refused, soCanHibernateand the related calls answernoand Plasma hides those actions. Swap on KDOS is zram, so there is no disk to resume from. These keys are read fromsleep.conf, notlogind.conf; a[Sleep]section in alogind.confdrop-in is ignored./run/elogind/sleep.conf.d/60-kdos-virtio-gpu.conf, written by40_elogind.shbefore elogind starts, and only on a machine with a virtio-gpu display (a virtual machine). It setsAllowSuspend=no, soCanSuspendanswersnoand Plasma, SDDM and PowerDevil offer no Sleep: that driver cannot restore the device after a resume, and the display stays dark.
The package’s own logind.conf, sleep.conf and their 10-elogind.conf drop-ins set nothing and sort before 50. A copy of either KDOS file in the package would be installed over the fs/ one, because packages are installed after fs/ is synced, which is why the recipe writes neither.
Seats come from the udev rules. The package installs 70-power-switch.rules, 70-uaccess.rules, 71-seat.rules and 73-seat-late.rules into /usr/lib/udev/rules.d. 71-seat.rules tags every DRM card master-of-seat and every input device seat; without it seat0 has no graphics device and the greeter’s KWin cannot take the seat. -Dacl=enabled is what writes the elogind-uaccess-command line into 73-seat-late.rules.
No libsystemd alias. Some distributions link libsystemd.pc and /usr/include/systemd to elogind’s. KDOS does not, so a port that probes for libsystemd still finds none and its systemd-only code stays off; a port that wants logind names libelogind.
meson setup runs realpath --relative-to, which coreutils’ realpath has and toybox’s and busybox’s do not, so coreutils is in depends.