aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorReyk Floeter <reyk@esdenera.com>2015-02-05 04:17:24 +0100
committerReyk Floeter <reyk@esdenera.com>2015-02-05 04:17:24 +0100
commitf8166531e6655bcd2f0514d74dd61e864a8794c3 (patch)
tree9779360761ca62ef40d2e9696b367e4d7fa5e9ea
parent1464756f1275128f9c68a9ddfe560ae952655928 (diff)
downloadhttpd-f8166531e6655bcd2f0514d74dd61e864a8794c3.tar.gz
httpd-f8166531e6655bcd2f0514d74dd61e864a8794c3.zip
sync with -current: fix includes, log remote user, fix ports by name.
-rw-r--r--config.c21
-rw-r--r--control.c9
-rw-r--r--httpd.c9
-rw-r--r--httpd.h12
-rw-r--r--log.c11
-rw-r--r--logger.c9
-rw-r--r--parse.y54
-rw-r--r--proc.c8
-rw-r--r--server.c16
-rw-r--r--server_fcgi.c16
-rw-r--r--server_file.c13
-rw-r--r--server_http.c38
12 files changed, 76 insertions, 140 deletions
diff --git a/config.c b/config.c
index 07d8e32..28fbecb 100644
--- a/config.c
+++ b/config.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: config.c,v 1.30 2015/01/19 19:37:50 reyk Exp $ */
+/* $OpenBSD: config.c,v 1.32 2015/01/21 22:21:05 reyk Exp $ */
/*
* Copyright (c) 2011 - 2015 Reyk Floeter <reyk@openbsd.org>
@@ -17,29 +17,16 @@
*/
#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/stat.h>
#include <sys/queue.h>
+#include <sys/tree.h>
+#include <sys/time.h>
#include <sys/uio.h>
-#include <net/if.h>
-#include <net/pfvar.h>
-#include <netinet/in.h>
-#include <net/route.h>
-
-#include <ctype.h>
#include <unistd.h>
-#include <err.h>
-#include <errno.h>
-#include <event.h>
-#include <limits.h>
-#include <stdint.h>
#include <stdlib.h>
-#include <stdarg.h>
#include <stdio.h>
-#include <netdb.h>
#include <string.h>
-#include <ifaddrs.h>
+#include <imsg.h>
#include "httpd.h"
diff --git a/control.c b/control.c
index a6422bc..fe60375 100644
--- a/control.c
+++ b/control.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: control.c,v 1.5 2014/12/21 00:54:49 guenther Exp $ */
+/* $OpenBSD: control.c,v 1.6 2015/01/21 22:21:05 reyk Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -16,22 +16,19 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-#include <sys/types.h>
#include <sys/queue.h>
#include <sys/stat.h>
#include <sys/socket.h>
+#include <sys/time.h>
#include <sys/un.h>
-#include <net/if.h>
-#include <arpa/inet.h>
-
#include <errno.h>
#include <event.h>
#include <fcntl.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
-#include <signal.h>
+#include <imsg.h>
#include "httpd.h"
diff --git a/httpd.c b/httpd.c
index f229cc5..5ea455e 100644
--- a/httpd.c
+++ b/httpd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: httpd.c,v 1.30 2015/01/19 19:37:50 reyk Exp $ */
+/* $OpenBSD: httpd.c,v 1.31 2015/01/21 22:21:05 reyk Exp $ */
/*
* Copyright (c) 2014 Reyk Floeter <reyk@openbsd.org>
@@ -23,16 +23,15 @@
#include <sys/stat.h>
#include <sys/wait.h>
#include <sys/resource.h>
-#include <sys/signal.h>
-#include <net/if.h>
#include <netinet/in.h>
#include <arpa/inet.h>
-#include <string.h>
#include <stdio.h>
#include <stdlib.h>
-#include <fcntl.h>
+#include <stdarg.h>
+#include <string.h>
+#include <signal.h>
#include <getopt.h>
#include <fnmatch.h>
#include <err.h>
diff --git a/httpd.h b/httpd.h
index e0473cb..e1fc20e 100644
--- a/httpd.h
+++ b/httpd.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: httpd.h,v 1.70 2015/01/19 19:37:50 reyk Exp $ */
+/* $OpenBSD: httpd.h,v 1.73 2015/01/21 22:23:24 reyk Exp $ */
/*
* Copyright (c) 2006 - 2015 Reyk Floeter <reyk@openbsd.org>
@@ -21,9 +21,17 @@
#ifndef _HTTPD_H
#define _HTTPD_H
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/queue.h>
#include <sys/tree.h>
+#include <sys/time.h>
+#include <net/if.h>
+
+#include <stdarg.h>
#include <limits.h>
+#include <event.h>
#include <imsg.h>
#include <tls.h>
@@ -298,7 +306,7 @@ struct client {
int clt_fcgi_type;
int clt_fcgi_chunked;
int clt_fcgi_end;
- char *clt_fcgi_remote_user;
+ char *clt_remote_user;
struct evbuffer *clt_srvevb;
struct evbuffer *clt_log;
diff --git a/log.c b/log.c
index f086d00..a5dfc6b 100644
--- a/log.c
+++ b/log.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: log.c,v 1.4 2014/12/21 00:54:49 guenther Exp $ */
+/* $OpenBSD: log.c,v 1.5 2015/01/21 22:21:05 reyk Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -17,13 +17,8 @@
*/
#include <sys/types.h>
-#include <sys/queue.h>
#include <sys/socket.h>
-#include <sys/tree.h>
-
-#include <net/if.h>
-#include <netinet/in.h>
-#include <netinet/ip.h>
+#include <sys/time.h>
#include <errno.h>
#include <stdarg.h>
@@ -31,7 +26,7 @@
#include <stdlib.h>
#include <string.h>
#include <syslog.h>
-#include <event.h>
+#include <time.h>
#include <netdb.h>
#include <ctype.h>
diff --git a/logger.c b/logger.c
index ee21585..c7a9bc3 100644
--- a/logger.c
+++ b/logger.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: logger.c,v 1.9 2015/01/16 06:40:17 deraadt Exp $ */
+/* $OpenBSD: logger.c,v 1.10 2015/01/21 22:21:05 reyk Exp $ */
/*
* Copyright (c) 2014 Reyk Floeter <reyk@openbsd.org>
@@ -18,19 +18,16 @@
#include <sys/param.h> /* nitems */
#include <sys/types.h>
-#include <sys/socket.h>
#include <sys/queue.h>
#include <sys/uio.h>
-#include <net/if.h>
-#include <arpa/inet.h>
-
+#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
-#include <event.h>
+#include <imsg.h>
#include "httpd.h"
diff --git a/parse.y b/parse.y
index 1b48940..d613efd 100644
--- a/parse.y
+++ b/parse.y
@@ -1,4 +1,4 @@
-/* $OpenBSD: parse.y,v 1.56 2015/01/19 19:37:50 reyk Exp $ */
+/* $OpenBSD: parse.y,v 1.59 2015/01/29 08:52:52 reyk Exp $ */
/*
* Copyright (c) 2007 - 2015 Reyk Floeter <reyk@openbsd.org>
@@ -29,19 +29,19 @@
#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/queue.h>
+#include <sys/tree.h>
#include <sys/ioctl.h>
+#include <sys/sockio.h>
+#include <sys/time.h>
#include <net/if.h>
-#include <net/pfvar.h>
#include <netinet/in.h>
#include <arpa/inet.h>
-#include <net/route.h>
#include <ctype.h>
#include <unistd.h>
#include <err.h>
#include <errno.h>
-#include <event.h>
#include <limits.h>
#include <stdint.h>
#include <stdarg.h>
@@ -369,11 +369,6 @@ serveroptsl : LISTEN ON STRING opttls port {
s_conf = alias;
} else
s_conf = &srv->srv_conf;
- if ($5.op != PF_OP_EQ) {
- yyerror("invalid port");
- free($3);
- YYERROR;
- }
TAILQ_INIT(&al);
if (host($3, &al, 1, &$5, NULL, -1) <= 0) {
@@ -901,39 +896,24 @@ medianamesl : numberstring {
}
;
-port : PORT STRING {
- char *a, *b;
- int p[2];
-
- p[0] = p[1] = 0;
-
- a = $2;
- b = strchr($2, ':');
- if (b == NULL)
- $$.op = PF_OP_EQ;
- else {
- *b++ = '\0';
- if ((p[1] = getservice(b)) == -1) {
- free($2);
- YYERROR;
- }
- $$.op = PF_OP_RRG;
- }
- if ((p[0] = getservice(a)) == -1) {
- free($2);
- YYERROR;
- }
- $$.val[0] = p[0];
- $$.val[1] = p[1];
- free($2);
- }
- | PORT NUMBER {
+port : PORT NUMBER {
if ($2 <= 0 || $2 >= (int)USHRT_MAX) {
yyerror("invalid port: %lld", $2);
YYERROR;
}
$$.val[0] = htons($2);
- $$.op = PF_OP_EQ;
+ }
+ | PORT STRING {
+ int val;
+
+ if ((val = getservice($2)) == -1) {
+ yyerror("invalid port: %s", $2);
+ free($2);
+ YYERROR;
+ }
+ free($2);
+
+ $$.val[0] = val;
}
;
diff --git a/proc.c b/proc.c
index 95c3e98..34d65c0 100644
--- a/proc.c
+++ b/proc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: proc.c,v 1.7 2014/12/21 00:54:49 guenther Exp $ */
+/* $OpenBSD: proc.c,v 1.8 2015/01/21 22:21:05 reyk Exp $ */
/*
* Copyright (c) 2010 - 2014 Reyk Floeter <reyk@openbsd.org>
@@ -21,11 +21,6 @@
#include <sys/queue.h>
#include <sys/socket.h>
#include <sys/wait.h>
-#include <sys/tree.h>
-
-#include <net/if.h>
-#include <netinet/in.h>
-#include <netinet/ip.h>
#include <stdio.h>
#include <stdlib.h>
@@ -35,6 +30,7 @@
#include <signal.h>
#include <pwd.h>
#include <event.h>
+#include <imsg.h>
#include "httpd.h"
diff --git a/server.c b/server.c
index dfaa15c..15e1453 100644
--- a/server.c
+++ b/server.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: server.c,v 1.53 2015/01/19 19:37:50 reyk Exp $ */
+/* $OpenBSD: server.c,v 1.54 2015/01/21 22:21:05 reyk Exp $ */
/*
* Copyright (c) 2006 - 2015 Reyk Floeter <reyk@openbsd.org>
@@ -22,26 +22,24 @@
#include <sys/time.h>
#include <sys/stat.h>
#include <sys/socket.h>
-#include <sys/un.h>
#include <sys/uio.h>
#include <sys/tree.h>
-#include <net/if.h>
#include <netinet/in.h>
-#include <netinet/ip.h>
#include <netinet/tcp.h>
+#include <arpa/inet.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdarg.h>
+#include <limits.h>
#include <errno.h>
#include <fcntl.h>
-#include <stdlib.h>
#include <string.h>
#include <syslog.h>
#include <unistd.h>
-#include <stdio.h>
-#include <err.h>
-#include <pwd.h>
#include <event.h>
-#include <fnmatch.h>
+#include <imsg.h>
#include <tls.h>
#include "httpd.h"
diff --git a/server_fcgi.c b/server_fcgi.c
index 8ae1f2f..563ffe5 100644
--- a/server_fcgi.c
+++ b/server_fcgi.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: server_fcgi.c,v 1.48 2015/01/19 19:37:50 reyk Exp $ */
+/* $OpenBSD: server_fcgi.c,v 1.51 2015/01/21 22:23:24 reyk Exp $ */
/*
* Copyright (c) 2014 Florian Obser <florian@openbsd.org>
@@ -17,26 +17,20 @@
*/
#include <sys/types.h>
-#include <sys/queue.h>
#include <sys/time.h>
-#include <sys/stat.h>
#include <sys/socket.h>
#include <sys/un.h>
-#include <sys/tree.h>
-#include <net/if.h>
#include <netinet/in.h>
-#include <netinet/ip.h>
-#include <netinet/tcp.h>
+#include <arpa/inet.h>
+#include <limits.h>
#include <errno.h>
-#include <fcntl.h>
#include <stdlib.h>
#include <string.h>
-#include <unistd.h>
#include <stdio.h>
+#include <time.h>
#include <ctype.h>
-#include <err.h>
#include <event.h>
#include "httpd.h"
@@ -261,7 +255,7 @@ server_fcgi(struct httpd *env, struct client *clt)
if (srv_conf->flags & SRVFLAG_AUTH) {
if (fcgi_add_param(&param, "REMOTE_USER",
- clt->clt_fcgi_remote_user, clt) == -1) {
+ clt->clt_remote_user, clt) == -1) {
errstr = "failed to encode param";
goto fail;
}
diff --git a/server_file.c b/server_file.c
index 447a0dd..2add01e 100644
--- a/server_file.c
+++ b/server_file.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: server_file.c,v 1.47 2015/01/16 06:40:17 deraadt Exp $ */
+/* $OpenBSD: server_file.c,v 1.48 2015/01/21 22:21:05 reyk Exp $ */
/*
* Copyright (c) 2006 - 2015 Reyk Floeter <reyk@openbsd.org>
@@ -17,18 +17,10 @@
*/
#include <sys/types.h>
-#include <sys/queue.h>
#include <sys/time.h>
#include <sys/stat.h>
-#include <sys/socket.h>
-#include <sys/un.h>
-#include <sys/tree.h>
-
-#include <net/if.h>
-#include <netinet/in.h>
-#include <netinet/ip.h>
-#include <netinet/tcp.h>
+#include <limits.h>
#include <errno.h>
#include <fcntl.h>
#include <stdlib.h>
@@ -37,7 +29,6 @@
#include <stdio.h>
#include <dirent.h>
#include <time.h>
-#include <err.h>
#include <event.h>
#include "httpd.h"
diff --git a/server_http.c b/server_http.c
index 99b6175..1a48b4a 100644
--- a/server_http.c
+++ b/server_http.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: server_http.c,v 1.66 2015/01/19 19:37:50 reyk Exp $ */
+/* $OpenBSD: server_http.c,v 1.69 2015/01/21 22:21:05 reyk Exp $ */
/*
* Copyright (c) 2006 - 2015 Reyk Floeter <reyk@openbsd.org>
@@ -18,28 +18,20 @@
#include <sys/types.h>
#include <sys/queue.h>
-#include <sys/time.h>
-#include <sys/stat.h>
#include <sys/socket.h>
-#include <sys/un.h>
#include <sys/tree.h>
-#include <net/if.h>
#include <netinet/in.h>
-#include <netinet/ip.h>
-#include <netinet/tcp.h>
+#include <arpa/inet.h>
#include <errno.h>
-#include <fcntl.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <limits.h>
#include <stdio.h>
-#include <err.h>
-#include <pwd.h>
+#include <time.h>
#include <resolv.h>
-#include <syslog.h>
#include <event.h>
#include <fnmatch.h>
@@ -163,6 +155,8 @@ server_http_authenticate(struct server_config *srv_conf, struct client *clt)
clt_user = decoded;
*clt_pass++ = '\0';
+ if ((clt->clt_remote_user = strdup(clt_user)) == NULL)
+ goto done;
if (clt_pass == NULL)
goto done;
@@ -190,9 +184,7 @@ server_http_authenticate(struct server_config *srv_conf, struct client *clt)
if (crypt_checkpass(clt_pass, pass) == 0) {
explicit_bzero(line, linelen);
- clt->clt_fcgi_remote_user = strdup(clt_user);
- if (clt->clt_fcgi_remote_user != NULL)
- ret = 0;
+ ret = 0;
break;
}
}
@@ -631,8 +623,8 @@ server_reset_http(struct client *clt)
clt->clt_line = 0;
clt->clt_done = 0;
clt->clt_chunk = 0;
- free(clt->clt_fcgi_remote_user);
- clt->clt_fcgi_remote_user = NULL;
+ free(clt->clt_remote_user);
+ clt->clt_remote_user = NULL;
clt->clt_bev->readcb = server_read_http;
clt->clt_srv_conf = &srv->srv_conf;
@@ -853,8 +845,8 @@ server_close_http(struct client *clt)
server_httpdesc_free(desc);
free(desc);
clt->clt_descresp = NULL;
- free(clt->clt_fcgi_remote_user);
- clt->clt_fcgi_remote_user = NULL;
+ free(clt->clt_remote_user);
+ clt->clt_remote_user = NULL;
}
int
@@ -1266,8 +1258,9 @@ server_log_http(struct client *clt, u_int code, size_t len)
switch (srv_conf->logformat) {
case LOG_FORMAT_COMMON:
if (evbuffer_add_printf(clt->clt_log,
- "%s %s - - [%s] \"%s %s%s%s%s%s\" %03d %zu\n",
- srv_conf->name, ip, tstamp,
+ "%s %s - %s [%s] \"%s %s%s%s%s%s\" %03d %zu\n",
+ srv_conf->name, ip, clt->clt_remote_user == NULL ? "-" :
+ clt->clt_remote_user, tstamp,
server_httpmethod_byid(desc->http_method),
desc->http_path == NULL ? "" : desc->http_path,
desc->http_query == NULL ? "" : "?",
@@ -1290,8 +1283,9 @@ server_log_http(struct client *clt, u_int code, size_t len)
agent = NULL;
if (evbuffer_add_printf(clt->clt_log,
- "%s %s - - [%s] \"%s %s%s%s%s%s\" %03d %zu \"%s\" \"%s\"\n",
- srv_conf->name, ip, tstamp,
+ "%s %s - %s [%s] \"%s %s%s%s%s%s\" %03d %zu \"%s\" \"%s\"\n",
+ srv_conf->name, ip, clt->clt_remote_user == NULL ? "-" :
+ clt->clt_remote_user, tstamp,
server_httpmethod_byid(desc->http_method),
desc->http_path == NULL ? "" : desc->http_path,
desc->http_query == NULL ? "" : "?",