commit 7554713a026de839e0b958d7885d5d1286b3f547 from: Stefan Sperling via: Thomas Adam date: Sat Apr 01 21:36:53 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 - 44e35bfc5d79729b628868aacb8e88ad5ab5bd46 commit + 7554713a026de839e0b958d7885d5d1286b3f547 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 - 03330557daded8509dfcf83418c94ef591139516 blob + 04d2d6c654a526a45e5fc7661da7c4d82aff89f1 --- gotd/gotd.c +++ gotd/gotd.c @@ -1749,7 +1749,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 - d60e420a5de39ef5683b29c27c5452b1f04a464c blob + 715588536b23a7e19527bba5a45c58c043647d7e --- gotd/parse.y +++ gotd/parse.y @@ -56,7 +56,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); @@ -624,7 +624,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; @@ -641,7 +641,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); @@ -666,7 +667,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; @@ -692,9 +693,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;