summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--usr.sbin/httpd/config.c8
-rw-r--r--usr.sbin/httpd/httpd.conf.54
-rw-r--r--usr.sbin/httpd/httpd.h29
-rw-r--r--usr.sbin/httpd/parse.y11
-rw-r--r--usr.sbin/httpd/server_http.c27
5 files changed, 47 insertions, 32 deletions
diff --git a/usr.sbin/httpd/config.c b/usr.sbin/httpd/config.c
index 3d8a5e13c16..650514e2910 100644
--- a/usr.sbin/httpd/config.c
+++ b/usr.sbin/httpd/config.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: config.c,v 1.10 2014/07/31 14:18:38 reyk Exp $ */
+/* $OpenBSD: config.c,v 1.11 2014/08/02 21:21:47 doug Exp $ */
/*
* Copyright (c) 2011 - 2014 Reyk Floeter <reyk@openbsd.org>
@@ -257,6 +257,12 @@ config_getserver_config(struct httpd *env, struct server *srv,
if ((srv_conf->flags & f) == 0)
srv_conf->flags |= srv->srv_conf.flags & f;
+ f = SRVFLAG_LOG|SRVFLAG_NO_LOG;
+ if ((srv_conf->flags & f) == 0) {
+ srv_conf->flags |= srv->srv_conf.flags & f;
+ srv_conf->logformat = srv->srv_conf.logformat;
+ }
+
DPRINTF("%s: %s %d received location \"%s\", parent \"%s\"",
__func__, ps->ps_title[privsep_process], ps->ps_instance,
srv_conf->location, srv->srv_conf.name);
diff --git a/usr.sbin/httpd/httpd.conf.5 b/usr.sbin/httpd/httpd.conf.5
index 949307e6010..befeaa0f30a 100644
--- a/usr.sbin/httpd/httpd.conf.5
+++ b/usr.sbin/httpd/httpd.conf.5
@@ -1,4 +1,4 @@
-.\" $OpenBSD: httpd.conf.5,v 1.16 2014/08/02 10:24:36 reyk Exp $
+.\" $OpenBSD: httpd.conf.5,v 1.17 2014/08/02 21:21:47 doug Exp $
.\"
.\" Copyright (c) 2014 Reyk Floeter <reyk@openbsd.org>
.\"
@@ -153,7 +153,7 @@ can be
.Ar common
or
.Ar combined .
-It is similar to the Apache and nginx logging format.
+It is similar to the default Apache and nginx access log.
If not specified, the default is
.Ar common .
.It Ic root Ar directory
diff --git a/usr.sbin/httpd/httpd.h b/usr.sbin/httpd/httpd.h
index 3a387eddb7d..3b3a78e1d32 100644
--- a/usr.sbin/httpd/httpd.h
+++ b/usr.sbin/httpd/httpd.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: httpd.h,v 1.32 2014/08/02 17:05:18 florian Exp $ */
+/* $OpenBSD: httpd.h,v 1.33 2014/08/02 21:21:47 doug Exp $ */
/*
* Copyright (c) 2006 - 2014 Reyk Floeter <reyk@openbsd.org>
@@ -285,18 +285,20 @@ struct client {
};
SPLAY_HEAD(client_tree, client);
-#define SRVFLAG_INDEX 0x01
-#define SRVFLAG_NO_INDEX 0x02
-#define SRVFLAG_AUTO_INDEX 0x04
-#define SRVFLAG_NO_AUTO_INDEX 0x08
-#define SRVFLAG_PATH 0x10
-#define SRVFLAG_LOCATION 0x20
-#define SRVFLAG_FCGI 0x40
-#define SRVFLAG_NO_FCGI 0x80
+#define SRVFLAG_INDEX 0x001
+#define SRVFLAG_NO_INDEX 0x002
+#define SRVFLAG_AUTO_INDEX 0x004
+#define SRVFLAG_NO_AUTO_INDEX 0x008
+#define SRVFLAG_PATH 0x010
+#define SRVFLAG_LOCATION 0x020
+#define SRVFLAG_FCGI 0x040
+#define SRVFLAG_NO_FCGI 0x080
+#define SRVFLAG_LOG 0x100
+#define SRVFLAG_NO_LOG 0x200
#define SRVFLAG_BITS \
"\10\01INDEX\02NO_INDEX\03AUTO_INDEX\04NO_AUTO_INDEX" \
- "\05PATH\06LOCATION\07FCGI\10NO_FCGI"
+ "\05PATH\06LOCATION\07FCGI\10NO_FCGI\11LOG\12NO_LOG"
#define TCPFLAG_NODELAY 0x01
#define TCPFLAG_NNODELAY 0x02
@@ -313,9 +315,8 @@ SPLAY_HEAD(client_tree, client);
"\05SOCKET_BUFFER_SIZE\06IP_TTL\07IP_MINTTL\10NO_SPLICE"
enum log_format {
- LOG_FORMAT_NONE = -1,
- LOG_FORMAT_COMMON = 0,
- LOG_FORMAT_COMBINED,
+ LOG_FORMAT_COMMON,
+ LOG_FORMAT_COMBINED
};
struct server_config {
@@ -330,7 +331,7 @@ struct server_config {
int prefixlen;
struct timeval timeout;
- u_int8_t flags;
+ u_int16_t flags;
u_int8_t tcpflags;
int tcpbufsiz;
int tcpbacklog;
diff --git a/usr.sbin/httpd/parse.y b/usr.sbin/httpd/parse.y
index 067b603d8e4..72dd913608e 100644
--- a/usr.sbin/httpd/parse.y
+++ b/usr.sbin/httpd/parse.y
@@ -1,4 +1,4 @@
-/* $OpenBSD: parse.y,v 1.15 2014/08/01 21:59:56 reyk Exp $ */
+/* $OpenBSD: parse.y,v 1.16 2014/08/02 21:21:47 doug Exp $ */
/*
* Copyright (c) 2007 - 2014 Reyk Floeter <reyk@openbsd.org>
@@ -216,6 +216,8 @@ server : SERVER STRING {
sizeof(s->srv_conf.index));
s->srv_conf.id = ++last_server_id;
s->srv_conf.timeout.tv_sec = SERVER_TIMEOUT;
+ s->srv_conf.flags |= SRVFLAG_LOG;
+ s->srv_conf.logformat = LOG_FORMAT_COMMON;
if (last_server_id == INT_MAX) {
yyerror("too many servers defined");
@@ -438,13 +440,18 @@ dirflags : INDEX STRING {
;
logformat : LOG COMMON {
+ srv->srv_conf.flags &= ~SRVFLAG_NO_LOG;
+ srv->srv_conf.flags |= SRVFLAG_LOG;
srv->srv_conf.logformat = LOG_FORMAT_COMMON;
}
| LOG COMBINED {
+ srv->srv_conf.flags &= ~SRVFLAG_NO_LOG;
+ srv->srv_conf.flags |= SRVFLAG_LOG;
srv->srv_conf.logformat = LOG_FORMAT_COMBINED;
}
| NO LOG {
- srv->srv_conf.logformat = LOG_FORMAT_NONE;
+ srv->srv_conf.flags &= ~SRVFLAG_LOG;
+ srv->srv_conf.flags |= SRVFLAG_NO_LOG;
}
;
diff --git a/usr.sbin/httpd/server_http.c b/usr.sbin/httpd/server_http.c
index 45b7000df38..2ff454f5336 100644
--- a/usr.sbin/httpd/server_http.c
+++ b/usr.sbin/httpd/server_http.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: server_http.c,v 1.27 2014/08/01 22:24:05 reyk Exp $ */
+/* $OpenBSD: server_http.c,v 1.28 2014/08/02 21:21:47 doug Exp $ */
/*
* Copyright (c) 2006 - 2014 Reyk Floeter <reyk@openbsd.org>
@@ -971,20 +971,20 @@ server_httperror_cmp(const void *a, const void *b)
int
server_log_http(struct client *clt, u_int code, size_t len)
{
- static char tstamp[64];
- static char ip[INET6_ADDRSTRLEN];
- time_t t;
- struct tm *tm;
+ static char tstamp[64];
+ static char ip[INET6_ADDRSTRLEN];
+ time_t t;
+ struct kv key, *agent, *referrer;
+ struct tm *tm;
struct server_config *srv_conf;
struct http_descriptor *desc;
- struct kv key, *agent, *referrer;
if ((srv_conf = clt->clt_srv_conf) == NULL)
return (-1);
+ if ((srv_conf->flags & SRVFLAG_LOG) == 0)
+ return (0);
if ((desc = clt->clt_desc) == NULL)
return (-1);
- if (srv_conf->logformat == LOG_FORMAT_NONE)
- return (0);
if ((t = time(NULL)) == -1)
return (-1);
@@ -994,11 +994,11 @@ server_log_http(struct client *clt, u_int code, size_t len)
return (-1);
if (clt->clt_ss.ss_family == AF_INET) {
- struct sockaddr_in *in = (struct sockaddr_in *)&clt->clt_ss;
+ struct sockaddr_in *in = (struct sockaddr_in *)&clt->clt_ss;
if (inet_ntop(AF_INET, &in->sin_addr, ip, sizeof(ip)) == NULL)
return (-1);
} else if (clt->clt_ss.ss_family == AF_INET6) {
- struct sockaddr_in6 *in = (struct sockaddr_in6 *)&clt->clt_ss;
+ struct sockaddr_in6 *in = (struct sockaddr_in6 *)&clt->clt_ss;
if (inet_ntop(AF_INET6, &in->sin6_addr, ip, sizeof(ip)) == NULL)
return (-1);
} else
@@ -1007,6 +1007,10 @@ server_log_http(struct client *clt, u_int code, size_t len)
/*
* For details on common log format, see:
* https://httpd.apache.org/docs/current/mod/mod_log_config.html
+ *
+ * httpd's format is similar to these Apache LogFormats:
+ * "%v %h %l %u %t \"%r\" %>s %B"
+ * "%v %h %l %u %t \"%r\" %>s %B \"%{Referer}i\" \"%{User-agent}i\""
*/
switch (srv_conf->logformat) {
case LOG_FORMAT_COMMON:
@@ -1048,9 +1052,6 @@ server_log_http(struct client *clt, u_int code, size_t len)
agent == NULL ? "" : agent->kv_value) == -1)
return (-1);
break;
-
- case LOG_FORMAT_NONE:
- return (-1);
}
return (0);