aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gmid.c9
-rw-r--r--gmid.h2
-rw-r--r--parse.y7
3 files changed, 12 insertions, 6 deletions
diff --git a/gmid.c b/gmid.c
index 1a796d2..a9616eb 100644
--- a/gmid.c
+++ b/gmid.c
@@ -230,7 +230,8 @@ main(int argc, char **argv)
conf = config_new();
- parse_conf(conf, config_path);
+ if (parse_conf(conf, config_path) == -1)
+ errx(1, "failed to load configuration file");
if (*conf->chroot != '\0' && *conf->user == '\0')
fatalx("can't chroot without a user to switch to after.");
@@ -345,7 +346,11 @@ main_reload(struct conf *conf)
log_debug("%s: config file %s", __func__, config_path);
config_purge(conf);
- parse_conf(conf, config_path); /* XXX should handle error here */
+
+ if (parse_conf(conf, config_path) == -1) {
+ log_warnx("failed to parse the config");
+ return;
+ }
main_configure(conf);
}
diff --git a/gmid.h b/gmid.h
index 0e99e13..804fe93 100644
--- a/gmid.h
+++ b/gmid.h
@@ -346,7 +346,7 @@ int config_recv(struct conf *, struct imsg *);
/* parse.y */
void yyerror(const char*, ...);
-void parse_conf(struct conf *, const char*);
+int parse_conf(struct conf *, const char*);
void print_conf(void);
int cmdline_symset(char *);
diff --git a/parse.y b/parse.y
index de0405b..11d4250 100644
--- a/parse.y
+++ b/parse.y
@@ -908,7 +908,7 @@ popfile(void)
return file ? 0 : EOF;
}
-void
+int
parse_conf(struct conf *c, const char *filename)
{
struct sym *sym, *next;
@@ -917,7 +917,7 @@ parse_conf(struct conf *c, const char *filename)
file = pushfile(filename, 0);
if (file == NULL)
- exit(1);
+ return -1;
topfile = file;
yyparse();
@@ -936,7 +936,8 @@ parse_conf(struct conf *c, const char *filename)
}
if (errors)
- exit(1);
+ return -1;
+ return 0;
}
void