Re: httpd: avoid opening log files on "no log"

2019-05-02 Thread Solene Rapenne
On Thu, May 02, 2019 at 10:36:29PM +0200, Klemens Nanni wrote:
> httpd(8) still creates/opens log files with `no log' in httpd.conf(5): 
> 
>  [no] log [option]
>  Set the specified logging options.  Logging is enabled by default
>  using the standard access and error log files, but can be changed
>  per server or location.  Use the no log directive to disable
>  logging of any requests.  Multiple options may be specified
>  within curly braces.  Valid options are:
> 
> I want to quickly serve files with nothing but a config file:
> 
>   # cat /etc/httpd.conf
>   chroot "/foo"
>   server "default" {
>   listen on "*" port www
>   no log
>   root "/"
>   }
>   # httpd -d
>   doas (k...@eru.my.domain) password:
>   startup
>   failed to open /foo/logs/access.log: No such file or directory
>   parent: failed to open log file
>   logger exiting, pid 1150
>   server exiting, pid 42968
>   server exiting, pid 51707
> 
> Diff below fixes this.
> 
> Feedback? OK?

works for me on amd64
a big YES for this!!

it doesn't even require man page change.



httpd: avoid opening log files on "no log"

2019-05-02 Thread Klemens Nanni
httpd(8) still creates/opens log files with `no log' in httpd.conf(5): 

 [no] log [option]
 Set the specified logging options.  Logging is enabled by default
 using the standard access and error log files, but can be changed
 per server or location.  Use the no log directive to disable
 logging of any requests.  Multiple options may be specified
 within curly braces.  Valid options are:

I want to quickly serve files with nothing but a config file:

# cat /etc/httpd.conf
chroot "/foo"
server "default" {
listen on "*" port www
no log
root "/"
}
# httpd -d
doas (k...@eru.my.domain) password:
startup
failed to open /foo/logs/access.log: No such file or directory
parent: failed to open log file
logger exiting, pid 1150
server exiting, pid 42968
server exiting, pid 51707

Diff below fixes this.

Feedback? OK?

Index: usr.sbin/httpd/logger.c
===
RCS file: /cvs/src/usr.sbin/httpd/logger.c,v
retrieving revision 1.21
diff -u -p -r1.21 logger.c
--- usr.sbin/httpd/logger.c 7 Feb 2018 03:28:05 -   1.21
+++ usr.sbin/httpd/logger.c 2 May 2019 20:13:04 -
@@ -197,7 +197,7 @@ logger_open(struct server *srv, struct s
 {
struct log_file *log, *logfile = NULL, *errfile = NULL;
 
-   if (srv_conf->flags & SRVFLAG_SYSLOG)
+   if (srv_conf->flags & (SRVFLAG_SYSLOG | SRVFLAG_NO_LOG))
return (0);
 
/* disassociate */