commit 9f849004c3ccccaa18bb815a7a21e13b7606d161 from: Stefan Sperling via: Thomas Adam date: Sat Aug 06 20:57:41 2022 UTC make gotwebd start up without a config file ok tracey commit - 15be8247b968c9b2207351c3d4227835a45acc3c commit + 9f849004c3ccccaa18bb815a7a21e13b7606d161 blob - 283b66d78660ef036a7c9e31cd7923e69844dbe3 blob + eac39b8465707782b70f9dae8bcc409643b2dd57 --- gotwebd/parse.y +++ gotwebd/parse.y @@ -814,20 +814,30 @@ closefile(struct file *xfile) free(xfile); } +static void +add_default_server(void) +{ + new_srv = conf_new_server(D_SITENAME); + log_debug("%s: adding default server %s", __func__, D_SITENAME); +} + int parse_config(const char *filename, struct gotwebd *env) { struct sym *sym, *next; - file = newfile(filename, 0); - if (file == NULL) - /* just return, as we don't require a conf file */ - return (0); - if (config_init(env) == -1) fatalx("failed to initialize configuration"); gotwebd = env; + + file = newfile(filename, 0); + if (file == NULL) { + add_default_server(); + sockets_parse_sockets(env); + /* just return, as we don't require a conf file */ + return (0); + } yyparse(); errors = file->errors; @@ -850,10 +860,8 @@ parse_config(const char *filename, struct gotwebd *env return (-1); /* just add default server if no config specified */ - if (gotwebd->server_cnt == 0) { - new_srv = conf_new_server(D_SITENAME); - log_debug("%s: adding default server %s", __func__, D_SITENAME); - } + if (gotwebd->server_cnt == 0) + add_default_server(); /* setup our listening sockets */ sockets_parse_sockets(env);