diff options
author | Paul Querna | 2005-04-04 08:28:38 +0000 |
---|---|---|
committer | Paul Querna | 2005-04-04 08:28:38 +0000 |
commit | 6e0bfd69eb8331d195f9fc4a449a3d52baa6793d (patch) | |
tree | 8e3082866cfbe32e2bfdd44db40660ab92f31ba8 | |
parent | 7bd1f6a2642fdbf5c5f2f48af9af01765e6abe05 (diff) |
- make memcahe optional
- update for 2.1.x branch changes.
- some mucking around with the conf stuff
-rwxr-xr-x | autogen.sh | 4 | ||||
-rw-r--r-- | configure.ac | 21 | ||||
-rw-r--r-- | include/mod_gnutls.h.in | 4 | ||||
-rw-r--r-- | src/Makefile.am | 16 | ||||
-rw-r--r-- | src/gnutls_cache.c | 88 | ||||
-rw-r--r-- | src/mod_gnutls.c | 4 |
6 files changed, 76 insertions, 61 deletions
@@ -3,8 +3,8 @@ | |||
3 | # $Id: autogen.sh,v 1.1 2004/03/04 08:12:13 firechipmunk Exp $ | 3 | # $Id: autogen.sh,v 1.1 2004/03/04 08:12:13 firechipmunk Exp $ |
4 | libtoolize --force --copy | 4 | libtoolize --force --copy |
5 | #libtoolize14 --force --copy | 5 | #libtoolize14 --force --copy |
6 | aclocal -I m4 | 6 | aclocal-1.9 -I m4 |
7 | autoheader | 7 | autoheader |
8 | automake --add-missing --copy --foreign | 8 | automake-1.9 --add-missing --copy --foreign |
9 | autoconf | 9 | autoconf |
10 | rm -rf autom4te.cache | 10 | rm -rf autom4te.cache |
diff --git a/configure.ac b/configure.ac index 001f145..086b9f5 100644 --- a/configure.ac +++ b/configure.ac | |||
@@ -1,16 +1,18 @@ | |||
1 | AC_INIT | 1 | |
2 | AC_INIT(mod_gnutls, 0.1.0) | ||
2 | OOO_CONFIG_NICE(config.nice) | 3 | OOO_CONFIG_NICE(config.nice) |
4 | AC_PREREQ(2.53) | ||
3 | AC_CONFIG_SRCDIR([src/mod_gnutls.c]) | 5 | AC_CONFIG_SRCDIR([src/mod_gnutls.c]) |
6 | AC_CONFIG_AUX_DIR(config) | ||
4 | AM_MAINTAINER_MODE | 7 | AM_MAINTAINER_MODE |
5 | AC_CANONICAL_TARGET | 8 | AC_CANONICAL_TARGET |
6 | AM_INIT_AUTOMAKE(mod_gnutls, 0.1.0) | 9 | AM_INIT_AUTOMAKE(AC_PACKAGE_NAME, AC_PACKAGE_VERSION) |
7 | AM_CONFIG_HEADER([include/mod_gnutls_config.h:config.in]) | 10 | AM_CONFIG_HEADER(include/mod_gnutls_config.h:config.in) |
8 | 11 | ||
9 | 12 | ||
10 | AC_PROG_CC | 13 | AC_PROG_CC |
11 | AC_PROG_LD | 14 | AC_PROG_LD |
12 | AC_PROG_INSTALL | 15 | AC_PROG_INSTALL |
13 | AM_PROG_LIBTOOL | ||
14 | 16 | ||
15 | 17 | ||
16 | AP_VERSION=2.0.40 | 18 | AP_VERSION=2.0.40 |
@@ -19,10 +21,15 @@ CHECK_APACHE(,$AP_VERSION, | |||
19 | AC_MSG_ERROR([*** Apache version $AP_VERSION not found!]) | 21 | AC_MSG_ERROR([*** Apache version $AP_VERSION not found!]) |
20 | ) | 22 | ) |
21 | 23 | ||
22 | MIN_TLS_VERSION=1.1.0 | 24 | LIBTOOL="`${APR_CONFIG} --apr-libtool`" |
25 | AC_SUBST(LIBTOOL) | ||
26 | |||
27 | MIN_TLS_VERSION=1.2.0 | ||
23 | CHECK_LIBGNUTLS($MIN_TLS_VERSION) | 28 | CHECK_LIBGNUTLS($MIN_TLS_VERSION) |
24 | 29 | ||
25 | CHECK_APR_MEMCACHE() | 30 | have_apr_memcache=0 |
31 | CHECK_APR_MEMCACHE([have_apr_memcache=1], [have_apr_memcache=0]) | ||
32 | AC_SUBST(have_apr_memcache) | ||
26 | 33 | ||
27 | MODULE_CFLAGS="${LIBGNUTLS_CFLAGS} ${APR_MEMCACHE_CFLAGS} ${APXS_CFLAGS} ${AP_INCLUDES} ${APR_INCLUDES} ${APU_INCLUDES}" | 34 | MODULE_CFLAGS="${LIBGNUTLS_CFLAGS} ${APR_MEMCACHE_CFLAGS} ${APXS_CFLAGS} ${AP_INCLUDES} ${APR_INCLUDES} ${APU_INCLUDES}" |
28 | MODULE_LIBS="${APR_MEMCACHE_LIBS} ${LIBGNUTLS_LIBS}" | 35 | MODULE_LIBS="${APR_MEMCACHE_LIBS} ${LIBGNUTLS_LIBS}" |
@@ -30,7 +37,7 @@ MODULE_LIBS="${APR_MEMCACHE_LIBS} ${LIBGNUTLS_LIBS}" | |||
30 | AC_SUBST(MODULE_CFLAGS) | 37 | AC_SUBST(MODULE_CFLAGS) |
31 | AC_SUBST(MODULE_LIBS) | 38 | AC_SUBST(MODULE_LIBS) |
32 | 39 | ||
33 | AC_CONFIG_FILES([Makefile src/Makefile]) | 40 | AC_CONFIG_FILES([Makefile src/Makefile include/mod_gnutls.h]) |
34 | AC_OUTPUT | 41 | AC_OUTPUT |
35 | 42 | ||
36 | echo "---" | 43 | echo "---" |
diff --git a/include/mod_gnutls.h.in b/include/mod_gnutls.h.in index 03ba4d1..469e678 100644 --- a/include/mod_gnutls.h.in +++ b/include/mod_gnutls.h.in | |||
@@ -29,9 +29,7 @@ | |||
29 | #ifndef __mod_gnutls_h_inc | 29 | #ifndef __mod_gnutls_h_inc |
30 | #define __mod_gnutls_h_inc | 30 | #define __mod_gnutls_h_inc |
31 | 31 | ||
32 | #if HAVE_APR_MEMCACHE | 32 | #define HAVE_APR_MEMCACHE @have_apr_memcache@ |
33 | #include "apr_memcache.h" | ||
34 | #endif | ||
35 | 33 | ||
36 | #include <gcrypt.h> | 34 | #include <gcrypt.h> |
37 | #include <gnutls/gnutls.h> | 35 | #include <gnutls/gnutls.h> |
diff --git a/src/Makefile.am b/src/Makefile.am index 1f1860b..30315a1 100644 --- a/src/Makefile.am +++ b/src/Makefile.am | |||
@@ -9,13 +9,13 @@ lib_LTLIBRARIES = libmod_gnutls.la | |||
9 | make_so: $(lib_LTLIBRARIES) | 9 | make_so: $(lib_LTLIBRARIES) |
10 | @if test ! -L mod_gnutls.so ; then ln -s .libs/libmod_gnutls.so mod_gnutls.so ; fi | 10 | @if test ! -L mod_gnutls.so ; then ln -s .libs/libmod_gnutls.so mod_gnutls.so ; fi |
11 | 11 | ||
12 | clean: | 12 | clean: |
13 | rm -f mod_gnutls.so | 13 | rm -f mod_gnutls.so |
14 | rm -f *.o *.lo *.la | 14 | rm -f *.o *.lo *.la |
15 | rm -fr .libs | 15 | rm -fr .libs |
16 | 16 | ||
17 | install: make_so | 17 | install: make_so |
18 | @${APXS_BIN} -i -n svn_view mod_gnutls.so | 18 | @${APXS_BIN} -i -n gnutls mod_gnutls.so |
19 | @echo "" | 19 | @echo "" |
20 | @echo "" | 20 | @echo "" |
21 | @echo "***********************************************" | 21 | @echo "***********************************************" |
@@ -27,15 +27,3 @@ install: make_so | |||
27 | @echo "***********************************************" | 27 | @echo "***********************************************" |
28 | @echo "" | 28 | @echo "" |
29 | 29 | ||
30 | activate: make_so | ||
31 | @${APXS_BIN} -i -a -n svn_view mod_gnutls.so | ||
32 | @echo "" | ||
33 | @echo "" | ||
34 | @echo "***********************************************" | ||
35 | @echo "" | ||
36 | @echo " Please read the documentation at " | ||
37 | @echo " http://www.outoforder.cc/ for " | ||
38 | @echo " details on configuration of this module " | ||
39 | @echo "" | ||
40 | @echo "***********************************************" | ||
41 | @echo "" | ||
diff --git a/src/gnutls_cache.c b/src/gnutls_cache.c index cee30fa..c1a6f37 100644 --- a/src/gnutls_cache.c +++ b/src/gnutls_cache.c | |||
@@ -16,8 +16,38 @@ | |||
16 | */ | 16 | */ |
17 | 17 | ||
18 | #include "mod_gnutls.h" | 18 | #include "mod_gnutls.h" |
19 | |||
20 | #if HAVE_APR_MEMCACHE | ||
21 | #include "apr_memcache.h" | ||
22 | #endif | ||
23 | |||
19 | #include "ap_mpm.h" | 24 | #include "ap_mpm.h" |
20 | 25 | ||
26 | #define GNUTLS_SESSION_ID_STRING_LEN \ | ||
27 | ((GNUTLS_MAX_SESSION_ID + 1) * 2) | ||
28 | #define MC_TAG "mod_gnutls:" | ||
29 | #define MC_TAG_LEN \ | ||
30 | (sizeof(MC_TAG)) | ||
31 | #define STR_SESSION_LEN (GNUTLS_SESSION_ID_STRING_LEN + MC_TAG_LEN) | ||
32 | |||
33 | static char *gnutls_session_id2sz(unsigned char *id, int idlen, | ||
34 | char *str, int strsize) | ||
35 | { | ||
36 | char *cp; | ||
37 | int n; | ||
38 | |||
39 | cp = apr_cpystrn(str, MC_TAG, MC_TAG_LEN); | ||
40 | for (n = 0; n < idlen && n < GNUTLS_MAX_SESSION_ID; n++) { | ||
41 | apr_snprintf(cp, strsize - (cp-str), "%02X", id[n]); | ||
42 | cp += 2; | ||
43 | } | ||
44 | *cp = '\0'; | ||
45 | return str; | ||
46 | } | ||
47 | |||
48 | |||
49 | #if HAVE_APR_MEMCACHE | ||
50 | |||
21 | /** | 51 | /** |
22 | * GnuTLS Session Cache using libmemcached | 52 | * GnuTLS Session Cache using libmemcached |
23 | * | 53 | * |
@@ -26,7 +56,7 @@ | |||
26 | /* The underlying apr_memcache system is thread safe... woohoo */ | 56 | /* The underlying apr_memcache system is thread safe... woohoo */ |
27 | static apr_memcache_t* mc; | 57 | static apr_memcache_t* mc; |
28 | 58 | ||
29 | int mod_gnutls_cache_child_init(apr_pool_t *p, server_rec *s, | 59 | int mc_cache_child_init(apr_pool_t *p, server_rec *s, |
30 | mod_gnutls_srvconf_rec *sc) | 60 | mod_gnutls_srvconf_rec *sc) |
31 | { | 61 | { |
32 | apr_status_t rv = APR_SUCCESS; | 62 | apr_status_t rv = APR_SUCCESS; |
@@ -109,32 +139,8 @@ int mod_gnutls_cache_child_init(apr_pool_t *p, server_rec *s, | |||
109 | return rv; | 139 | return rv; |
110 | } | 140 | } |
111 | 141 | ||
112 | /* thanks mod_ssl */ | 142 | static int mc_cache_store(void* baton, gnutls_datum_t key, |
113 | #define GNUTLS_SESSION_ID_STRING_LEN \ | 143 | gnutls_datum_t data) |
114 | ((GNUTLS_MAX_SESSION_ID + 1) * 2) | ||
115 | #define MC_TAG "mod_gnutls:" | ||
116 | #define MC_TAG_LEN \ | ||
117 | (sizeof(MC_TAG)) | ||
118 | #define STR_SESSION_LEN (GNUTLS_SESSION_ID_STRING_LEN + MC_TAG_LEN) | ||
119 | |||
120 | |||
121 | static char *gnutls_session_id2sz(unsigned char *id, int idlen, | ||
122 | char *str, int strsize) | ||
123 | { | ||
124 | char *cp; | ||
125 | int n; | ||
126 | |||
127 | cp = apr_cpystrn(str, MC_TAG, MC_TAG_LEN); | ||
128 | for (n = 0; n < idlen && n < GNUTLS_MAX_SESSION_ID; n++) { | ||
129 | apr_snprintf(cp, strsize - (cp-str), "%02X", id[n]); | ||
130 | cp += 2; | ||
131 | } | ||
132 | *cp = '\0'; | ||
133 | return str; | ||
134 | } | ||
135 | |||
136 | |||
137 | static int cache_store(void* baton, gnutls_datum_t key, gnutls_datum_t data) | ||
138 | { | 144 | { |
139 | apr_status_t rv = APR_SUCCESS; | 145 | apr_status_t rv = APR_SUCCESS; |
140 | mod_gnutls_handle_t *ctxt = baton; | 146 | mod_gnutls_handle_t *ctxt = baton; |
@@ -161,7 +167,7 @@ static int cache_store(void* baton, gnutls_datum_t key, gnutls_datum_t data) | |||
161 | return 0; | 167 | return 0; |
162 | } | 168 | } |
163 | 169 | ||
164 | static gnutls_datum_t cache_fetch(void* baton, gnutls_datum_t key) | 170 | static gnutls_datum_t mc_cache_fetch(void* baton, gnutls_datum_t key) |
165 | { | 171 | { |
166 | apr_status_t rv = APR_SUCCESS; | 172 | apr_status_t rv = APR_SUCCESS; |
167 | mod_gnutls_handle_t *ctxt = baton; | 173 | mod_gnutls_handle_t *ctxt = baton; |
@@ -190,7 +196,7 @@ static gnutls_datum_t cache_fetch(void* baton, gnutls_datum_t key) | |||
190 | return data; | 196 | return data; |
191 | } | 197 | } |
192 | 198 | ||
193 | /* TODO: Eliminate this memcpy. ffs. gnutls-- */ | 199 | /* TODO: Eliminate this memcpy. gnutls-- */ |
194 | data.data = gnutls_malloc(value_len); | 200 | data.data = gnutls_malloc(value_len); |
195 | if (data.data == NULL) | 201 | if (data.data == NULL) |
196 | return data; | 202 | return data; |
@@ -201,7 +207,7 @@ static gnutls_datum_t cache_fetch(void* baton, gnutls_datum_t key) | |||
201 | return data; | 207 | return data; |
202 | } | 208 | } |
203 | 209 | ||
204 | static int cache_delete(void* baton, gnutls_datum_t key) | 210 | static int mc_cache_delete(void* baton, gnutls_datum_t key) |
205 | { | 211 | { |
206 | apr_status_t rv = APR_SUCCESS; | 212 | apr_status_t rv = APR_SUCCESS; |
207 | mod_gnutls_handle_t *ctxt = baton; | 213 | mod_gnutls_handle_t *ctxt = baton; |
@@ -225,11 +231,27 @@ static int cache_delete(void* baton, gnutls_datum_t key) | |||
225 | return 0; | 231 | return 0; |
226 | } | 232 | } |
227 | 233 | ||
234 | #endif /* have_apr_memcache */ | ||
235 | |||
236 | int mod_gnutls_cache_child_init(apr_pool_t *p, server_rec *s, | ||
237 | mod_gnutls_srvconf_rec *sc) | ||
238 | { | ||
239 | #if HAVE_APR_MEMCACHE | ||
240 | return mc_cache_child_init(p, s, sc); | ||
241 | #else | ||
242 | return 0; | ||
243 | #endif | ||
244 | } | ||
245 | |||
228 | int mod_gnutls_cache_session_init(mod_gnutls_handle_t *ctxt) | 246 | int mod_gnutls_cache_session_init(mod_gnutls_handle_t *ctxt) |
229 | { | 247 | { |
230 | gnutls_db_set_retrieve_function(ctxt->session, cache_fetch); | 248 | #if HAVE_APR_MEMCACHE |
231 | gnutls_db_set_remove_function(ctxt->session, cache_delete); | 249 | gnutls_db_set_retrieve_function(ctxt->session, mc_cache_fetch); |
232 | gnutls_db_set_store_function(ctxt->session, cache_store); | 250 | gnutls_db_set_remove_function(ctxt->session, mc_cache_delete); |
251 | gnutls_db_set_store_function(ctxt->session, mc_cache_store); | ||
233 | gnutls_db_set_ptr(ctxt->session, ctxt); | 252 | gnutls_db_set_ptr(ctxt->session, ctxt); |
253 | #else | ||
254 | /* TODO: Alternative Cache Backends */ | ||
255 | #endif | ||
234 | return 0; | 256 | return 0; |
235 | } | 257 | } |
diff --git a/src/mod_gnutls.c b/src/mod_gnutls.c index 833edc2..a1668f3 100644 --- a/src/mod_gnutls.c +++ b/src/mod_gnutls.c | |||
@@ -124,7 +124,7 @@ static void mod_gnutls_hook_child_init(apr_pool_t *p, server_rec *s) | |||
124 | } | 124 | } |
125 | } | 125 | } |
126 | 126 | ||
127 | static const char *mod_gnutls_hook_http_method(const request_rec * r) | 127 | static const char *mod_gnutls_hook_http_scheme(const request_rec * r) |
128 | { | 128 | { |
129 | mod_gnutls_srvconf_rec *sc = | 129 | mod_gnutls_srvconf_rec *sc = |
130 | (mod_gnutls_srvconf_rec *) ap_get_module_config(r->server-> | 130 | (mod_gnutls_srvconf_rec *) ap_get_module_config(r->server-> |
@@ -340,7 +340,7 @@ static void gnutls_hooks(apr_pool_t * p) | |||
340 | APR_HOOK_MIDDLE); | 340 | APR_HOOK_MIDDLE); |
341 | ap_hook_child_init(mod_gnutls_hook_child_init, NULL, NULL, | 341 | ap_hook_child_init(mod_gnutls_hook_child_init, NULL, NULL, |
342 | APR_HOOK_MIDDLE); | 342 | APR_HOOK_MIDDLE); |
343 | ap_hook_http_method(mod_gnutls_hook_http_method, NULL, NULL, | 343 | ap_hook_http_scheme(mod_gnutls_hook_http_scheme, NULL, NULL, |
344 | APR_HOOK_MIDDLE); | 344 | APR_HOOK_MIDDLE); |
345 | ap_hook_default_port(mod_gnutls_hook_default_port, NULL, NULL, | 345 | ap_hook_default_port(mod_gnutls_hook_default_port, NULL, NULL, |
346 | APR_HOOK_MIDDLE); | 346 | APR_HOOK_MIDDLE); |