commit abe844e2dfc7056150889993b3568fe400af7358 from: Omar Polo date: Wed Jan 18 09:30:04 2023 UTC gotd: move socket path check to parse.y and error from the main process It's handy to have a "bad unix socket path" error being reported directly from the main process since can get caught by `gotd -n'. ok jamsek stsp commit - 809a54db7c7cec54dcacb53f62eedecc18a833da commit + abe844e2dfc7056150889993b3568fe400af7358 blob - 496a69548f10498a0a5ac85226976ec04339b121 blob + bbef698cd852eda07d51755cb924554e0f98b3c2 --- gotd/gotd.c +++ gotd/gotd.c @@ -1771,11 +1771,6 @@ main(int argc, char **argv) if (pw->pw_uid == 0) fatalx("cannot run %s as the superuser", getprogname()); - if (proc_id == PROC_LISTEN && - !got_path_is_absolute(gotd.unix_socket_path)) - fatalx("bad unix socket path \"%s\": must be an absolute path", - gotd.unix_socket_path); - if (noaction) { fprintf(stderr, "configuration OK\n"); return 0; blob - 8a904e018947db197de77329a4c68cc09742e7f2 blob + 51cf2780d3077e2b6c6f8202d840cfe73f46b425 --- gotd/parse.y +++ gotd/parse.y @@ -195,6 +195,10 @@ timeout : NUMBER { ; main : LISTEN ON STRING { + if (!got_path_is_absolute($3)) + yyerror("bad unix socket path \"%s\": " + "must be an absolute path", $3); + if (gotd_proc_id == PROC_LISTEN) { if (strlcpy(gotd->unix_socket_path, $3, sizeof(gotd->unix_socket_path)) >=