summaryrefslogtreecommitdiff
path: root/usr.sbin/httpd/server.c
AgeCommit message (Collapse)Author
2016-11-17Check the return value of tls_config_set_protocols(), now that it returnsJoel Sing
an int.
2016-11-17Move OCSP loading into a separate function - it is not part of the keypairJoel Sing
and this way we can give a separate specific error message. ok beck@ reyk@
2016-11-10Fix tcp ip ttl / minttl on IPv6 sockets.Jeremie Courreges-Anglas
ok florian@
2016-11-06conditionalize ocsp load properlyBob Beck
ok jsing@
2016-11-06Add OCSP stapling support to httpdBob Beck
ok jsing@ bcook@
2016-08-30Kill (remove) the ps_pid from privsep struct since it is not being usedRafael Zalamena
anymore. Also fix the process initialization prototypes. ok reyk@
2016-08-27Kill p_instance from proc.c and remove static proc_id unused variables.Rafael Zalamena
To keep the debug functionality intact and correct we'll use the pid field in the imsg header to pass the instance number. Remember to always pass 'ps_instance + 1' otherwise libutil will fill imsg header pid field with the imsgbuf pid (which is the current process pid). ok reyk@
2016-08-26Replace the static env variables with a single global variable.Rafael Zalamena
ok reyk@
2016-08-22Enable SNI support in httpd(8).Joel Sing
ok reyk@
2016-08-16stop including sys/param.h for nitems. define locally as needed.Ted Unangst
ok natano reyk
2016-08-16Turn "TLS handshake failed -" log message into a debug message - itReyk Floeter
happens way too often and does not provide much information. OK jung@
2016-08-16Rename server_handshake_tls() to server_tls_handshake() to align withReyk Floeter
the other server_tls_* functions (and I like the prefix notation better). No functional change.
2016-08-15Move server_match() from parse.y to server.c; use env instead of conf,Joel Sing
which is actually the same thing (cluebat from reyk@).
2016-08-15Use lowercase 'tls' in debug and log messages for consistency.Joel Sing
Requested by reyk@
2016-08-15Make httpd stricter with respect to TLS configuration - in particular, doJoel Sing
not allow TLS and non-TLS to be configured on the same port, do not allow TLS options to be specified without a TLS listener and ensure that the TLS options are the same when a server is specified on the same address/port. Currently, these configurations are permitted but do not work as intended. Also factor out and reuse the server matching code, which was previously duplicated. ok reyk@
2016-04-28Include the TLS configuration errors in log messages. Also set theJoel Sing
certificate and private key at the same time.
2016-04-19Use log_warnx() instead of log_warn() when the failure will not haveJoel Sing
resulted in errno being set. ok reyk@
2015-12-02sync with relayd, use proc_compose()Reyk Floeter
2015-11-23Retire socket_set_blockmode() in favor of the SOCK_NONBLOCK type flag.Reyk Floeter
As done in iked and snmpd. OK jung@
2015-11-05pledge(2) for httpd.Florian Obser
1) The main process listens on sockets and accepts connections. It creates and opens log files, creates and kills child processes. On start up and on receiving a HUP signal it parses the configuration. It passes on file descriptors for logging or requests to it's children. 2) The logger process writes log messages to a file descriptor passed in from the main process. 3) The server process reads the request from a file descriptor passed in from the main process. It reads a file or creates a directory index to send a response. Additionally this process handles fastcgi requests. It connects to AF_UNIX, AF_INET or AF_INET6 sockets. A re-factoring might make it possible to drop the additional fastcgi privileges when only static files are served. with deraadt@ some time ago prodding & OK deraadt@ tweaks and OK reyk@
2015-09-11Fix server_handshake_tls() - we should only call server_input() in the caseJoel Sing
where the handshake has successfully completed. ok beck@
2015-09-10fix return type for tls_read/writeBob Beck
jointly with jsing@
2015-09-10fix after libtls api changesBob Beck
ok jsing@
2015-09-10Update httpd to call tls_handshake() after tls_accept_socket().Joel Sing
ok beck@
2015-09-07Fix a regression that was introduced with server.c r1.64: Do NOT freeReyk Floeter
srv_conf->auth in serverconfig_free() because it was not allocated in config_getserver() but assigned as a reference by id from a global list that is maintained independently. This fixes a potential double-free. This fix also makes srv_conf->auth "const" to emphasize that the read-only auth pointer was not allocated here. OK jsing@
2015-08-20Change httpd(8) to use C99-style fixed-width integers (uintN_t insteadReyk Floeter
of u_intN_t) and replace u_int with unsigned int. Mixing both variants is a bad style and most contributors seem to prefer this style; it also helps us to get used to it, portability, and standardization. Theoretically no binary change, except one in practice: httpd.o has a different checksum because gcc with -O2 pads/optimizes "struct privsep" differently when using "unsigned int" instead "u_int" for the affected members. "u_int" is just a typedef of "unsigned int", -O0 doesn't build the difference and clang with -O2 doesn't do it either - it is just another curiosity from gcc-land. OK semarie@
2015-08-03Fix rev 1.70 of server.c by only re-enabling the bufferevent if weFlorian Obser
previously disabled it because we were reading to fast (from disk). Problem noted and tracked down to that commit by weerd@ and independently by stsp@. Tested by weerd@, stsp@, reyk@ OK bluhm@, reyk@
2015-07-29backout the previous: it broke wordpress somehow.Reyk Floeter
we need more care to find a proper fix for the fastcgi headers. acknowledged by deraadt@
2015-07-29Read fcgi response records until we have the whole http header and canFlorian Obser
parse it. Otherwise http headers can leak into the body. Pointed out by Jean-Philippe Ouellet on bugs@ Thanks! OK reyk, commit ASAP deraadt@
2015-07-18libtls has been changed to set SSL_MODE_ENABLE_PARTIAL_WRITE andReyk Floeter
SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER by default. This gives tls_write() a similar short write semantics as write(2) and a workaround in httpd to cope with the previous differences can be removed. Specifically, httpd can stop copying data into a local buffer that was used to keep it around for repeated writes. OK bluhm@
2015-07-16If we can read faster from disk than send data to the client stopFlorian Obser
reading from disk when we hold a certain amount of data in RAM. Re-enable reading once we send enough data to the client. Otherwise we might end up with the whole file (which can be huge) in RAM. Reported by Matthew Martin ( matt.a.martin AT gmail ) on bugs@, thanks! OK reyk@, benno@
2015-07-15Escape the message in server_log() as well.Reyk Floeter
OK benno@
2015-07-15Close connections that fail to complete a TLS handshake.Joel Sing
Based on a diff from Jack Burton <jack at saosce dot com dot au>. ok reyk@
2015-07-15Fix typo in comment.Joel Sing
2015-07-15Send the TLS certificate and key via separate imsgs, rather thanJoel Sing
including them in the IMSG_CFG_SERVER imsg. This allows the certificate and key to each be almost 16KB (the maximum size for an imsg), rather than having a combined total of less than 16KB (which can be reached with large keys, certificate bundles or by including text versions of certificates). ok reyk@
2015-07-15Explicitly check for and handle EOF on a TLS connection.Joel Sing
ok reyk@
2015-07-15Fix memory leaks that can occur when config_getserver() fails.Joel Sing
config.c r1.34 and r1.30 introduced potential memory leaks for auth and return_uri when config_getserver fails. Fix this by switching to serverconfig_free() and adding the missing free for srv_conf->auth. While here, make serverconfig_free() a little more bulletproof by explicit_bzero()ing key material. ok reyk@
2015-04-23We cannot log errors with server_close() before allocatingFlorian Obser
clt_log evbuffer. server_close() calls server_log() which uses ctl_log. Crash reported by Daniel Jakots <vigdis AT chown DOT me>, thanks! OK benno
2015-04-11Always check the return value of proc_composev_imsg() and handle failuresJoel Sing
appropriately. Otherwise imsg construction can silently fail, resulting in non-obvious problems. Found the hard way by Theodore Wynnychenko. ok doug@ florian@
2015-03-15Prevent use after free.Florian Obser
While here unconditionally free clt and move declaration of server_inflight_dec() into server.c Found while investigating if (foo != NULL) free(foo) patterns pointed out by Markus Elfring. OK reyk
2015-02-23Add return_uri to serverconfig_reset() to avoid using garbage from theReyk Floeter
imsg buffer. Debugging & OK halex@
2015-02-12Allow TLS protocols to be specified via a "tls protocols" configurationJoel Sing
option. ok reyk@
2015-02-12Change TLS_PROTOCOLS_DEFAULT to be TLSv1.2 only. Add a TLS_PROTOCOLS_ALLJoel Sing
that includes all currently supported protocols (TLSv1.0, TLSv1.1 and TLSv1.2). Change all users of libtls to use TLS_PROTOCOLS_ALL so that they maintain existing behaviour. Discussed with tedu@ and reyk@.
2015-02-07Remove server_load_file() in favor of tls_load_file(3)Reyk Floeter
2015-02-07Add httpd configuration options to allow the specification of DHEJoel Sing
parameters and the ECDHE curve. This primarily allows for DHE cipher suites to be enabled. ok reyk@
2015-02-07Add support for blocking, dropping, and redirecting requests.Reyk Floeter
OK florian@
2015-01-21httpd is based on relayd and had included many headers that are onlyReyk Floeter
needed by its ancestor. jsg@, include-what-you-use, and some manual review helped to cleanup the headers (take iwyu with a grain of salt). Based on common practice, httpd.h now also includes the necessary headers for itself. OK florian@
2015-01-19Decouple auth parameters from struct server_config into struct auth.Reyk Floeter
OK florian@
2015-01-16Replace <sys/param.h> with <limits.h> and other less dirty headers whereTheo de Raadt
possible. Annotate <sys/param.h> lines with their current reasons. Switch to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where sensible to avoid pulling in the pollution. These are the files confirmed through binary verification. ok guenther, millert, doug (helped with the verification protocol)
2015-01-13bump copyright yearReyk Floeter