79.1. pam-1.7.3
Linux Pluggable Authentication Modules (libpam + pam_unix against /etc/shadow)
| Version | 1.7.3, release 2 |
| Shelf | auth — Authentication, authorisation, accounts and directory services |
| Phase | 41_system (System), 40 of 1047 in build order |
| Licence | BSD-3-Clause OR GPL-2.0-or-later |
| Homepage | https://github.com/linux-pam/linux-pam |
| Build time | 0.2 SBU |
| Installed size | 1.1 MiB in 86 files |
| Recipe | ports/core/auth/pam/kpkgbuild |
About
Linux-PAM, the Pluggable Authentication Modules, is the library through which SDDM, util-linux’s login, sudo, vlock, the lock screen, polkit and the other programs that link it hand a password check and the setting up of a login to a stack of modules configured under /etc/pam.d. On KDOS the stacks are short: pam_unix against /etc/passwd and /etc/shadow, pam_limits for resource limits, and, for a login, pam_turnstile and pam_elogind, which come from turnstile and elogind; sudo’s file adds pam_fprintd for an enrolled finger. Besides the library and modules, this port writes the shared stacks that other service files include by name. shadow is built without PAM, so su and passwd read the shadow file themselves.
Sources
pam-1.7.3.tar.xz(503.5 KiB)
sha2562ce4765fd49df6693771ef2941f81e33d8ee14b94a81a5c7b369aa3b137b85a5
upstream: https://github.com/linux-pam/linux-pam/releases/download/v1.7.3/Linux-PAM-1.7.3.tar.xz
archive copy: sources-1/auth--pam-1.7.3.tar.xz
Dependencies
Depends on: meson, ninja, pkgconf, flex.
Required by (13): cups, elogind, fprintd, kbd, krdp, kscreenlocker, kwallet-pam, polkit, postgresql, sddm, sudo, turnstile, util-linux-login.
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 pam'
What kpkg does
kpkg runs these steps, in this order, as root inside the chroot. The port directory is /ports/core/auth/pam.
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/pam
echo '2ce4765fd49df6693771ef2941f81e33d8ee14b94a81a5c7b369aa3b137b85a5 pam-1.7.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/pam
SRC=$SRC_ROOT/pam-1.7.3
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf pam-1.7.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:
meson setup build \
--prefix=/usr --libdir=lib --sysconfdir=/etc \
--buildtype=release \
-D i18n=disabled \
-D docs=disabled \
-D audit=disabled \
-D econf=disabled \
-D logind=disabled \
-D elogind=disabled \
-D selinux=disabled \
-D nis=disabled \
-D pwaccess=disabled \
-D pam_userdb=disabled \
-D examples=false \
-D xtests=false \
-D pam_unix=enabled
meson compile -C build
DESTDIR=$PKG meson install --no-rebuild -C build
rm -rf "$PKG/usr/lib/systemd"
chmod -v 4755 $PKG/usr/sbin/unix_chkpwd
install -vdm755 $PKG/etc/pam.d
cat > $PKG/etc/pam.d/system-auth << "EOF"
# Begin /etc/pam.d/system-auth
account required pam_unix.so
auth required pam_unix.so nullok
auth optional pam_permit.so
session required pam_limits.so
session required pam_unix.so
password required pam_unix.so sha512 shadow try_first_pass
# End /etc/pam.d/system-auth
EOF
cat > $PKG/etc/pam.d/system-account << "EOF"
# Begin /etc/pam.d/system-account
account required pam_unix.so
# End /etc/pam.d/system-account
EOF
cat > $PKG/etc/pam.d/system-session << "EOF"
# Begin /etc/pam.d/system-session
session required pam_limits.so
session required pam_unix.so
# End /etc/pam.d/system-session
EOF
cat > $PKG/etc/pam.d/system-password << "EOF"
# Begin /etc/pam.d/system-password
password required pam_unix.so sha512 shadow try_first_pass
# End /etc/pam.d/system-password
EOF
cat > $PKG/etc/pam.d/system-login << "EOF"
# Begin /etc/pam.d/system-login
auth include system-auth
account include system-account
password include system-password
session include system-session
-session optional pam_turnstile.so
-session optional pam_elogind.so
# End /etc/pam.d/system-login
EOF
cat > $PKG/etc/pam.d/other << "EOF"
# Begin /etc/pam.d/other
auth required pam_warn.so
auth required pam_deny.so
account required pam_warn.so
account required pam_deny.so
password required pam_warn.so
password required pam_deny.so
session required pam_warn.so
session required pam_deny.so
# End /etc/pam.d/other
EOF
The switches, and why each is set:
-D pam_unix=enabled— Buildpam_unix, the module that checks a password against the shadow file, and make it a setup error if it cannot be built; every stackbuild.shwrites exceptothernames it.-D logind=disabled,-D elogind=disabled— Take no session information from a logind forpam_issue,pam_limitsandpam_timestamp. elogind linkslibpamand is built after this port, so building pam againstlibelogindwould be a dependency cycle; and the module that registers a login with elogind,pam_elogind.so, is built by elogind itself.-D audit=disabled,-D selinux=disabled,-D econf=disabled,-D pwaccess=disabled— Linux audit logging, SELinux contexts, libeconf’s configuration parsing and libpwaccess inpam_unix; none of their libraries is a port.-D nis=disabled— NIS/YP lookups inpam_unix; accounts are local.-D pam_userdb=disabled— Do not buildpam_userdb, which checks passwords against a Berkeley DB, GDBM or NDBM file instead of the shadow file.-D i18n=disabled— No translated messages; the English-only result is the language policy.-D docs=disabled,-D examples=false,-D xtests=false— No manuals built from DocBook, no example programs and no extended tests.
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/pam, 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 pam-1.7.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/pam, and runs the triggers its paths call for.
Contents
Installed programs: faillock, mkhomedir_helper, pam_namespace_helper, pam_timestamp_check, pwhistory_helper, unix_chkpwd.
Installed libraries: libpam.so, libpam_misc.so, libpamc.so.
Installed directories: /etc/security/namespace.d, /usr/include/security, /usr/lib/security/pam_filter, /usr/share/licenses/pam, /usr/share/pam.
Short descriptions
pam.pc |
The primary Linux-PAM library. It is used by PAM modules and PAM-aware applications. |
pam_misc.pc |
Miscellaneous functions that make the job of writing PAM-aware applications easier. |
pamc.pc |
The PAM client API library and binary prompt support. Rarely used. |
Notes
unix_chkpwdis made setuid root here. It is howpam_unixreads a 0600/etc/shadowon behalf of a caller that is not root. meson installs it 0755; left that way it cannot open the file, and every check from a program running as the session user — the lock screen orvlock— is refused. It is one of the entries in setuid binaries.- The shared stacks.
build.shwritessystem-auth,system-account,system-session,system-passwordandsystem-login, which the service files of other ports include by name:sudo’s,kbd’svlock, polkit’spolkit-1, util-linux’sloginand SDDM’s. Anincludeof a stack that is absent makes every call through that module type fail withPAM_PERM_DENIED, and only syslog names the file. Withsystem-accountmissing,sudoreports “PAM account management error: Permission denied” and syslog has_pam_load_conf_file: unable to open config for system-account. system-loginis the stack every login includes. It is the foursystem-*stacks plus two session modules:pam_turnstile, which creates/run/user/<uid>at the user’s first login, starts the user’s services and exportsXDG_RUNTIME_DIRandDBUS_SESSION_BUS_ADDRESS, andpam_elogind, which registers the login as a session on its seat, so the login is the active session polkit’sallow_activeanswers apply to. turnstile comes first, as in Chimera Linux’ssystem-login. Both lines start with-, so a system without either port installed still logs in, with no runtime directory or no registered session. A login that skips this stack gets neither: no session bus, no audio and noallow_activegrants.otherdenies. A service with no file of its own is refused, andpam_warnlogs it, rather than authenticating against nothing.- New hashes are SHA-512.
pam_unixhashes through musl’scrypt(), which knows DES, MD5, bcrypt, SHA-256 and SHA-512 and nothing else. Namingyescryptin apasswordline makespam_unixlog “Algo yescrypt not supported by the crypto backend” and refuse every password change made through PAM. /usr/lib/systemdis removed after the install. meson installspam_namespace.servicewhatever the options say, and the package lint refuses a package with that directory in it.