From 2e6dd4a8e9e5302efae6b7532f7f4609882fc21d Mon Sep 17 00:00:00 2001 From: dev Date: Sun, 15 Nov 2026 11:32:51 +0000 Subject: 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. --- src/util.c | 60 ------------------------------------------------------------ 1 file changed, 60 deletions(-) (limited to 'src/util.c') 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 #include #include #include @@ -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); -- cgit v1.2.3