commit e9e0377f452e9d3f600011e0714cc6c779f10bab from: Stefan Sperling date: Wed Mar 29 13:30:59 2023 UTC avoid gitwrapper printing a warning when /etc/gotd.conf does not exist gotd still requires the config file, of course, but gitwrapper must treat is as optional and remain silent if the file cannot be found. commit - c5d17ec881b7f4c35f151faa9d30ac436d812dc3 commit + e9e0377f452e9d3f600011e0714cc6c779f10bab blob - aac808b4b78aea1e1c1e43492f46a8fd7ff4495f blob + 61404820c89b2b713cc2e51739b6221e9ab104c1 --- gitwrapper/gitwrapper.c +++ gitwrapper/gitwrapper.c @@ -130,7 +130,7 @@ main(int argc, char *argv[]) confpath = getenv("GOTD_CONF_PATH"); if (confpath == NULL) confpath = GOTD_CONF_PATH; - parse_config(confpath, PROC_GOTD, &gotd); + parse_config(confpath, PROC_GOTD, &gotd, 0); error = apply_unveil(myserver); if (error) blob - c7a273204feec2eff188ea2e2530aa3c3d833253 blob + 794c48b1569cbd4214a7d34d9e2e81ac05ff789c --- gotd/gotd.c +++ gotd/gotd.c @@ -1752,7 +1752,7 @@ main(int argc, char **argv) if (geteuid() && (proc_id == PROC_GOTD || proc_id == PROC_LISTEN)) fatalx("need root privileges"); - if (parse_config(confpath, proc_id, &gotd) != 0) + if (parse_config(confpath, proc_id, &gotd, 1) != 0) return 1; pw = getpwnam(gotd.user_name); blob - 63cffc677d842269d09d3f07a3cc61bdf1e6c28b blob + 1f9b40a97a0e8ed68f190efc0abc407e5fbc5fde --- gotd/gotd.h +++ gotd/gotd.h @@ -446,7 +446,7 @@ struct gotd_imsg_auth { uint32_t client_id; }; -int parse_config(const char *, enum gotd_procid, struct gotd *); +int parse_config(const char *, enum gotd_procid, struct gotd *, int); struct gotd_repo *gotd_find_repo_by_name(const char *, struct gotd *); /* imsg.c */ blob - 9a5b91d273ade58fbf2195742c6bf0866eb7ac69 blob + b7d7e708dc1650571a862cb8f93f26798d1f1037 --- gotd/parse.y +++ gotd/parse.y @@ -58,7 +58,7 @@ static struct file { int lineno; int errors; } *file; -struct file *newfile(const char *, int); +struct file *newfile(const char *, int, int); static void closefile(struct file *); int check_file_secrecy(int, const char *); int yyparse(void); @@ -626,7 +626,7 @@ check_file_secrecy(int fd, const char *fname) } struct file * -newfile(const char *name, int secret) +newfile(const char *name, int secret, int required) { struct file *nfile; @@ -643,7 +643,8 @@ newfile(const char *name, int secret) } nfile->stream = fopen(nfile->name, "r"); if (nfile->stream == NULL) { - log_warn("open %s", nfile->name); + if (required) + log_warn("open %s", nfile->name); free(nfile->name); free(nfile); return (NULL); @@ -668,7 +669,7 @@ closefile(struct file *xfile) int parse_config(const char *filename, enum gotd_procid proc_id, - struct gotd *env) + struct gotd *env, int require_config_file) { struct sym *sym, *next; struct gotd_repo *repo; @@ -694,9 +695,9 @@ parse_config(const char *filename, enum gotd_procid pr gotd->request_timeout.tv_sec = GOTD_DEFAULT_REQUEST_TIMEOUT; gotd->request_timeout.tv_usec = 0; - file = newfile(filename, 0); + file = newfile(filename, 0, require_config_file); if (file == NULL) - return -1; + return require_config_file ? -1 : 0; yyparse(); errors = file->errors;