Index | Thread | Search

From:
"Carsten Reith" <carsten.reith@t-online.de>
Subject:
Re: diff httpd: avoid misleading syslog warnings
To:
Claudio Jeker <cjeker@diehard.n-r-g.com>, tech@openbsd.org
Date:
Tue, 13 Feb 2024 14:58:58 +0100

Download raw body.

Thread
  • Theo de Raadt:

    diff httpd: avoid misleading syslog warnings

  • On Tue, Feb 13, 2024 at 02:46:36PM +0100, Claudio Jeker wrote:
    > I guess it would be better to only call log_warn() if the errno is not
    > ENOENT. That should be enough to silence the common case.
    > 
    > -- 
    > :wq Claudio
    > 
    > Index: server_http.c
    > ===================================================================
    > RCS file: /cvs/src/usr.sbin/httpd/server_http.c,v
    > diff -u -p -r1.153 server_http.c
    > --- server_http.c	21 Sep 2022 05:55:18 -0000	1.153
    > +++ server_http.c	13 Feb 2024 13:45:26 -0000
    > @@ -1762,13 +1762,14 @@ read_errdoc(const char *root, const char
    >  	struct stat	 sb;
    >  	char		*path;
    >  	int		 fd;
    > -	char		*ret = NULL;
    > +	char		*ret;
    >  
    >  	if (asprintf(&path, "%s/%s.html", root, file) == -1)
    >  		fatal("asprintf");
    >  	if ((fd = open(path, O_RDONLY)) == -1) {
    >  		free(path);
    > -		log_warn("%s: open", __func__);
    > +		if (errno != ENOENT)
    > +			log_warn("%s: open", __func__);
    >  		return (NULL);
    >  	}
    >  	free(path);
    > @@ -1788,8 +1789,7 @@ read_errdoc(const char *root, const char
    >  		log_warn("%s: read", __func__);
    >  		close(fd);
    >  		free(ret);
    > -		ret = NULL;
    > -		return (ret);
    > +		return (NULL);
    >  	}
    >  	close(fd);
    >  
    >
    
    That's much better, thank you.
    
    
    
  • Theo de Raadt:

    diff httpd: avoid misleading syslog warnings