On Sat, Feb 10, 2024 at 06:21:03PM -0500, J Doe wrote: > > In /var/www I have created: > > /err root:daemon chmod 0755 > > Within /var/www/err I have created: > > err.html www:www chmod 0444 > > In my httpd.conf I have a global configuration that points to this: > > /etc/httpd.conf > . . . > errdocs "/err" > > When I cause an error with httpd, the error document template I have > created gets rendered to the client, but I get entries in syslog like > the following: > > serv1 httpd[23368]: read_errdoc: open: No such file or directory > > This also happens if a create a copy of err.html and name it 404.html. > > How can I modify my configuration to stop the: read_errdoc entries in > syslog ? > > Thanks, > > - J >
This is not a configuration error. The following line in server_http.c cause the problem: if ((body = read_errdoc(srv_conf->errdocroot, cstr)) == NULL && (body = read_errdoc(srv_conf->errdocroot, HTTPD_ERRDOCTEMPLATE) == NULL) The read_errdoc function tries to open the file (<code>.html first, then err.html) and writes the syslog message, if the file can't be found. I attach a diff, which fixes the issue for me. This is the first diff I submit, so anybody with more experience is welcome to improve or reject it. Index: server_http.c =================================================================== RCS file: /cvs/src/usr.sbin/httpd/server_http.c,v retrieving revision 1.153 diff -u -p -u -p -r1.153 server_http.c --- server_http.c 21 Sep 2022 05:55:18 -0000 1.153 +++ server_http.c 11 Feb 2024 12:11:27 -0000 @@ -893,6 +893,7 @@ server_abort_http(struct client *clt, un char buf[IBUF_READ_SIZE]; char *escapedmsg = NULL; char cstr[5]; + char *path; ssize_t bodylen; if (code == 0) { @@ -974,10 +975,21 @@ server_abort_http(struct client *clt, un if ((size_t)snprintf(cstr, sizeof(cstr), "%03u", code) >= sizeof(cstr)) goto builtin; - if ((body = read_errdoc(srv_conf->errdocroot, cstr)) == NULL && - (body = read_errdoc(srv_conf->errdocroot, HTTPD_ERRDOCTEMPLATE)) - == NULL) + if (asprintf(&path, "%s/%s.html", srv_conf->errdocroot, cstr) == -1) + fatal("asprintf"); + + if (access(path, R_OK) == 0) { + if ((body = read_errdoc(srv_conf->errdocroot, cstr)) == NULL) { + free(path); + goto builtin; + } + } + else if ((body = read_errdoc(srv_conf->errdocroot, + HTTPD_ERRDOCTEMPLATE)) == NULL) { + free(path); goto builtin; + } + free(path); body = replace_var(body, "$HTTP_ERROR", httperr); body = replace_var(body, "$RESPONSE_CODE", cstr);