Commit Diff


commit - af1dab18702cf135aa80bf15065f73050c915347
commit + 68368f4c29e208c67724b04fd0142e233a247a2a
blob - 1a796d2268061ad537a0bf8be69a618ce59687c8
blob + a9616eb98d9527801527555652f4669f7346f1c9
--- gmid.c
+++ 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,8 +346,12 @@ 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);
 }
 
blob - 0e99e135a60502c3ccdf154fde2eb2c05e1d9e52
blob + 804fe9311ff4370bf49949bb994ad9f991224747
--- gmid.h
+++ 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 *);
 
blob - de0405b9c92b72911abcfbe7bf85806d153eb714
blob + 11d4250da12f95f67ac51634d203258c9c172c5d
--- parse.y
+++ 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