-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathMakefile
More file actions
59 lines (47 loc) · 2.02 KB
/
Copy pathMakefile
File metadata and controls
59 lines (47 loc) · 2.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
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
build:
cargo build --release --workspace --bins --exclude shadow-rs
build-multicall:
cargo build --release --bin shadow-rs
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