summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am3
-rw-r--r--src/Makefile.in43
-rw-r--r--src/base.h6
-rw-r--r--src/configfile.c21
-rw-r--r--src/connections.c3
-rw-r--r--src/fdevent.c7
-rw-r--r--src/fdevent.h15
-rw-r--r--src/fdevent_solaris_port.c172
-rw-r--r--src/http_auth.c6
-rw-r--r--src/http_auth_digest.c6
-rw-r--r--src/md5.c24
-rw-r--r--src/md5.h9
-rw-r--r--src/mod_cgi.c15
-rw-r--r--src/mod_cml_funcs.c6
-rw-r--r--src/mod_cml_lua.c6
-rw-r--r--src/mod_fastcgi.c8
-rw-r--r--src/mod_proxy.c109
-rw-r--r--src/mod_scgi.c4
-rw-r--r--src/mod_secure_download.c6
-rw-r--r--src/mod_status.c3
-rw-r--r--src/mod_usertrack.c6
-rw-r--r--src/network.c118
-rw-r--r--src/proc_open.c2
-rw-r--r--src/server.c7
24 files changed, 509 insertions, 96 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index e675dc0..dbb6e81 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -64,7 +64,8 @@ common_src=buffer.c log.c \
data_integer.c md5.c data_fastcgi.c \
fdevent_select.c fdevent_libev.c \
fdevent_poll.c fdevent_linux_sysepoll.c \
- fdevent_solaris_devpoll.c fdevent_freebsd_kqueue.c \
+ fdevent_solaris_devpoll.c fdevent_solaris_port.c \
+ fdevent_freebsd_kqueue.c \
data_config.c bitset.c \
inet_ntop_cache.c crc32.c \
connections-glue.c \
diff --git a/src/Makefile.in b/src/Makefile.in
index 5b7cb63..b2d79d0 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -92,12 +92,12 @@ am__liblightcomp_la_SOURCES_DIST = buffer.c log.c keyvalue.c chunk.c \
data_array.c data_integer.c md5.c data_fastcgi.c \
fdevent_select.c fdevent_libev.c fdevent_poll.c \
fdevent_linux_sysepoll.c fdevent_solaris_devpoll.c \
- fdevent_freebsd_kqueue.c data_config.c bitset.c \
- inet_ntop_cache.c crc32.c connections-glue.c configfile-glue.c \
- http-header-glue.c network_write.c network_linux_sendfile.c \
- network_freebsd_sendfile.c network_writev.c \
- network_solaris_sendfilev.c network_openssl.c splaytree.c \
- status_counter.c
+ fdevent_solaris_port.c fdevent_freebsd_kqueue.c data_config.c \
+ bitset.c inet_ntop_cache.c crc32.c connections-glue.c \
+ configfile-glue.c http-header-glue.c network_write.c \
+ network_linux_sendfile.c network_freebsd_sendfile.c \
+ network_writev.c network_solaris_sendfilev.c network_openssl.c \
+ splaytree.c status_counter.c
am__objects_1 = liblightcomp_la-buffer.lo liblightcomp_la-log.lo \
liblightcomp_la-keyvalue.lo liblightcomp_la-chunk.lo \
liblightcomp_la-http_chunk.lo liblightcomp_la-stream.lo \
@@ -112,6 +112,7 @@ am__objects_1 = liblightcomp_la-buffer.lo liblightcomp_la-log.lo \
liblightcomp_la-fdevent_poll.lo \
liblightcomp_la-fdevent_linux_sysepoll.lo \
liblightcomp_la-fdevent_solaris_devpoll.lo \
+ liblightcomp_la-fdevent_solaris_port.lo \
liblightcomp_la-fdevent_freebsd_kqueue.lo \
liblightcomp_la-data_config.lo liblightcomp_la-bitset.lo \
liblightcomp_la-inet_ntop_cache.lo liblightcomp_la-crc32.lo \
@@ -372,12 +373,12 @@ am__lighttpd_SOURCES_DIST = server.c response.c connections.c \
data_string.c data_count.c data_array.c data_integer.c md5.c \
data_fastcgi.c fdevent_select.c fdevent_libev.c fdevent_poll.c \
fdevent_linux_sysepoll.c fdevent_solaris_devpoll.c \
- fdevent_freebsd_kqueue.c data_config.c bitset.c \
- inet_ntop_cache.c crc32.c connections-glue.c configfile-glue.c \
- http-header-glue.c network_write.c network_linux_sendfile.c \
- network_freebsd_sendfile.c network_writev.c \
- network_solaris_sendfilev.c network_openssl.c splaytree.c \
- status_counter.c
+ fdevent_solaris_port.c fdevent_freebsd_kqueue.c data_config.c \
+ bitset.c inet_ntop_cache.c crc32.c connections-glue.c \
+ configfile-glue.c http-header-glue.c network_write.c \
+ network_linux_sendfile.c network_freebsd_sendfile.c \
+ network_writev.c network_solaris_sendfilev.c network_openssl.c \
+ splaytree.c status_counter.c
am__objects_2 = buffer.$(OBJEXT) log.$(OBJEXT) keyvalue.$(OBJEXT) \
chunk.$(OBJEXT) http_chunk.$(OBJEXT) stream.$(OBJEXT) \
fdevent.$(OBJEXT) stat_cache.$(OBJEXT) plugin.$(OBJEXT) \
@@ -388,6 +389,7 @@ am__objects_2 = buffer.$(OBJEXT) log.$(OBJEXT) keyvalue.$(OBJEXT) \
fdevent_libev.$(OBJEXT) fdevent_poll.$(OBJEXT) \
fdevent_linux_sysepoll.$(OBJEXT) \
fdevent_solaris_devpoll.$(OBJEXT) \
+ fdevent_solaris_port.$(OBJEXT) \
fdevent_freebsd_kqueue.$(OBJEXT) data_config.$(OBJEXT) \
bitset.$(OBJEXT) inet_ntop_cache.$(OBJEXT) crc32.$(OBJEXT) \
connections-glue.$(OBJEXT) configfile-glue.$(OBJEXT) \
@@ -503,6 +505,7 @@ CRYPT_LIB = @CRYPT_LIB@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@ -DHAVE_VERSION_H -DLIBRARY_DIR="\"$(libdir)\"" -DSBIN_DIR="\"$(sbindir)\""
DEPDIR = @DEPDIR@
+DLLTOOL = @DLLTOOL@
DL_LIB = @DL_LIB@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
@@ -536,6 +539,7 @@ LTLIBOBJS = @LTLIBOBJS@
LUA_CFLAGS = @LUA_CFLAGS@
LUA_LIBS = @LUA_LIBS@
MAKEINFO = @MAKEINFO@
+MANIFEST_TOOL = @MANIFEST_TOOL@
MEMCACHE_LIB = @MEMCACHE_LIB@
MKDIR_P = @MKDIR_P@
MYSQL_CONFIG = @MYSQL_CONFIG@
@@ -579,6 +583,7 @@ abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@
abs_top_srcdir = @abs_top_srcdir@
+ac_ct_AR = @ac_ct_AR@
ac_ct_CC = @ac_ct_CC@
ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
am__include = @am__include@
@@ -611,7 +616,6 @@ libdir = @libdir@
libexecdir = @libexecdir@
localedir = @localedir@
localstatedir = @localstatedir@
-lt_ECHO = @lt_ECHO@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
@@ -646,7 +650,8 @@ common_src = buffer.c log.c \
data_integer.c md5.c data_fastcgi.c \
fdevent_select.c fdevent_libev.c \
fdevent_poll.c fdevent_linux_sysepoll.c \
- fdevent_solaris_devpoll.c fdevent_freebsd_kqueue.c \
+ fdevent_solaris_devpoll.c fdevent_solaris_port.c \
+ fdevent_freebsd_kqueue.c \
data_config.c bitset.c \
inet_ntop_cache.c crc32.c \
connections-glue.c \
@@ -1042,6 +1047,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fdevent_poll.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fdevent_select.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fdevent_solaris_devpoll.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fdevent_solaris_port.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/http-header-glue.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/http_auth.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/http_auth_digest.Plo@am__quote@
@@ -1071,6 +1077,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/liblightcomp_la-fdevent_poll.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/liblightcomp_la-fdevent_select.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/liblightcomp_la-fdevent_solaris_devpoll.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/liblightcomp_la-fdevent_solaris_port.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/liblightcomp_la-http-header-glue.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/liblightcomp_la-http_chunk.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/liblightcomp_la-inet_ntop_cache.Plo@am__quote@
@@ -1356,6 +1363,14 @@ liblightcomp_la-fdevent_solaris_devpoll.lo: fdevent_solaris_devpoll.c
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(liblightcomp_la_CFLAGS) $(CFLAGS) -c -o liblightcomp_la-fdevent_solaris_devpoll.lo `test -f 'fdevent_solaris_devpoll.c' || echo '$(srcdir)/'`fdevent_solaris_devpoll.c
+liblightcomp_la-fdevent_solaris_port.lo: fdevent_solaris_port.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(liblightcomp_la_CFLAGS) $(CFLAGS) -MT liblightcomp_la-fdevent_solaris_port.lo -MD -MP -MF $(DEPDIR)/liblightcomp_la-fdevent_solaris_port.Tpo -c -o liblightcomp_la-fdevent_solaris_port.lo `test -f 'fdevent_solaris_port.c' || echo '$(srcdir)/'`fdevent_solaris_port.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/liblightcomp_la-fdevent_solaris_port.Tpo $(DEPDIR)/liblightcomp_la-fdevent_solaris_port.Plo
+@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='fdevent_solaris_port.c' object='liblightcomp_la-fdevent_solaris_port.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(liblightcomp_la_CFLAGS) $(CFLAGS) -c -o liblightcomp_la-fdevent_solaris_port.lo `test -f 'fdevent_solaris_port.c' || echo '$(srcdir)/'`fdevent_solaris_port.c
+
liblightcomp_la-fdevent_freebsd_kqueue.lo: fdevent_freebsd_kqueue.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(liblightcomp_la_CFLAGS) $(CFLAGS) -MT liblightcomp_la-fdevent_freebsd_kqueue.lo -MD -MP -MF $(DEPDIR)/liblightcomp_la-fdevent_freebsd_kqueue.Tpo -c -o liblightcomp_la-fdevent_freebsd_kqueue.lo `test -f 'fdevent_freebsd_kqueue.c' || echo '$(srcdir)/'`fdevent_freebsd_kqueue.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/liblightcomp_la-fdevent_freebsd_kqueue.Tpo $(DEPDIR)/liblightcomp_la-fdevent_freebsd_kqueue.Plo
diff --git a/src/base.h b/src/base.h
index 8278c7e..fcbd9ad 100644
--- a/src/base.h
+++ b/src/base.h
@@ -275,7 +275,10 @@ typedef struct {
buffer *ssl_pemfile;
buffer *ssl_ca_file;
buffer *ssl_cipher_list;
+ buffer *ssl_dh_file;
+ buffer *ssl_ec_curve;
unsigned short ssl_use_sslv2;
+ unsigned short ssl_use_sslv3;
unsigned short ssl_verifyclient;
unsigned short ssl_verifyclient_enforce;
unsigned short ssl_verifyclient_depth;
@@ -527,7 +530,10 @@ typedef struct {
buffer *ssl_pemfile;
buffer *ssl_ca_file;
buffer *ssl_cipher_list;
+ buffer *ssl_dh_file;
+ buffer *ssl_ec_curve;
unsigned short ssl_use_sslv2;
+ unsigned short ssl_use_sslv3;
unsigned short use_ipv6;
unsigned short is_ssl;
diff --git a/src/configfile.c b/src/configfile.c
index 0ee96b6..162fa00 100644
--- a/src/configfile.c
+++ b/src/configfile.c
@@ -102,6 +102,9 @@ static int config_insert(server *srv) {
{ "ssl.verifyclient.exportcert", NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_SERVER }, /* 60 */
{ "server.set-v6only", NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_CONNECTION }, /* 61 */
+ { "ssl.use-sslv3", NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_SERVER }, /* 62 */
+ { "ssl.dh-file", NULL, T_CONFIG_STRING, T_CONFIG_SCOPE_SERVER }, /* 63 */
+ { "ssl.ec-curve", NULL, T_CONFIG_STRING, T_CONFIG_SCOPE_SERVER }, /* 64 */
{ "server.host", "use server.bind instead", T_CONFIG_DEPRECATED, T_CONFIG_SCOPE_UNSET },
{ "server.docroot", "use server.document-root instead", T_CONFIG_DEPRECATED, T_CONFIG_SCOPE_UNSET },
@@ -164,6 +167,8 @@ static int config_insert(server *srv) {
s->error_handler = buffer_init();
s->server_tag = buffer_init();
s->ssl_cipher_list = buffer_init();
+ s->ssl_dh_file = buffer_init();
+ s->ssl_ec_curve = buffer_init();
s->errorfile_prefix = buffer_init();
s->max_keep_alive_requests = 16;
s->max_keep_alive_idle = 5;
@@ -172,6 +177,7 @@ static int config_insert(server *srv) {
s->use_xattr = 0;
s->is_ssl = 0;
s->ssl_use_sslv2 = 0;
+ s->ssl_use_sslv3 = 1;
s->use_ipv6 = 0;
s->set_v6only = 1;
s->defer_accept = 0;
@@ -236,6 +242,9 @@ static int config_insert(server *srv) {
cv[47].destination = s->ssl_cipher_list;
cv[48].destination = &(s->ssl_use_sslv2);
+ cv[62].destination = &(s->ssl_use_sslv3);
+ cv[63].destination = s->ssl_dh_file;
+ cv[64].destination = s->ssl_ec_curve;
cv[49].destination = &(s->etag_use_inode);
cv[50].destination = &(s->etag_use_mtime);
cv[51].destination = &(s->etag_use_size);
@@ -324,7 +333,10 @@ int config_setup_connection(server *srv, connection *con) {
#endif
PATCH(ssl_ca_file);
PATCH(ssl_cipher_list);
+ PATCH(ssl_dh_file);
+ PATCH(ssl_ec_curve);
PATCH(ssl_use_sslv2);
+ PATCH(ssl_use_sslv3);
PATCH(etag_use_inode);
PATCH(etag_use_mtime);
PATCH(etag_use_size);
@@ -390,10 +402,16 @@ int config_patch_connection(server *srv, connection *con, comp_key_t comp) {
PATCH(ssl_ca_file);
} else if (buffer_is_equal_string(du->key, CONST_STR_LEN("ssl.use-sslv2"))) {
PATCH(ssl_use_sslv2);
+ } else if (buffer_is_equal_string(du->key, CONST_STR_LEN("ssl.use-sslv3"))) {
+ PATCH(ssl_use_sslv3);
} else if (buffer_is_equal_string(du->key, CONST_STR_LEN("ssl.cipher-list"))) {
PATCH(ssl_cipher_list);
} else if (buffer_is_equal_string(du->key, CONST_STR_LEN("ssl.engine"))) {
PATCH(is_ssl);
+ } else if (buffer_is_equal_string(du->key, CONST_STR_LEN("ssl.dh-file"))) {
+ PATCH(ssl_dh_file);
+ } else if (buffer_is_equal_string(du->key, CONST_STR_LEN("ssl.ec-curve"))) {
+ PATCH(ssl_ec_curve);
#ifdef HAVE_LSTAT
} else if (buffer_is_equal_string(du->key, CONST_STR_LEN("server.follow-symlink"))) {
PATCH(follow_symlink);
@@ -1194,6 +1212,9 @@ int config_set_defaults(server *srv) {
#ifdef USE_SOLARIS_DEVPOLL
{ FDEVENT_HANDLER_SOLARIS_DEVPOLL,"solaris-devpoll" },
#endif
+#ifdef USE_SOLARIS_PORT
+ { FDEVENT_HANDLER_SOLARIS_PORT, "solaris-eventports" },
+#endif
#ifdef USE_FREEBSD_KQUEUE
{ FDEVENT_HANDLER_FREEBSD_KQUEUE, "freebsd-kqueue" },
{ FDEVENT_HANDLER_FREEBSD_KQUEUE, "kqueue" },
diff --git a/src/connections.c b/src/connections.c
index 95c1cda..75a8f61 100644
--- a/src/connections.c
+++ b/src/connections.c
@@ -1224,7 +1224,8 @@ static handler_t connection_handle_fdevent(server *srv, void *context, int reven
}
} else if (revents & FDEVENT_ERR) {
-#ifndef USE_LINUX_SIGIO
+ /* error, connection reset, whatever... we don't want to spam the logfile */
+#if 0
log_error_write(srv, __FILE__, __LINE__, "sd",
"connection closed: poll() -> ERR", con->fd);
#endif
diff --git a/src/fdevent.c b/src/fdevent.c
index 5f24b16..0ba73b9 100644
--- a/src/fdevent.c
+++ b/src/fdevent.c
@@ -50,6 +50,13 @@ fdevents *fdevent_init(server *srv, size_t maxfds, fdevent_handler_t type) {
return NULL;
}
return ev;
+ case FDEVENT_HANDLER_SOLARIS_PORT:
+ if (0 != fdevent_solaris_port_init(ev)) {
+ log_error_write(ev->srv, __FILE__, __LINE__, "S",
+ "event-handler solaris-eventports failed, try to set server.event-handler = \"poll\" or \"select\"");
+ return NULL;
+ }
+ return ev;
case FDEVENT_HANDLER_FREEBSD_KQUEUE:
if (0 != fdevent_freebsd_kqueue_init(ev)) {
log_error_write(ev->srv, __FILE__, __LINE__, "S",
diff --git a/src/fdevent.h b/src/fdevent.h
index 5f813d6..bdc82b5 100644
--- a/src/fdevent.h
+++ b/src/fdevent.h
@@ -49,16 +49,16 @@
# include <sys/devpoll.h>
#endif
+#if defined HAVE_PORT_H && defined HAVE_PORT_CREATE && defined(__sun)
+# define USE_SOLARIS_PORT
+# include <port.h>
+#endif
+
#if defined HAVE_SYS_EVENT_H && defined HAVE_KQUEUE
# define USE_FREEBSD_KQUEUE
# include <sys/event.h>
#endif
-#if defined HAVE_SYS_PORT_H && defined HAVE_PORT_CREATE
-# define USE_SOLARIS_PORT
-# include <sys/port.h>
-#endif
-
#if defined HAVE_LIBEV
# define USE_LIBEV
# include <ev.h>
@@ -90,6 +90,7 @@ typedef enum { FDEVENT_HANDLER_UNSET,
FDEVENT_HANDLER_POLL,
FDEVENT_HANDLER_LINUX_SYSEPOLL,
FDEVENT_HANDLER_SOLARIS_DEVPOLL,
+ FDEVENT_HANDLER_SOLARIS_PORT,
FDEVENT_HANDLER_FREEBSD_KQUEUE,
FDEVENT_HANDLER_LIBEV
} fdevent_handler_t;
@@ -153,6 +154,9 @@ typedef struct fdevents {
int devpoll_fd;
struct pollfd *devpollfds;
#endif
+#ifdef USE_SOLARIS_PORT
+ port_event_t *port_events;
+#endif
#ifdef USE_FREEBSD_KQUEUE
int kq_fd;
struct kevent *kq_results;
@@ -202,6 +206,7 @@ int fdevent_select_init(fdevents *ev);
int fdevent_poll_init(fdevents *ev);
int fdevent_linux_sysepoll_init(fdevents *ev);
int fdevent_solaris_devpoll_init(fdevents *ev);
+int fdevent_solaris_port_init(fdevents *ev);
int fdevent_freebsd_kqueue_init(fdevents *ev);
int fdevent_libev_init(fdevents *ev);
diff --git a/src/fdevent_solaris_port.c b/src/fdevent_solaris_port.c
new file mode 100644
index 0000000..8dea4d2
--- /dev/null
+++ b/src/fdevent_solaris_port.c
@@ -0,0 +1,172 @@
+#include "fdevent.h"
+#include "buffer.h"
+#include "log.h"
+
+#include <sys/types.h>
+
+#include <unistd.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <signal.h>
+#include <fcntl.h>
+
+#ifdef USE_SOLARIS_PORT
+
+static const int SOLARIS_PORT_POLL_READ = POLLIN;
+static const int SOLARIS_PORT_POLL_WRITE = POLLOUT;
+static const int SOLARIS_PORT_POLL_READ_WRITE = POLLIN & POLLOUT;
+
+static int fdevent_solaris_port_event_del(fdevents *ev, int fde_ndx, int fd) {
+ if (fde_ndx < 0) return -1;
+
+ if (0 != port_dissociate(ev->port_fd, PORT_SOURCE_FD, fd)) {
+ log_error_write(ev->srv, __FILE__, __LINE__, "SSS",
+ "port_dissociate failed: ", strerror(errno), ", dying");
+
+ SEGFAULT();
+
+ return 0;
+ }
+
+ return -1;
+}
+
+static int fdevent_solaris_port_event_set(fdevents *ev, int fde_ndx, int fd, int events) {
+ const int* user_data = NULL;
+
+ if ((events & FDEVENT_IN) && (events & FDEVENT_OUT)) {
+ user_data = &SOLARIS_PORT_POLL_READ_WRITE;
+ } else if (events & FDEVENT_IN) {
+ user_data = &SOLARIS_PORT_POLL_READ;
+ } else if (events & FDEVENT_OUT) {
+ user_data = &SOLARIS_PORT_POLL_WRITE;
+ }
+
+ if (0 != port_associate(ev->port_fd, PORT_SOURCE_FD, fd, *user_data, (void*) user_data)) {
+ log_error_write(ev->srv, __FILE__, __LINE__, "SSS",
+ "port_associate failed: ", strerror(errno), ", dying");
+
+ SEGFAULT();
+
+ return 0;
+ }
+
+ return fd;
+}
+
+static int fdevent_solaris_port_event_get_revent(fdevents *ev, size_t ndx) {
+ int events = 0, e;
+
+ e = ev->port_events[ndx].portev_events;
+ if (e & POLLIN) events |= FDEVENT_IN;
+ if (e & POLLOUT) events |= FDEVENT_OUT;
+ if (e & POLLERR) events |= FDEVENT_ERR;
+ if (e & POLLHUP) events |= FDEVENT_HUP;
+ if (e & POLLPRI) events |= FDEVENT_PRI;
+ if (e & POLLNVAL) events |= FDEVENT_NVAL;
+
+ return e;
+}
+
+static int fdevent_solaris_port_event_get_fd(fdevents *ev, size_t ndx) {
+ return ev->port_events[ndx].portev_object;
+}
+
+static int fdevent_solaris_port_event_next_fdndx(fdevents *ev, int ndx) {
+ size_t i;
+
+ UNUSED(ev);
+
+ i = (ndx < 0) ? 0 : ndx + 1;
+
+ return i;
+}
+
+static void fdevent_solaris_port_free(fdevents *ev) {
+ close(ev->port_fd);
+ free(ev->port_events);
+}
+
+/* if there is any error it will return the return values of port_getn, otherwise it will return number of events **/
+static int fdevent_solaris_port_poll(fdevents *ev, int timeout_ms) {
+ int i = 0;
+ int ret;
+ unsigned int available_events, wait_for_events = 0;
+ const int *user_data;
+
+ struct timespec timeout;
+
+ timeout.tv_sec = timeout_ms/1000L;
+ timeout.tv_nsec = (timeout_ms % 1000L) * 1000000L;
+
+ /* get the number of file descriptors with events */
+ if ((ret = port_getn(ev->port_fd, ev->port_events, 0, &wait_for_events, &timeout)) < 0) return ret;
+
+ /* wait for at least one event */
+ if (0 == wait_for_events) wait_for_events = 1;
+
+ available_events = wait_for_events;
+
+ /* get the events of the file descriptors */
+ if ((ret = port_getn(ev->port_fd, ev->port_events, ev->maxfds, &available_events, &timeout)) < 0) {
+ /* if errno == ETIME and available_event == wait_for_events we didn't get any events */
+ /* for other errors we didn't get any events either */
+ if (!(errno == ETIME && wait_for_events != available_events)) return ret;
+ }
+
+ for (i = 0; i < available_events; ++i) {
+ user_data = (const int *) ev->port_events[i].portev_user;
+
+ if ((ret = port_associate(ev->port_fd, PORT_SOURCE_FD, ev->port_events[i].portev_object,
+ *user_data, (void*) user_data)) < 0) {
+ log_error_write(ev->srv, __FILE__, __LINE__, "SSS",
+ "port_associate failed: ", strerror(errno), ", dying");
+
+ SEGFAULT();
+
+ return 0;
+ }
+ }
+
+ return available_events;
+}
+
+int fdevent_solaris_port_init(fdevents *ev) {
+ ev->type = FDEVENT_HANDLER_SOLARIS_PORT;
+#define SET(x) \
+ ev->x = fdevent_solaris_port_##x;
+
+ SET(free);
+ SET(poll);
+
+ SET(event_del);
+ SET(event_set);
+
+ SET(event_next_fdndx);
+ SET(event_get_fd);
+ SET(event_get_revent);
+
+ if ((ev->port_fd = port_create()) < 0) {
+ log_error_write(ev->srv, __FILE__, __LINE__, "SSS",
+ "port_create() failed (", strerror(errno), "), try to set server.event-handler = \"poll\" or \"select\"");
+
+ return -1;
+ }
+
+ ev->port_events = malloc(ev->maxfds * sizeof(*ev->port_events));
+
+ return 0;
+}
+
+#else
+int fdevent_solaris_port_init(fdevents *ev) {
+ UNUSED(ev);
+
+ log_error_write(ev->srv, __FILE__, __LINE__, "S",
+ "solaris-eventports not supported, try to set server.event-handler = \"poll\" or \"select\"");
+
+ return -1;
+}
+#endif
diff --git a/src/http_auth.c b/src/http_auth.c
index f7f0aaf..e479683 100644
--- a/src/http_auth.c
+++ b/src/http_auth.c
@@ -32,6 +32,12 @@
# include <openssl/md5.h>
#else
# include "md5.h"
+
+typedef li_MD5_CTX MD5_CTX;
+#define MD5_Init li_MD5_Init
+#define MD5_Update li_MD5_Update
+#define MD5_Final li_MD5_Final
+
#endif
/**
diff --git a/src/http_auth_digest.c b/src/http_auth_digest.c
index e3f46b6..83b3c60 100644
--- a/src/http_auth_digest.c
+++ b/src/http_auth_digest.c
@@ -6,6 +6,12 @@
#ifndef USE_OPENSSL
# include "md5.h"
+
+typedef li_MD5_CTX MD5_CTX;
+#define MD5_Init li_MD5_Init
+#define MD5_Update li_MD5_Update
+#define MD5_Final li_MD5_Final
+
#endif
void CvtHex(IN HASH Bin, OUT HASHHEX Hex) {
diff --git a/src/md5.c b/src/md5.c
index 34c6ac9..f13d866 100644
--- a/src/md5.c
+++ b/src/md5.c
@@ -52,7 +52,7 @@ documentation and/or software.
#define S43 15
#define S44 21
-static void MD5Transform (UINT4 [4], const unsigned char [64]);
+static void li_MD5Transform (UINT4 [4], const unsigned char [64]);
static void Encode (unsigned char *, UINT4 *, unsigned int);
static void Decode (UINT4 *, const unsigned char *, unsigned int);
@@ -110,8 +110,8 @@ Rotation is separate from addition to prevent recomputation.
/* MD5 initialization. Begins an MD5 operation, writing a new context.
*/
-void MD5_Init (context)
-MD5_CTX *context; /* context */
+void li_MD5_Init (context)
+li_MD5_CTX *context; /* context */
{
context->count[0] = context->count[1] = 0;
/* Load magic initialization constants.
@@ -126,8 +126,8 @@ MD5_CTX *context; /* context */
operation, processing another message block, and updating the
context.
*/
-void MD5_Update (context, _input, inputLen)
-MD5_CTX *context; /* context */
+void li_MD5_Update (context, _input, inputLen)
+li_MD5_CTX *context; /* context */
const void *_input; /* input block */
unsigned int inputLen; /* length of input block */
{
@@ -151,10 +151,10 @@ unsigned int inputLen; /* length of input block */
if (inputLen >= partLen) {
MD5_memcpy
((POINTER)&context->buffer[ndx], (POINTER)input, partLen);
- MD5Transform (context->state, context->buffer);
+ li_MD5Transform (context->state, context->buffer);
for (i = partLen; i + 63 < inputLen; i += 64)
- MD5Transform (context->state, &input[i]);
+ li_MD5Transform (context->state, &input[i]);
ndx = 0;
}
@@ -170,9 +170,9 @@ unsigned int inputLen; /* length of input block */
/* MD5 finalization. Ends an MD5 message-digest operation, writing the
the message digest and zeroizing the context.
*/
-void MD5_Final (digest, context)
+void li_MD5_Final (digest, context)
unsigned char digest[16]; /* message digest */
-MD5_CTX *context; /* context */
+li_MD5_CTX *context; /* context */
{
unsigned char bits[8];
unsigned int ndx, padLen;
@@ -184,10 +184,10 @@ MD5_CTX *context; /* context */
*/
ndx = (unsigned int)((context->count[0] >> 3) & 0x3f);
padLen = (ndx < 56) ? (56 - ndx) : (120 - ndx);
- MD5_Update (context, PADDING, padLen);
+ li_MD5_Update (context, PADDING, padLen);
/* Append length (before padding) */
- MD5_Update (context, bits, 8);
+ li_MD5_Update (context, bits, 8);
/* Store state in digest */
Encode (digest, context->state, 16);
@@ -199,7 +199,7 @@ MD5_CTX *context; /* context */
/* MD5 basic transformation. Transforms state based on block.
*/
-static void MD5Transform (state, block)
+static void li_MD5Transform (state, block)
UINT4 state[4];
const unsigned char block[64];
{
diff --git a/src/md5.h b/src/md5.h
index 591a17d..669a826 100644
--- a/src/md5.h
+++ b/src/md5.h
@@ -39,9 +39,8 @@ typedef struct {
UINT4 state[4]; /* state (ABCD) */
UINT4 count[2]; /* number of bits, modulo 2^64 (lsb first) */
unsigned char buffer[64]; /* input buffer */
-} MD5_CTX;
-
-void MD5_Init (MD5_CTX *);
-void MD5_Update (MD5_CTX *, const void *, unsigned int);
-void MD5_Final (unsigned char [16], MD5_CTX *);
+} li_MD5_CTX;
+void li_MD5_Init (li_MD5_CTX *);
+void li_MD5_Update (li_MD5_CTX *, const void *, unsigned int);
+void li_MD5_Final (unsigned char [16], li_MD5_CTX *);
diff --git a/src/mod_cgi.c b/src/mod_cgi.c
index 1608f02..25d2f65 100644
--- a/src/mod_cgi.c
+++ b/src/mod_cgi.c
@@ -341,8 +341,19 @@ static int cgi_demux_response(server *srv, handler_ctx *hctx) {
while(1) {
int n;
+ int toread;
+
+#if defined(__WIN32)
+ buffer_prepare_copy(hctx->response, 4 * 1024);
+#else
+ if (ioctl(con->fd, FIONREAD, &toread) || toread == 0 || toread <= 4*1024) {
+ buffer_prepare_copy(hctx->response, 4 * 1024);
+ } else {
+ if (toread > MAX_READ_LIMIT) toread = MAX_READ_LIMIT;
+ buffer_prepare_copy(hctx->response, toread + 1);
+ }
+#endif
- buffer_prepare_copy(hctx->response, 1024);
if (-1 == (n = read(hctx->fd, hctx->response->ptr, hctx->response->size - 1))) {
if (errno == EAGAIN || errno == EINTR) {
/* would block, wait for signal */
@@ -917,7 +928,7 @@ static int cgi_create_env(server *srv, connection *con, plugin_data *p, buffer *
cgi_env_add(&env, CONST_STR_LEN("CONTENT_LENGTH"), buf, strlen(buf));
cgi_env_add(&env, CONST_STR_LEN("SCRIPT_FILENAME"), CONST_BUF_LEN(con->physical.path));
cgi_env_add(&env, CONST_STR_LEN("SCRIPT_NAME"), CONST_BUF_LEN(con->uri.path));
- cgi_env_add(&env, CONST_STR_LEN("DOCUMENT_ROOT"), CONST_BUF_LEN(con->physical.doc_root));
+ cgi_env_add(&env, CONST_STR_LEN("DOCUMENT_ROOT"), CONST_BUF_LEN(con->physical.basedir));
/* for valgrind */
if (NULL != (s = getenv("LD_PRELOAD"))) {
diff --git a/src/mod_cml_funcs.c b/src/mod_cml_funcs.c
index b01d4d2..b8958ab 100644
--- a/src/mod_cml_funcs.c
+++ b/src/mod_cml_funcs.c
@@ -21,6 +21,12 @@
# include <openssl/md5.h>
#else
# include "md5.h"
+
+typedef li_MD5_CTX MD5_CTX;
+#define MD5_Init li_MD5_Init
+#define MD5_Update li_MD5_Update
+#define MD5_Final li_MD5_Final
+
#endif
#define HASHLEN 16
diff --git a/src/mod_cml_lua.c b/src/mod_cml_lua.c
index b3f2cbb..8be4538 100644
--- a/src/mod_cml_lua.c
+++ b/src/mod_cml_lua.c
@@ -15,6 +15,12 @@
# include <openssl/md5.h>
#else
# include "md5.h"
+
+typedef li_MD5_CTX MD5_CTX;
+#define MD5_Init li_MD5_Init
+#define MD5_Update li_MD5_Update
+#define MD5_Final li_MD5_Final
+
#endif
#define HASHLEN 16
diff --git a/src/mod_fastcgi.c b/src/mod_fastcgi.c
index ae39d89..0fbcc17 100644
--- a/src/mod_fastcgi.c
+++ b/src/mod_fastcgi.c
@@ -80,7 +80,6 @@ typedef struct fcgi_proc {
size_t load; /* number of requests waiting on this process */
- time_t last_used; /* see idle_timeout */
size_t requests; /* see max_requests */
struct fcgi_proc *prev, *next; /* see first */
@@ -1132,7 +1131,6 @@ static int fcgi_spawn_connection(server *srv,
/* register process */
proc->pid = child;
- proc->last_used = srv->cur_ts;
proc->is_local = 1;
break;
@@ -1970,7 +1968,7 @@ static int fcgi_create_env(server *srv, handler_ctx *hctx, size_t request_id) {
if (!buffer_is_empty(host->docroot)) {
buffer_copy_string_buffer(p->path, host->docroot);
} else {
- buffer_copy_string_buffer(p->path, con->physical.doc_root);
+ buffer_copy_string_buffer(p->path, con->physical.basedir);
}
buffer_append_string_buffer(p->path, con->request.pathinfo);
FCGI_ENV_ADD_CHECK(fcgi_env_add(p->fcgi_env, CONST_STR_LEN("PATH_TRANSLATED"), CONST_BUF_LEN(p->path)),con)
@@ -2010,7 +2008,7 @@ static int fcgi_create_env(server *srv, handler_ctx *hctx, size_t request_id) {
}
FCGI_ENV_ADD_CHECK(fcgi_env_add(p->fcgi_env, CONST_STR_LEN("SCRIPT_FILENAME"), CONST_BUF_LEN(p->path)),con)
- FCGI_ENV_ADD_CHECK(fcgi_env_add(p->fcgi_env, CONST_STR_LEN("DOCUMENT_ROOT"), CONST_BUF_LEN(con->physical.doc_root)),con)
+ FCGI_ENV_ADD_CHECK(fcgi_env_add(p->fcgi_env, CONST_STR_LEN("DOCUMENT_ROOT"), CONST_BUF_LEN(con->physical.basedir)),con)
}
if (host->strip_request_uri->used > 1) {
@@ -3047,7 +3045,6 @@ static handler_t fcgi_write_request(server *srv, handler_ctx *hctx) {
/* ok, we have the connection */
fcgi_proc_load_inc(srv, hctx);
- hctx->proc->last_used = srv->cur_ts;
hctx->got_proc = 1;
status_counter_inc(srv, CONST_STR_LEN("fastcgi.requests"));
@@ -3276,6 +3273,7 @@ static handler_t fcgi_handle_fdevent(server *srv, void *ctx, int revents) {
*/
buffer_copy_string_buffer(con->physical.doc_root, host->docroot);
+ buffer_copy_string_buffer(con->physical.basedir, host->docroot);
buffer_copy_string_buffer(con->physical.path, host->docroot);
buffer_append_string_buffer(con->physical.path, con->uri.path);
diff --git a/src/mod_proxy.c b/src/mod_proxy.c
index b54d243..bd82654 100644
--- a/src/mod_proxy.c
+++ b/src/mod_proxy.c
@@ -724,9 +724,9 @@ static int proxy_demux_response(server *srv, handler_ctx *hctx) {
con->file_started = 1;
if (blen) {
http_chunk_append_mem(srv, con, c + 4, blen + 1);
- joblist_append(srv, con);
}
hctx->response->used = 0;
+ joblist_append(srv, con);
}
} else {
http_chunk_append_mem(srv, con, hctx->response->ptr, hctx->response->used);
@@ -750,7 +750,6 @@ static int proxy_demux_response(server *srv, handler_ctx *hctx) {
static handler_t proxy_write_request(server *srv, handler_ctx *hctx) {
data_proxy *host= hctx->host;
- plugin_data *p = hctx->plugin_data;
connection *con = hctx->remote_conn;
int ret;
@@ -759,6 +758,17 @@ static handler_t proxy_write_request(server *srv, handler_ctx *hctx) {
(!host->host->used || !host->port)) return -1;
switch(hctx->state) {
+ case PROXY_STATE_CONNECT:
+ /* wait for the connect() to finish */
+
+ /* connect failed ? */
+ if (-1 == hctx->fde_ndx) return HANDLER_ERROR;
+
+ /* wait */
+ return HANDLER_WAIT_FOR_EVENT;
+
+ break;
+
case PROXY_STATE_INIT:
#if defined(HAVE_IPV6) && defined(HAVE_INET_PTON)
if (strstr(host->host->ptr,":")) {
@@ -786,58 +796,28 @@ static handler_t proxy_write_request(server *srv, handler_ctx *hctx) {
return HANDLER_ERROR;
}
- /* fall through */
-
- case PROXY_STATE_CONNECT:
- /* try to finish the connect() */
- if (hctx->state == PROXY_STATE_INIT) {
- /* first round */
- switch (proxy_establish_connection(srv, hctx)) {
- case 1:
- proxy_set_state(srv, hctx, PROXY_STATE_CONNECT);
-
- /* connection is in progress, wait for an event and call getsockopt() below */
-
- fdevent_event_set(srv->ev, &(hctx->fde_ndx), hctx->fd, FDEVENT_OUT);
-
- return HANDLER_WAIT_FOR_EVENT;
- case -1:
- /* if ECONNREFUSED choose another connection -> FIXME */
- hctx->fde_ndx = -1;
-
- return HANDLER_ERROR;
- default:
- /* everything is ok, go on */
- break;
- }
- } else {
- int socket_error;
- socklen_t socket_error_len = sizeof(socket_error);
+ switch (proxy_establish_connection(srv, hctx)) {
+ case 1:
+ proxy_set_state(srv, hctx, PROXY_STATE_CONNECT);
- /* we don't need it anymore */
- fdevent_event_del(srv->ev, &(hctx->fde_ndx), hctx->fd);
+ /* connection is in progress, wait for an event and call getsockopt() below */
- /* try to finish the connect() */
- if (0 != getsockopt(hctx->fd, SOL_SOCKET, SO_ERROR, &socket_error, &socket_error_len)) {
- log_error_write(srv, __FILE__, __LINE__, "ss",
- "getsockopt failed:", strerror(errno));
+ fdevent_event_set(srv->ev, &(hctx->fde_ndx), hctx->fd, FDEVENT_OUT);
- return HANDLER_ERROR;
- }
- if (socket_error != 0) {
- log_error_write(srv, __FILE__, __LINE__, "ss",
- "establishing connection failed:", strerror(socket_error),
- "port:", hctx->host->port);
+ return HANDLER_WAIT_FOR_EVENT;
+ case -1:
+ /* if ECONNREFUSED choose another connection -> FIXME */
+ hctx->fde_ndx = -1;
- return HANDLER_ERROR;
- }
- if (p->conf.debug) {
- log_error_write(srv, __FILE__, __LINE__, "s", "proxy - connect - delayed success");
- }
+ return HANDLER_ERROR;
+ default:
+ /* everything is ok, go on */
+ proxy_set_state(srv, hctx, PROXY_STATE_PREPARE_WRITE);
+ break;
}
- proxy_set_state(srv, hctx, PROXY_STATE_PREPARE_WRITE);
/* fall through */
+
case PROXY_STATE_PREPARE_WRITE:
proxy_create_env(srv, hctx);
@@ -1019,11 +999,42 @@ static handler_t proxy_handle_fdevent(server *srv, void *ctx, int revents) {
"proxy: fdevent-out", hctx->state);
}
- if (hctx->state == PROXY_STATE_CONNECT ||
+ if (hctx->state == PROXY_STATE_CONNECT) {
+ int socket_error;
+ socklen_t socket_error_len = sizeof(socket_error);
+
+ /* we don't need it anymore */
+ fdevent_event_del(srv->ev, &(hctx->fde_ndx), hctx->fd);
+ hctx->fde_ndx = -1;
+
+ /* try to finish the connect() */
+ if (0 != getsockopt(hctx->fd, SOL_SOCKET, SO_ERROR, &socket_error, &socket_error_len)) {
+ log_error_write(srv, __FILE__, __LINE__, "ss",
+ "getsockopt failed:", strerror(errno));
+
+ joblist_append(srv, con);
+ return HANDLER_FINISHED;
+ }
+ if (socket_error != 0) {
+ log_error_write(srv, __FILE__, __LINE__, "ss",
+ "establishing connection failed:", strerror(socket_error),
+ "port:", hctx->host->port);
+
+ joblist_append(srv, con);
+ return HANDLER_FINISHED;
+ }
+ if (p->conf.debug) {
+ log_error_write(srv, __FILE__, __LINE__, "s", "proxy - connect - delayed success");
+ }
+
+ proxy_set_state(srv, hctx, PROXY_STATE_PREPARE_WRITE);
+ }
+
+ if (hctx->state == PROXY_STATE_PREPARE_WRITE ||
hctx->state == PROXY_STATE_WRITE) {
/* we are allowed to send something out
*
- * 1. in a unfinished connect() call
+ * 1. after a just finished connect() call
* 2. in a unfinished write() call (long POST request)
*/
return mod_proxy_handle_subrequest(srv, con, p);
diff --git a/src/mod_scgi.c b/src/mod_scgi.c
index 0455fbf..59e5ccb 100644
--- a/src/mod_scgi.c
+++ b/src/mod_scgi.c
@@ -1558,7 +1558,7 @@ static int scgi_create_env(server *srv, handler_ctx *hctx) {
if (!buffer_is_empty(host->docroot)) {
buffer_copy_string_buffer(p->path, host->docroot);
} else {
- buffer_copy_string_buffer(p->path, con->physical.doc_root);
+ buffer_copy_string_buffer(p->path, con->physical.basedir);
}
buffer_append_string_buffer(p->path, con->request.pathinfo);
scgi_env_add(p->scgi_env, CONST_STR_LEN("PATH_TRANSLATED"), CONST_BUF_LEN(p->path));
@@ -1589,7 +1589,7 @@ static int scgi_create_env(server *srv, handler_ctx *hctx) {
buffer_copy_string_buffer(p->path, con->physical.path);
scgi_env_add(p->scgi_env, CONST_STR_LEN("SCRIPT_FILENAME"), CONST_BUF_LEN(p->path));
- scgi_env_add(p->scgi_env, CONST_STR_LEN("DOCUMENT_ROOT"), CONST_BUF_LEN(con->physical.doc_root));
+ scgi_env_add(p->scgi_env, CONST_STR_LEN("DOCUMENT_ROOT"), CONST_BUF_LEN(con->physical.basedir));
}
scgi_env_add(p->scgi_env, CONST_STR_LEN("REQUEST_URI"), CONST_BUF_LEN(con->request.orig_uri));
if (!buffer_is_equal(con->request.uri, con->request.orig_uri)) {
diff --git a/src/mod_secure_download.c b/src/mod_secure_download.c
index 67013c3..bf33b43 100644
--- a/src/mod_secure_download.c
+++ b/src/mod_secure_download.c
@@ -12,6 +12,12 @@
# include <openssl/md5.h>
#else
# include "md5.h"
+
+typedef li_MD5_CTX MD5_CTX;
+#define MD5_Init li_MD5_Init
+#define MD5_Update li_MD5_Update
+#define MD5_Final li_MD5_Final
+
#endif
#define HASHLEN 16
diff --git a/src/mod_status.c b/src/mod_status.c
index e1a11a0..69c5de5 100644
--- a/src/mod_status.c
+++ b/src/mod_status.c
@@ -694,6 +694,9 @@ static handler_t mod_status_handle_server_config(server *srv, connection *con, v
#ifdef USE_SOLARIS_DEVPOLL
{ FDEVENT_HANDLER_SOLARIS_DEVPOLL,"solaris-devpoll" },
#endif
+#ifdef USE_SOLARIS_PORT
+ { FDEVENT_HANDLER_SOLARIS_PORT, "solaris-eventports" },
+#endif
#ifdef USE_FREEBSD_KQUEUE
{ FDEVENT_HANDLER_FREEBSD_KQUEUE, "freebsd-kqueue" },
#endif
diff --git a/src/mod_usertrack.c b/src/mod_usertrack.c
index cbdf1b0..06de298 100644
--- a/src/mod_usertrack.c
+++ b/src/mod_usertrack.c
@@ -12,6 +12,12 @@
# include <openssl/md5.h>
#else
# include "md5.h"
+
+typedef li_MD5_CTX MD5_CTX;
+#define MD5_Init li_MD5_Init
+#define MD5_Update li_MD5_Update
+#define MD5_Final li_MD5_Final
+
#endif
/* plugin config for all request/connections */
diff --git a/src/network.c b/src/network.c
index a98b4b8..58b8e5c 100644
--- a/src/network.c
+++ b/src/network.c
@@ -479,6 +479,55 @@ int network_init(server *srv) {
size_t i;
network_backend_t backend;
+#if OPENSSL_VERSION_NUMBER >= 0x0090800fL
+ EC_KEY *ecdh;
+ int nid;
+#endif
+
+#ifdef USE_OPENSSL
+ DH *dh;
+ BIO *bio;
+
+ /* 1024-bit MODP Group with 160-bit prime order subgroup (RFC5114)
+ * -----BEGIN DH PARAMETERS-----
+ * MIIBDAKBgQCxC4+WoIDgHd6S3l6uXVTsUsmfvPsGo8aaap3KUtI7YWBz4oZ1oj0Y
+ * mDjvHi7mUsAT7LSuqQYRIySXXDzUm4O/rMvdfZDEvXCYSI6cIZpzck7/1vrlZEc4
+ * +qMaT/VbzMChUa9fDci0vUW/N982XBpl5oz9p21NpwjfH7K8LkpDcQKBgQCk0cvV
+ * w/00EmdlpELvuZkF+BBN0lisUH/WQGz/FCZtMSZv6h5cQVZLd35pD1UE8hMWAhe0
+ * sBuIal6RVH+eJ0n01/vX07mpLuGQnQ0iY/gKdqaiTAh6CR9THb8KAWm2oorWYqTR
+ * jnOvoy13nVkY0IvIhY9Nzvl8KiSFXm7rIrOy5QICAKA=
+ * -----END DH PARAMETERS-----
+ */
+
+ static const unsigned char dh1024_p[]={
+ 0xB1,0x0B,0x8F,0x96,0xA0,0x80,0xE0,0x1D,0xDE,0x92,0xDE,0x5E,
+ 0xAE,0x5D,0x54,0xEC,0x52,0xC9,0x9F,0xBC,0xFB,0x06,0xA3,0xC6,
+ 0x9A,0x6A,0x9D,0xCA,0x52,0xD2,0x3B,0x61,0x60,0x73,0xE2,0x86,
+ 0x75,0xA2,0x3D,0x18,0x98,0x38,0xEF,0x1E,0x2E,0xE6,0x52,0xC0,
+ 0x13,0xEC,0xB4,0xAE,0xA9,0x06,0x11,0x23,0x24,0x97,0x5C,0x3C,
+ 0xD4,0x9B,0x83,0xBF,0xAC,0xCB,0xDD,0x7D,0x90,0xC4,0xBD,0x70,
+ 0x98,0x48,0x8E,0x9C,0x21,0x9A,0x73,0x72,0x4E,0xFF,0xD6,0xFA,
+ 0xE5,0x64,0x47,0x38,0xFA,0xA3,0x1A,0x4F,0xF5,0x5B,0xCC,0xC0,
+ 0xA1,0x51,0xAF,0x5F,0x0D,0xC8,0xB4,0xBD,0x45,0xBF,0x37,0xDF,
+ 0x36,0x5C,0x1A,0x65,0xE6,0x8C,0xFD,0xA7,0x6D,0x4D,0xA7,0x08,
+ 0xDF,0x1F,0xB2,0xBC,0x2E,0x4A,0x43,0x71,
+ };
+
+ static const unsigned char dh1024_g[]={
+ 0xA4,0xD1,0xCB,0xD5,0xC3,0xFD,0x34,0x12,0x67,0x65,0xA4,0x42,
+ 0xEF,0xB9,0x99,0x05,0xF8,0x10,0x4D,0xD2,0x58,0xAC,0x50,0x7F,
+ 0xD6,0x40,0x6C,0xFF,0x14,0x26,0x6D,0x31,0x26,0x6F,0xEA,0x1E,
+ 0x5C,0x41,0x56,0x4B,0x77,0x7E,0x69,0x0F,0x55,0x04,0xF2,0x13,
+ 0x16,0x02,0x17,0xB4,0xB0,0x1B,0x88,0x6A,0x5E,0x91,0x54,0x7F,
+ 0x9E,0x27,0x49,0xF4,0xD7,0xFB,0xD7,0xD3,0xB9,0xA9,0x2E,0xE1,
+ 0x90,0x9D,0x0D,0x22,0x63,0xF8,0x0A,0x76,0xA6,0xA2,0x4C,0x08,
+ 0x7A,0x09,0x1F,0x53,0x1D,0xBF,0x0A,0x01,0x69,0xB6,0xA2,0x8A,
+ 0xD6,0x62,0xA4,0xD1,0x8E,0x73,0xAF,0xA3,0x2D,0x77,0x9D,0x59,
+ 0x18,0xD0,0x8B,0xC8,0x85,0x8F,0x4D,0xCE,0xF9,0x7C,0x2A,0x24,
+ 0x85,0x5E,0x6E,0xEB,0x22,0xB3,0xB2,0xE5,
+ };
+#endif
+
struct nb_map {
network_backend_t nb;
const char *name;
@@ -521,6 +570,7 @@ int network_init(server *srv) {
if (srv->ssl_is_init == 0) {
SSL_load_error_strings();
SSL_library_init();
+ OpenSSL_add_all_algorithms();
srv->ssl_is_init = 1;
if (0 == RAND_status()) {
@@ -545,6 +595,15 @@ int network_init(server *srv) {
}
}
+ if (!s->ssl_use_sslv3) {
+ /* disable SSLv3 */
+ if (!(SSL_OP_NO_SSLv3 & SSL_CTX_set_options(s->ssl_ctx, SSL_OP_NO_SSLv3))) {
+ log_error_write(srv, __FILE__, __LINE__, "ss", "SSL:",
+ ERR_error_string(ERR_get_error(), NULL));
+ return -1;
+ }
+ }
+
if (!buffer_is_empty(s->ssl_cipher_list)) {
/* Disable support for low encryption ciphers */
if (SSL_CTX_set_cipher_list(s->ssl_ctx, s->ssl_cipher_list->ptr) != 1) {
@@ -554,6 +613,65 @@ int network_init(server *srv) {
}
}
+ /* Support for Diffie-Hellman key exchange */
+ if (!buffer_is_empty(s->ssl_dh_file)) {
+ /* DH parameters from file */
+ bio = BIO_new_file((char *) s->ssl_dh_file->ptr, "r");
+ if (bio == NULL) {
+ log_error_write(srv, __FILE__, __LINE__, "ss", "SSL: Unable to open file", s->ssl_dh_file->ptr);
+ return -1;
+ }
+ dh = PEM_read_bio_DHparams(bio, NULL, NULL, NULL);
+ BIO_free(bio);
+ if (dh == NULL) {
+ log_error_write(srv, __FILE__, __LINE__, "ss", "SSL: PEM_read_bio_DHparams failed", s->ssl_dh_file->ptr);
+ return -1;
+ }
+ } else {
+ /* Default DH parameters from RFC5114 */
+ dh = DH_new();
+ if (dh == NULL) {
+ log_error_write(srv, __FILE__, __LINE__, "s", "SSL: DH_new () failed");
+ return -1;
+ }
+ dh->p = BN_bin2bn(dh1024_p,sizeof(dh1024_p), NULL);
+ dh->g = BN_bin2bn(dh1024_g,sizeof(dh1024_g), NULL);
+ dh->length = 160;
+ if ((dh->p == NULL) || (dh->g == NULL)) {
+ DH_free(dh);
+ log_error_write(srv, __FILE__, __LINE__, "s", "SSL: BN_bin2bn () failed");
+ return -1;
+ }
+ }
+ SSL_CTX_set_tmp_dh(s->ssl_ctx,dh);
+ SSL_CTX_set_options(s->ssl_ctx,SSL_OP_SINGLE_DH_USE);
+ DH_free(dh);
+
+#if OPENSSL_VERSION_NUMBER >= 0x0090800fL
+#ifndef OPENSSL_NO_ECDH
+ /* Support for Elliptic-Curve Diffie-Hellman key exchange */
+ if (!buffer_is_empty(s->ssl_ec_curve)) {
+ /* OpenSSL only supports the "named curves" from RFC 4492, section 5.1.1. */
+ nid = OBJ_sn2nid((char *) s->ssl_ec_curve->ptr);
+ if (nid == 0) {
+ log_error_write(srv, __FILE__, __LINE__, "ss", "SSL: Unknown curve name", s->ssl_ec_curve->ptr);
+ return -1;
+ }
+ } else {
+ /* Default curve */
+ nid = OBJ_sn2nid("prime256v1");
+ }
+ ecdh = EC_KEY_new_by_curve_name(nid);
+ if (ecdh == NULL) {
+ log_error_write(srv, __FILE__, __LINE__, "ss", "SSL: Unable to create curve", s->ssl_ec_curve->ptr);
+ return -1;
+ }
+ SSL_CTX_set_tmp_ecdh(s->ssl_ctx,ecdh);
+ SSL_CTX_set_options(s->ssl_ctx,SSL_OP_SINGLE_ECDH_USE);
+ EC_KEY_free(ecdh);
+#endif
+#endif
+
if (!buffer_is_empty(s->ssl_ca_file)) {
if (1 != SSL_CTX_load_verify_locations(s->ssl_ctx, s->ssl_ca_file->ptr, NULL)) {
log_error_write(srv, __FILE__, __LINE__, "ssb", "SSL:",
diff --git a/src/proc_open.c b/src/proc_open.c
index eb9dbdd..3c065d0 100644
--- a/src/proc_open.c
+++ b/src/proc_open.c
@@ -3,6 +3,7 @@
#include <stdlib.h>
#include <stdio.h>
#include <ctype.h>
+#include <string.h>
#include <errno.h>
#ifdef WIN32
@@ -257,6 +258,7 @@ int proc_open(proc_handler_t *proc, const char *command) {
proc_close_parents(proc);
execl(shell, shell, "-c", command, (char *)NULL);
+ fprintf(stderr, "failed to execute shell: %s -c %s: %s\n", shell, command, strerror(errno));
_exit(127);
} else if (child < 0) {
diff --git a/src/server.c b/src/server.c
index 0b92239..5fcbfe4 100644
--- a/src/server.c
+++ b/src/server.c
@@ -306,6 +306,8 @@ static void server_free(server *srv) {
buffer_free(s->ssl_pemfile);
buffer_free(s->ssl_ca_file);
buffer_free(s->ssl_cipher_list);
+ buffer_free(s->ssl_dh_file);
+ buffer_free(s->ssl_ec_curve);
buffer_free(s->error_handler);
buffer_free(s->errorfile_prefix);
array_free(s->mimetypes);
@@ -391,6 +393,11 @@ static void show_features (void) {
#else
"\t- /dev/poll (Solaris)\n"
#endif
+#ifdef USE_SOLARIS_PORT
+ "\t+ eventports (Solaris)\n"
+#else
+ "\t- eventports (Solaris)\n"
+#endif
#ifdef USE_FREEBSD_KQUEUE
"\t+ kqueue (FreeBSD)\n"
#else