41.1. utmps-0.1.3.4
utmp and wtmp for musl — the utmpx library and the utmpd and wtmpd daemons behind it
| Version | 0.1.3.4, release 1 |
| Shelf | auth — Authentication, authorisation, accounts and directory services |
| Phase | 30_foundation (Build Foundation), 34 of 127 in build order |
| Licence | ISC |
| Homepage | https://skarnet.org/software/utmps/ |
| Build time | 0.1 SBU |
| Installed size | 119.5 KiB in 13 files |
| Recipe | ports/core/auth/utmps/kpkgbuild |
About
utmps is skarnet’s implementation of the utmpx interface: who is logged in at the moment, and the history of logins, logouts, boots and shutdowns. musl’s own utmp and utmpx functions are stubs that store nothing, so on KDOS these records exist only because of this package. It installs libutmps, which sends each call over a socket, and the two daemons that answer it, utmps-utmpd and utmps-wtmpd, which /etc/init.d/06_utmps.sh starts under the supervisor. What each daemon keeps, and who may write to it, is in Login records and utmpd and wtmpd.
Every reader and writer of the records must link libutmps, because utmps’ record layout is not musl’s: sysvinit, util-linux, shadow, coreutils and procps-ng are all built against it. It is built on skalibs, and the daemons run behind s6-ipcserver from s6, which is needed only when they run.
Why it is in KDOS
The comment above the 8 ports from skalibs to sed in script/phases/30_foundation/packages.txt:
utmps, the utmp and wtmp service over skalibs (shelves auth and base-libs): coreutils, sysvinit, util-linux and shadow build against it, and coreutils'
dependsinstalls both in the pinned run above, ahead of the other three.
Sources
utmps-0.1.3.4.tar.gz(35.0 KiB)
sha25612dcc102ad6ac81f81aecc4950733db94f35081947054b9b1473cac5c90810bc
upstream: https://skarnet.org/software/utmps/utmps-0.1.3.4.tar.gz
archive copy: sources-1/auth--utmps-0.1.3.4.tar.gz
Dependencies
Depends on: skalibs.
Required by (7): coreutils, procps-ng, sddm, shadow, sysvinit, util-linux, util-linux-login.
Patches
build.sh applies these; kpkg applies nothing by itself.
runlvl-replace.patch— replace the runlevel record in utmp rather than appending anotherutmpd finds the record a pututxline() replaces by its type alone only for BOOT_TIME, OLD_TIME and NEW_TIME, so every RUN_LVL record init writes is appended. glibc matches RUN_LVL by type as well, and sysvinit relies on it: its runlevel(8) prints the first RUN_LVL record in the file, which with the records appended is the one written at boot, whatever the runlevel since.
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/30_foundation/phase.env && kpkg install utmps'
What kpkg does
kpkg runs these steps, in this order, as root inside the chroot. The port directory is /ports/core/auth/utmps.
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/utmps
echo '12dcc102ad6ac81f81aecc4950733db94f35081947054b9b1473cac5c90810bc utmps-0.1.3.4.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/utmps
SRC=$SRC_ROOT/utmps-0.1.3.4
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf utmps-0.1.3.4.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:
patch -p1 -i "$PORT_SRC/runlvl-replace.patch"
./configure --prefix=/usr --enable-shared --disable-allstatic --enable-pkgconfig \
--with-pkgconfig --enable-utmp --disable-rpath
make
make DESTDIR=$PKG install
The switches, and why each is set:
--enable-shared— Buildlibutmps.soas well aslibutmps.a. skarnet’s configure builds static libraries only unless this is given.--disable-allstatic— Link the programs against shared libraries, skalibs’libskarnet.soamong them, instead of skarnet’s default of preferring the static archives.--enable-pkgconfig— Write and installlibutmps.pc.--with-pkgconfig— Find skalibs throughpkg-configwhile configuring, and stop if it is missing or too old.--enable-utmp— Also install autmp.hwith the Linux-specificutmpdeclarations, besideutmpx.h, for programs that include the older header.--disable-rpath— Linklibutmps.sowith no run-time library path. Left on, it would carry-rpath=/usr/lib, a directory the dynamic loader searches anyway.
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/utmps, 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 utmps-0.1.3.4-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/utmps, and runs the triggers its paths call for.
Contents
Installed programs: utmps-utmpd, utmps-write, utmps-wtmpd.
Installed libraries: libutmps.a, libutmps.so.
Installed directories: /usr/include/utmps, /usr/share/licenses/utmps.
Short descriptions
libutmps.pc |
The utmps library, a secure utmp implementation |
Notes
The headers go to /usr/include/utmps/, not over musl’s <utmpx.h> and <utmp.h>: the switch that would overwrite musl’s, --enable-libc-includes, is not passed. A consumer therefore has to put that directory ahead of the C library’s headers and link the library by name, which is why the recipes of its consumers pass -I/usr/include/utmps (in CPPFLAGS, or in CFLAGS for sysvinit) and -lutmps -lskarnet. A consumer built without them compiles and links cleanly against musl’s stubs, and its who or last then reports no one.
runlvl-replace.patch makes utmps-utmpd keep a single runlevel record, replacing it at each change of runlevel as glibc does, so that who -r prints one line and runlevel the current runlevel rather than the one the machine booted into.
The socket paths are compiled in at their defaults, /run/utmps/.utmpd-socket and /run/utmps/.wtmpd-socket, which are the paths 06_utmps.sh serves.