diff options
-rw-r--r-- | gmid.c | 9 | ||||
-rw-r--r-- | gmid.h | 2 | ||||
-rw-r--r-- | parse.y | 7 |
3 files changed, 12 insertions, 6 deletions
@@ -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); } @@ -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 *); @@ -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 |