Trying to add a hook to mod_auth_form via diff --git a/include/mod_auth.h b/include/mod_auth.h index 9b9561e..74e2dc6 100644 --- a/include/mod_auth.h +++ b/include/mod_auth.h @@ -134,6 +134,8 @@ APR_DECLARE_OPTIONAL_FN(void, ap_authn_cache_store, (request_rec*, const char*, const char*, const char*, const char*));
+AP_DECLARE_HOOK(int, form_logout_handler, (request_rec* r)); + #ifdef __cplusplus } #endif diff --git a/modules/aaa/mod_auth_form.c b/modules/aaa/mod_auth_form.c index 28045b5..1662eeb 100644 --- a/modules/aaa/mod_auth_form.c +++ b/modules/aaa/mod_auth_form.c @@ -82,6 +82,12 @@ typedef struct { int logout_set; } auth_form_config_rec; +APR_HOOK_STRUCT( + APR_HOOK_LINK(form_logout_handler) +) + +AP_IMPLEMENT_HOOK_RUN_ALL(int, form_logout_handler, (request_rec* r), (r), OK, DECLINED) + static void *create_auth_form_dir_config(apr_pool_t * p, char *d) { auth_form_config_rec *conf = apr_pcalloc(p, sizeof(*conf)); @@ -1200,6 +1208,9 @@ static int authenticate_form_logout_handler(request_rec * r) conf = ap_get_module_config(r->per_dir_config, &auth_form_module); + /* run the form logout hook as long as the apache session still contains useful data */ + ap_run_form_logout_handler(r); + /* remove the username and password, effectively logging the user out */ set_session_auth(r, NULL, NULL, NULL); but keep getting server/.libs/libmain.a(exports.o):(.data+0x11dc): undefined reference to `ap_hook_form_logout_handler' server/.libs/libmain.a(exports.o):(.data+0x11e0): undefined reference to `ap_hook_get_form_logout_handler' server/.libs/libmain.a(exports.o):(.data+0x11e4): undefined reference to `ap_run_form_logout_handler' I read the comment in AP_IMPLEMENT_HOOK_RUN_ALL regarding the link prefix but I figured since I was adding this to modules/aaa/mod_auth_form.c and include/mod_auth.h it was not relevant. I tried using a different link prefix and namespace anyway. Using diff --git a/include/mod_auth.h b/include/mod_auth.h index 9b9561e..6535770 100644 --- a/include/mod_auth.h +++ b/include/mod_auth.h @@ -134,6 +134,8 @@ APR_DECLARE_OPTIONAL_FN(void, ap_authn_cache_store, (request_rec*, const char*, const char*, const char*, const char*)); +APR_DECLARE_EXTERNAL_HOOK(auth, AUTH, int, form_logout_handler, (request_rec* r)); + #ifdef __cplusplus } #endif diff --git a/modules/aaa/mod_auth_form.c b/modules/aaa/mod_auth_form.c index 28045b5..7fd5edd 100644 --- a/modules/aaa/mod_auth_form.c +++ b/modules/aaa/mod_auth_form.c @@ -82,6 +82,12 @@ typedef struct { int logout_set; } auth_form_config_rec; +APR_HOOK_STRUCT( + APR_HOOK_LINK(form_logout_handler) +) + +APR_IMPLEMENT_EXTERNAL_HOOK_RUN_ALL(auth, AUTH, int, form_logout_handler, (request_rec* r), (r), OK, DECLINED) + static void *create_auth_form_dir_config(apr_pool_t * p, char *d) { auth_form_config_rec *conf = apr_pcalloc(p, sizeof(*conf)); @@ -1200,6 +1208,9 @@ static int authenticate_form_logout_handler(request_rec * r) conf = ap_get_module_config(r->per_dir_config, &auth_form_module); + /* run the form logout hook as long as the apache session still contains useful data */ + auth_run_form_logout_handler(r); + /* remove the username and password, effectively logging the user out */ set_session_auth(r, NULL, NULL, NULL); got me literally flooded with error messages starting with In file included from exports.c:105: /usr/src/packages/BUILD/httpd-2.4.4/include/mod_auth.h:137: warning: return type defaults to 'int' /usr/src/packages/BUILD/httpd-2.4.4/include/mod_auth.h: In function 'AUTH_DECLARE': /usr/src/packages/BUILD/httpd-2.4.4/include/mod_auth.h:137: error: expected declaration specifiers before 'auth_hook_form_logout_handler' so I guess there's a bit more work required for setting up a new namespace/link prefix. Back with the first appraoch (using AP_DECLARE_HOOK and friends) I compared this with other hooks, e.g. with http_protocol, http_connection and mod_proxy in general but could not find the missing link (no pun intended..) I did read http://httpd.apache.org/docs/2.4/developer/hooks.html but didn't see discrepancies with my AP_DECLARE* patch. Anyone care to shed some light on this for me ? Is it preferrable to get it done via AP_DECLARE_*and friends or should I use APR_DECLARE_* and if so, then how would I take care of the above mentioned error messages ? (If anyone is interested in the "why": I need to clean up data in my custom form auth provider on logout. I figured the proper way was to do this via a hook.)