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
shadow-4.20.3.tar.xz(2.2 MiB)
sha256623be9429f64fa2165bfc5957c6a642ec309c5cf23c0d53855c99f7591922297
upstream: https://github.com/shadow-maint/shadow/releases/download/4.20.3/shadow-4.20.3.tar.xz
archive copy: sources-1/auth--shadow-4.20.3.tar.xz
Dependencies
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.
--without-libbsd, line 28: libbsd (explained with the switches below)--without-libpam, line 29: pam (explained with the switches below)
Patches
build.sh applies these; kpkg applies nothing by itself.
no-mail-spool.patch— login.defs: name no mail spool, so the user tools keep noneprivate-homes.patch— login.defs: make the homes useradd creates private (HOME_MODE 0700)
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:
--disable-logind— Build no logind integration, whichloginandsuuse to register a session. Left on, which is upstream’s default, configure stops unless it findslibsystemd, which is not a port; elogind is a41_systemport, built after this one, and the login that registers a session is util-linux-login’s throughpam_elogind.--disable-rpath— Embed no run-time library search path in the installed programs.--enable-lastlog— Install thelastlogprogram, which reports/var/log/lastlog; util-linux’sloginwrites that file. Upstream’s default is off; it needs<lastlog.h>, which musl provides.--with-bcrypt— AcceptBCRYPTasENCRYPT_METHODin/etc/login.defs. Hashing goes through musl’scrypt(), which implements bcrypt.--without-yescrypt— Do not offerYESCRYPT: musl’scrypt()has no yescrypt, so a hash written with it could never be checked.--without-libbsd— Compile shadow’s own copies ofreadpassphrase()andfreezero()instead of taking them from libbsd. Left at its default, configure looks forreadpassphrase()in the C library or in libbsd and stops when neither has it; musl does not, and libbsd is a41_systemport, not installed when this builds.--without-libpam— Check passwords against/etc/shadowdirectly, with no PAM. PAM is built in a later phase, and/etc/pam.d/otherdenies everything, so a shadow tool built against PAM would need a service file of its own for every program.--with-acl— Copy POSIX ACLs along with the files whenuseradd -mfills a new home from/etc/skelandusermod -mmoves one, throughperm_copy_fd()from acl; configure also needs<attr/error_context.h>from attr. Named, a missing header or library stops configure instead of dropping the feature.--with-btrfs— Letuseraddcreate a home directory as a btrfs subvolume (--btrfs-subvolume-home, orBTRFS_SUBVOLUME_HOMEinlogin.defs). The installer can put the root on btrfs (kinstall).--without-audit,--without-selinux,--without-tcb— No Linux audit records, no SELinux labels and no per-usertcbshadow files. None of the three libraries is in the tree.--with-group-name-max-length=32— Refuse group names longer than 32 characters. It is upstream’s default value, stated.shadow_cv_maildir=none,shadow_cv_mailfile=none— Compile in no mail spool directory and no mailbox file name. configure otherwise takes the first of/var/mail,/var/spool/mail,/usr/spool/mailand/usr/mailthat exists in the build root, and the first ofMailbox,mailbox,Mail,mailand.mailthat exists in the builder’s home, and the tools fall back to them wheneverlogin.defsnames neither, which withno-mail-spool.patch(see Notes) would bring back the mailbox the image has no directory for.CPPFLAGS=-I/usr/include/utmps,LIBS="-lutmps -lskarnet"— Build against utmps, so the programs that read or write login records see the oneswhoandlastread. musl’s ownutmpxfunctions are stubs; see Login records.
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.