diff options
| author | dev <dev@example> | 2026-11-13 20:34:47 +0000 |
|---|---|---|
| committer | dev <dev@example> | 2026-11-13 20:34:47 +0000 |
| commit | 19a3eb704479fa01c383960ca21a057e8c5fbaf7 (patch) | |
| tree | 565882a47da5ced0f2112a36703a81406f9a0a69 /Makefile | |
| parent | e755a181b0e4c952c35d80e2aa1acd584d2e4595 (diff) | |
| download | access-control-19a3eb704479fa01c383960ca21a057e8c5fbaf7.tar.gz access-control-19a3eb704479fa01c383960ca21a057e8c5fbaf7.zip | |
Install: the hook is a relative symlink, and the policy is configuration
The hook is a symlink named pre-receive, because that name is what
core.hooksPath looks for and what selects authorize mode inside the binary.
It was built by cd'ing into the hook directory first, which left the awk
script writing the relative path out of reach, and the recipe failed with the
link never created. The path is computed where the script is, and the link is
made from there.
Relative rather than absolute for the reason that matters during an install: a
staged tree under DESTDIR, an unpacked prefix, or an image assembled somewhere
else must point at the binary that came with them, not at whatever lives at the
same absolute path on the machine reading the link. relpath.awk walks both
paths component by component - it is not a string-prefix operation, because
/usr/local/share and /usr/local/bin share a prefix only up to the point where
".." starts - and falls back to the absolute path when a component cannot be
named from where it stands.
authz.conf is the example policy, and the installer treats it as
configuration: an existing file is an operator's, so it is kept and the new
example lands beside it as authz.conf.new rather than over the rules someone
wrote down. `make sanitizer' builds both suites under AddressSanitizer and
UBSan, which is how the editing bugs in the previous commit were found.
Diffstat (limited to 'Makefile')
| -rw-r--r-- | Makefile | 35 |
1 files changed, 30 insertions, 5 deletions
@@ -36,6 +36,18 @@ $(PROG): $(OBJS) src/%.o: src/%.c src/authz.h $(CC) $(STD) $(WARN) $(CPPFLAGS) $(CFLAGS) -c -o $@ $< +# AddressSanitizer/UBSan build of everything, so that the behavioural suite - +# which is what actually exercises the editing code paths - runs against them: +# +# make clean && make sanitizer +# +# Leaks are checked, which is why every command frees what it read: a program +# that exits in a millisecond does not need the memory back, but it does need +# the leak report to stay empty, or the one real leak hides among forty. +sanitizer: CFLAGS := -O1 -g -fsanitize=address,undefined -fno-omit-frame-pointer +sanitizer: LDFLAGS := -fsanitize=address,undefined +sanitizer: test + # The unit test links the parts it tests, not the command line, so that a # broken argument parser cannot hide a working matcher (or the other way round). $(UNIT): tests/unit.c src/util.o src/glob.o src/policy.o @@ -47,14 +59,27 @@ test: $(PROG) $(UNIT) $(UNIT) AUTHZ=./$(PROG) sh tests/run.sh +# The hook is a symlink to the program, named 'pre-receive', because that name +# is what core.hooksPath looks for and what selects authorize mode inside the +# binary. The link is relative so that a staged install, an unpacked prefix and +# the image built from either all resolve to the binary that came with them +# rather than to whatever lives at the same absolute path on the reading side. +# +# The policy is configuration: an existing one is an operator's file, so it is +# kept and the new one arrives beside it as authz.conf.new. install: $(PROG) install -d $(DESTDIR)$(BINDIR) $(DESTDIR)$(HOOKDIR) $(DESTDIR)$(SYSCONFDIR) install -m 0755 $(PROG) $(DESTDIR)$(BINDIR)/$(PROG) - install -m 0644 authz.conf $(DESTDIR)$(SYSCONFDIR)/authz.conf - rm -f $(DESTDIR)$(HOOKDIR)/pre-receive - cd $(DESTDIR)$(HOOKDIR) && \ - ln -s "`awk -v from='$(SHAREDIR)/hooks' -v to='$(BINDIR)/$(PROG)' \ - -f build/relpath.awk`" pre-receive + @if [ -e $(DESTDIR)$(SYSCONFDIR)/authz.conf ]; then \ + install -m 0644 authz.conf $(DESTDIR)$(SYSCONFDIR)/authz.conf.new; \ + echo " kept $(DESTDIR)$(SYSCONFDIR)/authz.conf; new example is authz.conf.new"; \ + else \ + install -m 0644 authz.conf $(DESTDIR)$(SYSCONFDIR)/authz.conf; \ + fi + link=`awk -v from='$(HOOKDIR)' -v to='$(BINDIR)/$(PROG)' -f build/relpath.awk`; \ + rm -f $(DESTDIR)$(HOOKDIR)/pre-receive; \ + ln -s "$$link" $(DESTDIR)$(HOOKDIR)/pre-receive; \ + echo " $(HOOKDIR)/pre-receive -> $$link" uninstall: rm -f $(DESTDIR)$(BINDIR)/$(PROG) $(DESTDIR)$(HOOKDIR)/pre-receive |
