mirror of https://github.com/omar-polo/gmid.git
parse_conf: don't die on error, return -1
this avoids having the daemon dieing on SIGHUP with a bad config file.
This commit is contained in:
parent
af1dab1870
commit
68368f4c29
9
gmid.c
9
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);
|
||||
}
|
||||
|
|
2
gmid.h
2
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 *);
|
||||
|
||||
|
|
7
parse.y
7
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
|
||||
|
|
Loading…
Reference in New Issue