From 312ddd4936f09ae27a180ca495cacf2c06faf33e Mon Sep 17 00:00:00 2001 From: dev Date: Sat, 14 Nov 2026 01:05:08 +0000 Subject: Comments: cut to what the code cannot say 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. --- container/entrypoint.sh | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'container/entrypoint.sh') diff --git a/container/entrypoint.sh b/container/entrypoint.sh index e82ae4f..df33b47 100755 --- a/container/entrypoint.sh +++ b/container/entrypoint.sh @@ -16,9 +16,9 @@ need_secret() { # [mode] [owner-group] chmod "$mode" "$SECRETS_DIR/$name" } -# Copy the secrets to /run and fix their modes. Mounted secrets arrive with -# whatever mode the volume plugin chose, and sshd refuses keys that are too -# loose while lighttpd must be able to read htpasswd as the git user. +# Mounted secrets arrive with whatever mode the volume plugin chose. sshd refuses +# keys that are too loose; lighttpd must read htpasswd as the git user. + mkdir -p "$SECRETS_DIR" need_secret authorized_keys 0640 git need_secret htpasswd 0640 git @@ -28,15 +28,14 @@ need_secret ssh_host_rsa_key need_secret ssh_host_rsa_key.pub 0644 chmod 0755 /run/git-host "$SECRETS_DIR" -# One hook for every repository. This is the single most important line in the -# container: without it a repository carries no policy and pushes go unchecked. -# The policy file itself stays wherever it is mounted; it is never copied, so a -# ConfigMap update takes effect on the next push with no restart. +# The single most important line in the container: without it a repository carries +# no policy and pushes go unchecked. The policy is never copied, so a ConfigMap +# update takes effect on the next push. + git config --file /etc/gitconfig core.hooksPath "${GIT_HOST_HOOK_DIR:-/usr/local/share/git-host/hooks}" -# Fail rather than serve a host that cannot enforce anything. A policy that -# does not parse is only a warning inside validate: reads keep working and -# pushes are denied, which is the correct direction for a mistake to fall in. +# Do not serve a host that cannot enforce anything. + git-authz validate /usr/sbin/sshd -D -e -f /etc/ssh/sshd_config & -- cgit v1.2.3