summaryrefslogtreecommitdiffstats
path: root/src/authz.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/authz.h')
-rw-r--r--src/authz.h22
1 files changed, 17 insertions, 5 deletions
diff --git a/src/authz.h b/src/authz.h
index f9fbfa3..6665e03 100644
--- a/src/authz.h
+++ b/src/authz.h
@@ -1,14 +1,16 @@
// No regex, no fnmatch, no libgit2: a hook must not depend on anything that can
// be missing at 3am.
//
-// The exit status is the interface: 0 allowed, 1 denied, 3 no usable policy,
-// 64 usage.
+// The exit status is the interface: 0 allowed, 1 denied (this person may not),
+// 3 the host is broken and not this person (no usable policy, or input that was
+// never a push), 64 usage.
#ifndef AUTHZ_H
#define AUTHZ_H
#include <getopt.h>
#include <stddef.h>
+#include <stdio.h>
#define MAX_FIELDS 64 // one rule line, split on whitespace
#define AUTHZ_MSGSZ 512 // one complaint, in the words the caller prints
@@ -38,12 +40,20 @@ typedef struct {
int errors;
int unreadable; // the file itself could not be opened
char *path; // what messages call the file
+ FILE *log; // where the reading of the file complains: line
+ // numbers and errno, which an operator needs and a
+ // person pushing does not. NULL says nothing; the
+ // hook sets that, because its stderr is the
+ // pusher's terminal and `validate` has the detail.
} policy_t;
typedef struct {
int allowed;
level_t need; // what it cost in the end
- char why[512]; // the sentence the person pushing reads
+ char why[512]; // the sentence about the policy: what was held, the
+ // ref, what it cost and why. `check` prints it,
+ // and so does the hook under --explain; the person
+ // pushing gets one terse line instead.
} decision_t;
// glob.c --------------------------------------------------------------------
@@ -59,7 +69,8 @@ int glob_match(const char *pattern, const char *s);
void policy_init(policy_t *p, const char *path);
void policy_free(policy_t *p);
-// 0 usable, -1 errors, -2 unreadable. Errors print as they are found.
+// 0 usable, -1 errors, -2 unreadable. Errors print as they are found, to
+// p->log, which is stderr until a caller says otherwise.
int policy_load(policy_t *p);
@@ -123,7 +134,8 @@ typedef struct {
const char *ff; // "auto" (ask git), "yes", "no"
const char *head; // "auto" (ask git), "none", or a refname
int use_git; // 0 never runs git, whatever 'ff'/'head' say
- int explain; // print every verdict, not only the denials
+ int explain; // the sentence, and the allows too, not only the
+ // terse denial a pusher is given
} hook_opts;
int cmd_authorize(const policy_t *p, hook_opts o, int argc, char **argv);