summaryrefslogtreecommitdiffstats
path: root/build
Commit message (Collapse)AuthorAgeFilesLines
* Comments: cut to what the code cannot saydev2026-11-141-14/+8
| | | | | | | | | | | | | | | | | | | | | | | | The comments had grown into essays. A file header explaining why the file exists, then a paragraph above each function restating what the next eight lines do, then a paragraph above that one explaining why that matters. The reader gets no further than the first paragraph, and the second is the one that goes stale: it describes code that has since changed, and nothing fails when it does. Cut by about half. What is left is the three things a comment can do that code cannot: say why the constraint exists (no regex because a hook must not depend on what might be missing at 3am), say what is not obvious from the shape (a bare ref name is a branch, never a tag; the seventh field of /etc/passwd is the shell), and say where it hurts (the NULL in an execvp array, the mode and owner that have to survive an atomic rewrite, the child that must not keep the hook's stdin). Block comments became // lines, which is also what the other C trees here use, and the file headers went to two or three lines. Section banners stayed: they are navigation, not prose. Behaviour is unchanged and the suites prove it: 171 direct checks, 162 behavioural, clean under -Werror and under ASan/UBSan.
* Install: the hook is a relative symlink, and the policy is configurationdev2026-11-131-19/+60
| | | | | | | | | | | | | | | | | | | | | | | | 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.
* git-authz: one C program for who may move which refsdev2026-11-131-0/+22
A git host that anonymous-clones and shared-pushes has one question left to answer: which human may move which ref. This answers it from one plain file, in one binary, with no runtime beyond libc. Four modes, because they must agree exactly about what a rule means - a check that answers differently from the hook is a program that lies: check one question, for an operator or a script authorize a whole push, the way core.hooksPath hands it over: identity from GIT_HOST_USER (ssh key option) or REMOTE_USER (http auth), and one "old new ref" line per ref on stdin. Also runs as "pre-receive", which is how git finds it. validate does the policy parse, and is the host wired to run it edit grant, revoke, protect (the deployed policy is a read-only mount on purpose, so these are for the source copy and say so when told) The verdict is the exit status, since the caller is a hook: 0 allowed, 1 denied, 3 no usable policy, 64 usage. A policy that cannot be read or does not parse denies everything rather than guessing, and one bad line poisons the whole file on purpose: a mistyped rule that quietly widens access is worse than an evening of refused pushes. Semantics kept from the shell engine this replaces: levels are monotone (admin implies force implies write), rules add up rather than order, "@" is only everyone the policy already names, protected refs cost one step more than the action asked for, and refs that are neither branches nor tags are for admins. "main", "heads/main" and "refs/heads/main" are one branch; a bare name is never a tag. Two facts a push does not carry - is old an ancestor of new, and which branch HEAD points at - are asked of git, and an answer that cannot be had is taken the expensive way. tests/unit.c covers the matcher directly (173 checks); the behavioural suite that drives this the way git does follows next.