mirror of
https://github.com/uutils/shadow.git
synced 2026-06-10 16:14:57 -07:00
Makefile: drop PROFILE var, fix stale comments
Address Copilot review round 2: - Remove PROFILE variable and hardcode --release / target/release/. Cargo maps "dev" profile to target/debug/ (not target/dev/), so PROFILE=dev would silently break install. Nobody installs debug builds of setuid-root tools. - Fix stale comments in Makefile and README that referenced the old "chmod on symlink follows through" approach. The current code uses install -Dm4755 directly.
This commit is contained in:
@@ -1,6 +1,5 @@
|
|||||||
PREFIX ?= /usr/local
|
PREFIX ?= /usr/local
|
||||||
BINDIR ?= $(PREFIX)/sbin
|
BINDIR ?= $(PREFIX)/sbin
|
||||||
PROFILE ?= release
|
|
||||||
|
|
||||||
# Tools that need setuid-root to allow non-root callers (change own password,
|
# Tools that need setuid-root to allow non-root callers (change own password,
|
||||||
# GECOS, shell, effective group).
|
# GECOS, shell, effective group).
|
||||||
@@ -17,10 +16,10 @@ ALL_TOOLS = $(SETUID_TOOLS) $(ROOT_TOOLS)
|
|||||||
all: build
|
all: build
|
||||||
|
|
||||||
build:
|
build:
|
||||||
cargo build --profile $(PROFILE) --workspace --bins --exclude shadow-rs
|
cargo build --release --workspace --bins --exclude shadow-rs
|
||||||
|
|
||||||
build-multicall:
|
build-multicall:
|
||||||
cargo build --profile $(PROFILE) --bin shadow-rs
|
cargo build --release --bin shadow-rs
|
||||||
|
|
||||||
test:
|
test:
|
||||||
cargo test --workspace
|
cargo test --workspace
|
||||||
@@ -29,21 +28,21 @@ test:
|
|||||||
# layout matching GNU shadow-utils. Only passwd/chfn/chsh/newgrp are setuid.
|
# layout matching GNU shadow-utils. Only passwd/chfn/chsh/newgrp are setuid.
|
||||||
install: build
|
install: build
|
||||||
@for tool in $(SETUID_TOOLS); do \
|
@for tool in $(SETUID_TOOLS); do \
|
||||||
install -Dm4755 target/$(PROFILE)/$$tool $(DESTDIR)$(BINDIR)/$$tool || exit 1; \
|
install -Dm4755 target/release/$$tool $(DESTDIR)$(BINDIR)/$$tool || exit 1; \
|
||||||
done
|
done
|
||||||
@for tool in $(ROOT_TOOLS); do \
|
@for tool in $(ROOT_TOOLS); do \
|
||||||
install -Dm0755 target/$(PROFILE)/$$tool $(DESTDIR)$(BINDIR)/$$tool || exit 1; \
|
install -Dm0755 target/release/$$tool $(DESTDIR)$(BINDIR)/$$tool || exit 1; \
|
||||||
done
|
done
|
||||||
@echo "Installed $(words $(ALL_TOOLS)) standalone binaries to $(DESTDIR)$(BINDIR)/"
|
@echo "Installed $(words $(ALL_TOOLS)) standalone binaries to $(DESTDIR)$(BINDIR)/"
|
||||||
@echo " setuid (4755): $(SETUID_TOOLS)"
|
@echo " setuid (4755): $(SETUID_TOOLS)"
|
||||||
@echo " root-only (0755): $(ROOT_TOOLS)"
|
@echo " root-only (0755): $(ROOT_TOOLS)"
|
||||||
|
|
||||||
# Opt-in install: single multicall binary with symlinks. Smaller footprint but
|
# Opt-in install: single multicall binary with symlinks. Smaller footprint but
|
||||||
# larger setuid attack surface — chmod on any setuid symlink follows through to
|
# larger setuid attack surface — the binary is installed setuid-root, so all 14
|
||||||
# the ELF, so all tools end up running with euid=root. Intended for
|
# applets run with euid=root when invoked via symlink. Intended for
|
||||||
# container/embedded use where disk savings matter and attack surface does not.
|
# container/embedded use where disk savings matter and attack surface does not.
|
||||||
install-multicall: build-multicall
|
install-multicall: build-multicall
|
||||||
install -Dm4755 target/$(PROFILE)/shadow-rs $(DESTDIR)$(BINDIR)/shadow-rs
|
install -Dm4755 target/release/shadow-rs $(DESTDIR)$(BINDIR)/shadow-rs
|
||||||
@for tool in $(ALL_TOOLS); do \
|
@for tool in $(ALL_TOOLS); do \
|
||||||
ln -sf shadow-rs $(DESTDIR)$(BINDIR)/$$tool; \
|
ln -sf shadow-rs $(DESTDIR)$(BINDIR)/$$tool; \
|
||||||
done
|
done
|
||||||
|
|||||||
@@ -96,9 +96,9 @@ sudo make install PREFIX=/usr/local
|
|||||||
```
|
```
|
||||||
|
|
||||||
Alternative: single multicall binary with symlinks. Smaller footprint (~14×
|
Alternative: single multicall binary with symlinks. Smaller footprint (~14×
|
||||||
disk savings) but larger setuid attack surface, since `chmod` on a setuid
|
disk savings) but larger setuid attack surface — the binary is installed
|
||||||
symlink follows through to the underlying ELF — all 14 tools end up running
|
setuid-root, so all 14 applets run with `euid=root` when invoked via symlink.
|
||||||
with `euid=root` when invoked. Intended for container/embedded use cases.
|
Intended for container/embedded use cases.
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
sudo make install-multicall PREFIX=/usr/local
|
sudo make install-multicall PREFIX=/usr/local
|
||||||
|
|||||||
Reference in New Issue
Block a user