summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* A refusal names the level held on the ref in questiondev2026-11-134-20/+79
| | | | | | | | | | | | | | | | | | | | | | "carol has force on team; refs/heads/main needs force", said while refusing carol a force push to main, is a sentence nobody can act on: her force is on refs/heads/feature/*, and the message reported the strongest level she holds somewhere in the repository rather than the one she holds on the ref that was refused. scope() now records both, and the refusal uses the level that covers the ref, with a separate sentence for the case where nothing covers it at all - "a rule for team but nothing on this ref" is a different problem from "not enough for this ref", and the person pushing cannot tell them apart without reading the file the way the matcher does. Also: a policy that could not be opened is remembered (unreadable), so validate reports "every push is denied until it is mounted" instead of announcing that an empty policy is in force, and /etc/passwd is split by its seven fields rather than eight - the old loop marked the colons as the fields and so never found the git account at all, which meant a login shell for git passed validation. Both were found by driving the binary the way a receive hook is driven; that suite is in a later commit of this series.
* git-authz: one C program for who may move which refsdev2026-11-1312-0/+3371
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.