Files
shadow/Makefile
T
Pierre Warnier 3de8b506ac build: ship binaries with PAM so passwd can change passwords (#220) (#225)
`pam` is not a default cargo feature, so every build path except the e2e
image compiled the interactive change path out of `passwd`. The tool
could report and lock accounts but not change a password:

    $ passwd alice
    shadow-rs: PAM support is not compiled in — cannot change password
    interactively

That covered the release archive, `make install` (the default install of
14 standalone binaries) and `make install-multicall`. Only the e2e image
passed --features pam, and its assertions stop at `passwd -S`, which
works without PAM — hence nobody noticed.

Enable the feature in the release build and in both Makefile targets, and
install libpam0g-dev on the release runner. The PAM headers are already a
documented build requirement.

Add an e2e assertion that the installed passwd is linked against libpam,
so this cannot regress silently again.

Closes #220.
2026-09-03 13:16:46 +02:00

64 lines
2.3 KiB
Makefile

PREFIX ?= /usr/local
BINDIR ?= $(PREFIX)/sbin
# Tools that need setuid-root to allow non-root callers (change own password,
# GECOS, shell, effective group).
SETUID_TOOLS = passwd chfn chsh newgrp
# Root-only tools (no setuid; fail at getuid() check for non-root callers).
ROOT_TOOLS = useradd userdel usermod chpasswd chage \
groupadd groupdel groupmod pwck grpck
ALL_TOOLS = $(SETUID_TOOLS) $(ROOT_TOOLS)
.PHONY: all build build-multicall test install install-multicall uninstall clean
all: build
# `pam` is not a default cargo feature, so a plain build produces a `passwd`
# that refuses the interactive change path ("PAM support is not compiled in").
# Installed binaries must have it; the PAM headers are already listed as a
# build requirement in the README.
build:
cargo build --release --workspace --bins --exclude uu_shadow --features uu_passwd/pam
build-multicall:
cargo build --release --bin shadow-rs --features pam
test:
cargo test --workspace
# Default install: 14 standalone per-tool binaries with least-privilege setuid
# layout matching GNU shadow-utils. Only passwd/chfn/chsh/newgrp are setuid.
install: build
@for tool in $(SETUID_TOOLS); do \
install -Dm4755 target/release/$$tool $(DESTDIR)$(BINDIR)/$$tool || exit 1; \
done
@for tool in $(ROOT_TOOLS); do \
install -Dm0755 target/release/$$tool $(DESTDIR)$(BINDIR)/$$tool || exit 1; \
done
@echo "Installed $(words $(ALL_TOOLS)) standalone binaries to $(DESTDIR)$(BINDIR)/"
@echo " setuid (4755): $(SETUID_TOOLS)"
@echo " root-only (0755): $(ROOT_TOOLS)"
# Opt-in install: single multicall binary with symlinks. Smaller footprint but
# larger setuid attack surface — the binary is installed setuid-root, so all 14
# applets run with euid=root when invoked via symlink. Intended for
# container/embedded use where disk savings matter and attack surface does not.
install-multicall: build-multicall
install -Dm4755 target/release/shadow-rs $(DESTDIR)$(BINDIR)/shadow-rs
@for tool in $(ALL_TOOLS); do \
ln -sf shadow-rs $(DESTDIR)$(BINDIR)/$$tool; \
done
@echo "Installed multicall shadow-rs + $(words $(ALL_TOOLS)) symlinks to $(DESTDIR)$(BINDIR)/"
uninstall:
@for tool in $(ALL_TOOLS); do \
rm -f $(DESTDIR)$(BINDIR)/$$tool; \
done
rm -f $(DESTDIR)$(BINDIR)/shadow-rs
@echo "Uninstalled shadow-rs from $(DESTDIR)$(BINDIR)/"
clean:
cargo clean