summaryrefslogtreecommitdiffstats
path: root/src/validate.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/validate.c')
-rw-r--r--src/validate.c23
1 files changed, 17 insertions, 6 deletions
diff --git a/src/validate.c b/src/validate.c
index fd8abb9..ab8348c 100644
--- a/src/validate.c
+++ b/src/validate.c
@@ -303,22 +303,28 @@ static void check_account(const policy_t *p, validate_opts o)
return;
}
while ((len = getline(&line, &cap, f)) != -1) {
- char *fields[9];
+ char *fields[8];
int nf = 0;
char *q = line;
+ /* name:password:uid:gid:gecos:home:shell - the seventh field decides
+ * whether a key can open a shell at all. */
while (*q != '\0') {
+ char *start = q;
+
while (*q != '\0' && *q != ':')
q++;
- fields[nf++] = q;
- if (*q == '\0')
+ if (*q == '\0') {
+ fields[nf++] = start;
break;
+ }
*q++ = '\0';
- if (nf == 8)
+ fields[nf++] = start;
+ if (nf == 7)
break;
}
- if (nf == 8 && strcmp(fields[0], "git") == 0) {
- char *shell = strip(fields[7]);
+ if (nf >= 7 && strcmp(fields[0], "git") == 0) {
+ char *shell = strip(fields[6]);
found = 1;
if (strstr(shell, "git-shell") == NULL)
@@ -440,6 +446,11 @@ int cmd_validate(const policy_t *p, validate_opts o)
/* Anything the parser already complained about went to stderr with its line
* number. A policy with errors is not used at all, so nothing else here
* matters until it is fixed. */
+ if (p->unreadable) {
+ verr("%s cannot be read: the hook fails closed on this, so every push is "
+ "denied until it is mounted", p->path);
+ return 3;
+ }
if (p->errors > 0) {
verr("%s: %d error(s): the policy is not used, and every push is denied",
p->path, p->errors);