summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordev <dev@example>2026-11-15 11:32:51 +0000
committerdev <dev@example>2026-11-15 11:32:51 +0000
commit2e6dd4a8e9e5302efae6b7532f7f4609882fc21d (patch)
treebcf0ce30538dbea33156ec98da8fd8cfe0d0679e
parentc2b95afc6aefbab69133a202cab95a50a2df82fc (diff)
downloadaccess-control-2e6dd4a8e9e5302efae6b7532f7f4609882fc21d.tar.gz
access-control-2e6dd4a8e9e5302efae6b7532f7f4609882fc21d.zip
Three things the removal left behind
The shipped example policy still told operators that `git-authz grant` and `revoke` edit a source copy. Both exit 64 now, so the header says why the deployed copy is read-only instead - the hook must not be able to change who can push - and stops short of naming a command that no longer exists. container/git-host-key made the same claim from the other side: that `validate` cross-checks keys and the rest of the wiring. It does not any more. The text now says what git-host-key itself guarantees, the option prefix it writes onto each key, and what it does not: a key edited in by hand can still lose the identity, and the name still needs a rule. sb_init/sb_add/sb_addf/sb_free and strbuf_t were orphaned when edit.c went - nothing else ever built a string buffer - so they are gone, with the stdarg.h include that only sb_addf needed. 64 lines. src/ and cmd/ are 1,431 non-blank lines. make strict, make test and make sanitizer are clean, sanitizers silent, and the example policy still parses to its 7 rules.
-rw-r--r--authz.conf7
-rwxr-xr-xcontainer/git-host-key7
-rw-r--r--src/authz.h13
-rw-r--r--src/util.c60
4 files changed, 8 insertions, 79 deletions
diff --git a/authz.conf b/authz.conf
index 7881329..f9dfba9 100644
--- a/authz.conf
+++ b/authz.conf
@@ -1,9 +1,10 @@
# git-host access policy.
#
# One file, read by the receive hook on every push and by nothing that serves
-# reads. The deployed copy is mounted read-only - a ConfigMap - so changes are
-# made to the copy in git and rolled out; `git-authz grant` and `revoke` edit a
-# source copy and refuse, with an explanation, when pointed at the read-only one.
+# reads. The deployed copy is mounted read-only - a ConfigMap - on purpose: the
+# hook must not be able to change who can push, and neither must whatever else
+# runs as the git account. Edit the copy in git and roll the ConfigMap that
+# provides it.
#
# <user> <repo> <write|force|admin> [ <ref pattern> ... ]
#
diff --git a/container/git-host-key b/container/git-host-key
index 10d8131..4c7c2dc 100755
--- a/container/git-host-key
+++ b/container/git-host-key
@@ -23,9 +23,10 @@ Usage:
git-host-key list user, fingerprint and comment per key
git-host-key rm <user> remove every key of <user>
-Keys are cross-checked by 'git-authz validate', which also checks the rest of
-the wiring: identity-less keys, keys pinned somewhere other than git-shell, and
-identities with no policy rule.
+Each key is written with the option prefix above, so a push made with one arrives
+named rather than anonymous. Nothing re-checks that afterwards: a key edited in
+by hand can lose the identity option, and the name a key carries still needs a
+rule in the policy file.
Files:
GIT_HOST_AUTHORIZED_KEYS authoritative file (default /etc/git-host/secrets/authorized_keys)
diff --git a/src/authz.h b/src/authz.h
index ad39b35..f9fbfa3 100644
--- a/src/authz.h
+++ b/src/authz.h
@@ -138,14 +138,6 @@ int cmd_validate(const policy_t *p, validate_opts o);
// util.c --------------------------------------------------------------------
-// A growing string. strncat with hand-computed room is how buffer bugs are
-// born.
-typedef struct {
- char *s; // never NULL once sb_init has run
- size_t len;
- size_t cap;
-} strbuf_t;
-
// A file, one entry per line. The newline is kept, and a last line without one
// is given one, so the lines may be written straight back out again.
typedef struct {
@@ -164,11 +156,6 @@ void lines_free(lines_t *l);
// nothing at all for a file that is optional here.
int authz_read_lines(const char *path, lines_t *l);
-void sb_init(strbuf_t *b);
-void sb_add(strbuf_t *b, const char *s);
-void sb_addf(strbuf_t *b, const char *fmt, ...);
-void sb_free(strbuf_t *b);
-
void *xmalloc(size_t n);
void *xrealloc(void *p, size_t n);
char *xstrdup(const char *s);
diff --git a/src/util.c b/src/util.c
index 1cebd39..e769238 100644
--- a/src/util.c
+++ b/src/util.c
@@ -3,7 +3,6 @@
// somewhere a caller forgot to look.
#include "authz.h"
-#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -17,65 +16,6 @@ static void oom(void)
exit(3);
}
-void sb_init(strbuf_t *b)
-{
- b->cap = 64;
- b->len = 0;
- b->s = xmalloc(b->cap);
- b->s[0] = '\0';
-}
-
-static void sb_room(strbuf_t *b, size_t extra)
-{
- if (b->len + extra + 1 <= b->cap)
- return;
- while (b->len + extra + 1 > b->cap)
- b->cap *= 2;
- b->s = xrealloc(b->s, b->cap);
-}
-
-void sb_add(strbuf_t *b, const char *s)
-{
- size_t n;
-
- if (s == NULL)
- return;
- n = strlen(s);
- sb_room(b, n);
- memcpy(b->s + b->len, s, n + 1);
- b->len += n;
-}
-
-void sb_addf(strbuf_t *b, const char *fmt, ...)
-{
- va_list ap;
- int n;
- char *out;
-
- va_start(ap, fmt);
- n = vsnprintf(NULL, 0, fmt, ap);
- va_end(ap);
- if (n < 0)
- return;
- sb_room(b, (size_t)n);
- va_start(ap, fmt);
- out = b->s + b->len;
- n = vsnprintf(out, b->cap - b->len, fmt, ap);
- va_end(ap);
- if (n < 0) {
- b->s[b->len] = '\0';
- return;
- }
- b->len += (size_t)n;
-}
-
-void sb_free(strbuf_t *b)
-{
- free(b->s);
- b->s = NULL;
- b->len = b->cap = 0;
-}
-
void *xmalloc(size_t n)
{
void *p = malloc(n != 0 ? n : 1);