summaryrefslogtreecommitdiffstats
path: root/src/authz.h
diff options
context:
space:
mode:
authordev <dev@example>2026-11-13 20:33:51 +0000
committerdev <dev@example>2026-11-13 20:34:17 +0000
commit1fd64267f678b8c6d17b2bcae702d577df1fc9e4 (patch)
tree01a7d8a235c8e78c80c511dbee8cf738f7646053 /src/authz.h
parentf87a792743227ea06cfa1580f8d30a618b4d1a04 (diff)
downloadaccess-control-1fd64267f678b8c6d17b2bcae702d577df1fc9e4.tar.gz
access-control-1fd64267f678b8c6d17b2bcae702d577df1fc9e4.zip
A refusal names the level held on the ref in question
"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.
Diffstat (limited to 'src/authz.h')
-rw-r--r--src/authz.h11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/authz.h b/src/authz.h
index 9ca0eb6..53f251d 100644
--- a/src/authz.h
+++ b/src/authz.h
@@ -56,6 +56,7 @@ typedef struct {
int errors;
int warnings;
+ int unreadable; /* the file itself could not be opened */
char *path; /* what messages call the file */
} policy_t;
@@ -178,10 +179,16 @@ typedef struct {
const char *out; /* NULL edits in place; "-" is stdout */
} edit_opts;
-/* Shared by the three editing commands: leading --out/--stdout flags, and how
- * many arguments they consumed. Returns -1 on an unknown option. */
+/* Shared by the three editing commands: pulls --out and --stdout out of the
+ * argument list wherever they sit (an option at the end reads better in a
+ * shell history) and compacts what is left into argv, returning the count in
+ * *consumed. Returns -1 on a missing value. */
int authz_parse_out(int argc, char **argv, edit_opts *o, int *consumed);
+/* A ref pattern or name that starts with "--" is a mistyped option, not
+ * something to grant. Prints and returns 1 when it finds one. */
+int authz_reject_options(int argc, char **argv);
+
int cmd_grant(const char *path, edit_opts o, int argc, char **argv);
int cmd_revoke(const char *path, edit_opts o, int argc, char **argv);
int cmd_protect(const char *path, edit_opts o, int argc, char **argv);