Skip to the text
KDOS
Menu
kdos.dev KDOS from Scratch KDOS 0.2 · 4dd4a10 · 2026-11-30 Contents Index

41.4. shadow-4.20.3

Password and user-account management programs

Version 4.20.3, release 2
Shelf auth — Authentication, authorisation, accounts and directory services
Phase 30_foundation (Build Foundation), 84 of 127 in build order
Licence BSD-3-Clause
Homepage https://github.com/shadow-maint/shadow
Build time 0.3 SBU
Installed size 2.5 MiB in 38 files
Recipe ports/core/auth/shadow/kpkgbuild

About

shadow is the account suite: su, passwd, useradd and the other user* and group* programs, chsh, chfn, newgrp, vipw, lastlog, nologin, and newuidmap and newgidmap with their library libsubid. It owns /etc/login.defs, the defaults those programs and util-linux’s login read.

On KDOS it is the only owner of these names. util-linux is built without its own su, nologin, chsh and chfn (see util-linux). login is not shadow’s: the recipe deletes it, and a console login ends in util-linux’s agetty handing over to util-linux-login, which is built against PAM and so registers the login with elogind. newuidmap and newgidmap are what every boxed application depends on: the container engine runs them to write a rootless container’s user-namespace map, and without their setuid bits no box starts (setuid binaries).

The build links no PAM: pam is a 41_system port, and su and passwd here check /etc/shadow themselves.

Sources

Dependencies

Depends on: acl, attr, utmps.

Required by (4): kdenetwork-filesharing, plasma-setup, skopeo, util-linux-login.

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.

Patches

build.sh applies these; kpkg applies nothing by itself.

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 shadow'

What kpkg does

kpkg runs these steps, in this order, as root inside the chroot. The port directory is /ports/core/auth/shadow.

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/shadow
echo '623be9429f64fa2165bfc5957c6a642ec309c5cf23c0d53855c99f7591922297  shadow-4.20.3.tar.xz' | 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/shadow
SRC=$SRC_ROOT/shadow-4.20.3
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf shadow-4.20.3.tar.xz -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/no-mail-spool.patch"
patch -p1 -i "$PORT_SRC/private-homes.patch"

./configure \
	--prefix=/usr \
	--bindir=/usr/bin \
	--sbindir=/usr/sbin \
	--libdir=/usr/lib \
	--sysconfdir=/etc \
	--disable-logind \
	--disable-static \
	--disable-rpath \
	--disable-nls \
	--enable-lastlog \
	--with-bcrypt \
	--without-yescrypt \
	--without-libbsd \
	--without-libpam \
	--with-acl \
	--with-btrfs \
	--without-audit \
	--without-selinux \
	--without-tcb \
	--with-group-name-max-length=32 \
	shadow_cv_maildir=none \
	shadow_cv_mailfile=none \
	CPPFLAGS=-I/usr/include/utmps LIBS="-lutmps -lskarnet"

make
make DESTDIR=$PKG install

chmod 4755 "$PKG/usr/bin/newuidmap" "$PKG/usr/bin/newgidmap"
rm "$PKG/usr/bin/login" "$PKG/etc/login.access"

The switches, and why each is set:

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/shadow, 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 shadow-4.20.3-2.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/shadow, and runs the triggers its paths call for.

Contents

Installed programs: chage, chfn, chgpasswd, chpasswd, chsh, faillog, getsubids, gpasswd, groupadd, groupdel, groupmod, grpck, grpconv, grpunconv, lastlog, newgidmap, newgrp, newuidmap, newusers, nologin, passwd, pwck, pwconv, pwunconv, sg, su, useradd, userdel, usermod, vigr, vipw.

Installed libraries: libsubid.so.

Installed directories: /usr/include/shadow, /usr/share/licenses/shadow.

Notes

no-mail-spool.patch comments out MAIL_DIR in /etc/login.defs, and MAIL_FILE stays commented, so no tool keeps a mailbox. Nothing on KDOS delivers local mail and the image has no spool directory: with the line in place useradd prints Creating mailbox file: No such file or directory for every account it makes, and userdel -r prints mail spool (/var/spool/mail/<user>) not found for every one it removes. useradd’s compiled CREATE_MAIL_SPOOL is yes, and no configure switch changes it; with no MAIL_DIR it creates no mailbox all the same, and the base file system’s /etc/default/useradd sets the key to no, so useradd -D reports what useradd does.

private-homes.patch sets HOME_MODE 0700 in the same file, so every home useradd -m and newusers create is readable by its owner alone, the mode the installer gives its own account. An account made by System Settings, AccountsService or Plasma Setup goes through useradd -m and gets it too. Without the key the two take the mode from UMASK 022 and every other account can read the new home. UMASK is left at 022: pam_umask applies the same key to every login, and 077 there would make every file a user writes unreadable to the groups they share.

The /etc/default/useradd that ships in the base file system sets GROUPS=audio, which useradd adds to every account it makes without -r, so an account made by System Settings, AccountsService or Plasma Setup gets PipeWire’s real-time limits like the installer’s. useradd -G replaces that list instead of adding to it, which is why accountsservice is patched to add an administrator’s wheel with usermod -a after the account exists.

build.sh ends by setting mode 4755 on newuidmap and newgidmap itself. make install sets the bit already, unless shadow is configured --with-fcaps to rely on file capabilities instead; repeating it means no configure change can leave the two without it. A file capability would not survive kpkg’s package archive, which is written without extended attributes (setuid binaries). kdos doctor checks the two bits, because losing them is silent until a box fails to start.

The hash passwd and chpasswd write is set by ENCRYPT_METHOD in /etc/login.defs. The installed file leaves that line commented out, so they use shadow’s built-in choice, SHA-512. Setting it to BCRYPT works because of --with-bcrypt; YESCRYPT is taken for an invalid value, with a warning, and SHA-512 is used instead.

The recipe deletes /usr/bin/login and /etc/login.access, the access table only shadow’s login reads. util-linux-login installs /usr/bin/login and names shadow in replaces, so it takes the path over in a tree whose installed shadow package still holds it.