Return-Path: X-Original-To: apmail-httpd-dev-archive@www.apache.org Delivered-To: apmail-httpd-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id D2975106D7 for ; Fri, 29 Nov 2013 19:52:48 +0000 (UTC) Received: (qmail 57814 invoked by uid 500); 29 Nov 2013 19:52:47 -0000 Delivered-To: apmail-httpd-dev-archive@httpd.apache.org Received: (qmail 57785 invoked by uid 500); 29 Nov 2013 19:52:47 -0000 Mailing-List: contact dev-help@httpd.apache.org; run by ezmlm Precedence: bulk Reply-To: dev@httpd.apache.org list-help: list-unsubscribe: List-Post: List-Id: Delivered-To: mailing list dev@httpd.apache.org Received: (qmail 57777 invoked by uid 99); 29 Nov 2013 19:52:47 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 29 Nov 2013 19:52:47 +0000 X-ASF-Spam-Status: No, hits=2.2 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_NONE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: local policy) Received: from [195.232.224.77] (HELO mailout08.vodafone.com) (195.232.224.77) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 29 Nov 2013 19:52:40 +0000 Received: from mailint08.vodafone.com (localhost [127.0.0.1]) by mailout08.vodafone.com (Postfix) with ESMTP id 783AC221B63 for ; Fri, 29 Nov 2013 20:52:15 +0100 (CET) Received: from VOEXC01W.internal.vodafone.com (voexc01w.dc-ratingen.de [145.230.101.21]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) by mailint08.vodafone.com (Postfix) with ESMTPS id 6B9CE22166C for ; Fri, 29 Nov 2013 20:52:15 +0100 (CET) Received: from AVOEXH04W.internal.vodafone.com (145.230.15.136) by VOEXC01W.internal.vodafone.com (145.230.101.21) with Microsoft SMTP Server (TLS) id 14.3.146.2; Fri, 29 Nov 2013 20:52:15 +0100 Received: from VOEXM10W.internal.vodafone.com ([169.254.2.26]) by AVOEXH04W.internal.vodafone.com ([145.230.15.136]) with mapi id 14.03.0146.002; Fri, 29 Nov 2013 20:52:14 +0100 From: =?iso-8859-1?Q?Pl=FCm=2C_R=FCdiger=2C_Vodafone_Group?= To: "dev@httpd.apache.org" Subject: AW: adding hook into mod_auth_form Thread-Topic: adding hook into mod_auth_form Thread-Index: AQHO7Smb/Yo7OYDQ70CMl3KxJ2aSLJo8nmGA Date: Fri, 29 Nov 2013 19:52:13 +0000 Message-ID: References: In-Reply-To: Accept-Language: en-US Content-Language: de-DE X-MS-Has-Attach: X-MS-TNEF-Correlator: Content-Type: multipart/alternative; boundary="_000_AB1691BE05AE7F4992697F2A0835627A948D875CVOEXM10Winterna_" MIME-Version: 1.0 X-Virus-Checked: Checked by ClamAV on apache.org --_000_AB1691BE05AE7F4992697F2A0835627A948D875CVOEXM10Winterna_ Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable I guess your second example is correct (with EXTERNAL), but you miss the fo= llowing before in the header file (example from mod_proxy): /* Create a set of PROXY_DECLARE(type), PROXY_DECLARE_NONSTD(type) and * PROXY_DECLARE_DATA with appropriate export and import tags for the platfo= rm */ #if !defined(WIN32) #define PROXY_DECLARE(type) type #define PROXY_DECLARE_NONSTD(type) type #define PROXY_DECLARE_DATA #elif defined(PROXY_DECLARE_STATIC) #define PROXY_DECLARE(type) type __stdcall #define PROXY_DECLARE_NONSTD(type) type #define PROXY_DECLARE_DATA #elif defined(PROXY_DECLARE_EXPORT) #define PROXY_DECLARE(type) __declspec(dllexport) type __stdcall #define PROXY_DECLARE_NONSTD(type) __declspec(dllexport) type #define PROXY_DECLARE_DATA __declspec(dllexport) #else #define PROXY_DECLARE(type) __declspec(dllimport) type __stdcall #define PROXY_DECLARE_NONSTD(type) __declspec(dllimport) type #define PROXY_DECLARE_DATA __declspec(dllimport) #endif Regards R=FCdiger Von: Thomas Eckert [mailto:thomas.r.w.eckert@gmail.com] Gesendet: Freitag, 29. November 2013 18:36 An: dev@httpd.apache.org Betreff: adding hook into mod_auth_form 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 =3D apr_pcalloc(p, sizeof(*conf)); @@ -1200,6 +1208,9 @@ static int authenticate_form_logout_handler(request_r= ec * r) conf =3D ap_get_module_config(r->per_dir_config, &auth_form_module); + /* run the form logout hook as long as the apache session still contai= ns 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 b= ut I figured since I was adding this to modules/aaa/mod_auth_form.c and include/mod_auth.h it was not relevant. I t= ried 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_r= ec* 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 =3D apr_pcalloc(p, sizeof(*conf)); @@ -1200,6 +1208,9 @@ static int authenticate_form_logout_handler(request_r= ec * r) conf =3D ap_get_module_config(r->per_dir_config, &auth_form_module); + /* run the form logout hook as long as the apache session still contai= ns 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: retu= rn 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: expect= ed 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.) --_000_AB1691BE05AE7F4992697F2A0835627A948D875CVOEXM10Winterna_ Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable

I guess yo= ur second example is correct (with EXTERNAL), but you miss the following be= fore in the header file (example from mod_proxy):

 = ;

/* Create = a set of PROXY_DECLARE(type), PROXY_DECLARE_NONSTD(type) and

* PROXY_DE= CLARE_DATA with appropriate export and import tags for the platform

*/

#if !defin= ed(WIN32)

#define PR= OXY_DECLARE(type)         &nbs= p;  type

#define PR= OXY_DECLARE_NONSTD(type)     type

#define PR= OXY_DECLARE_DATA

#elif defi= ned(PROXY_DECLARE_STATIC)

#define PR= OXY_DECLARE(type)         &nbs= p;  type __stdcall

#define PR= OXY_DECLARE_NONSTD(type)     type

#define PR= OXY_DECLARE_DATA

#elif defi= ned(PROXY_DECLARE_EXPORT)

#define PR= OXY_DECLARE(type)         &nbs= p;  __declspec(dllexport) type __stdcall

#define PR= OXY_DECLARE_NONSTD(type)     __declspec(dllexport) type=

#define PR= OXY_DECLARE_DATA          = ;   __declspec(dllexport)

#else=

#define PR= OXY_DECLARE(type)          &nb= sp; __declspec(dllimport) type __stdcall

#define PR= OXY_DECLARE_NONSTD(type)     __declspec(dllimport) type=

#define PR= OXY_DECLARE_DATA          = ;   __declspec(dllimport)

#endif

 = ;

Regards

 = ;

R=FCdiger<= o:p>

 = ;

Von: Thomas Ec= kert [mailto:thomas.r.w.eckert@gmail.com]
Gesendet: Freitag, 29. November 2013 18:36
An: dev@httpd.apache.org
Betreff: adding hook into mod_auth_form

 

 

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,=
            &nb= sp;            (requ= est_rec*, const char*, const char*,
            &nb= sp;            = 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 =3D apr_pcalloc(p, size= of(*conf));
@@ -1200,6 +1208,9 @@ static int authenticate_form_logout_handler(reque= st_rec * r)
 
     conf =3D ap_get_module_config(r->per_dir_config= , &auth_form_module);
 
+    /* run the form logout hook as long as the apache s= ession still contains useful data */
+    ap_run_form_logout_handler(r);
+
     /* remove the username and password, effectively l= ogging the user out */
     set_session_auth(r, NULL, NULL, NULL);<= /p>

but keep getting

  server/.libs/libmain.a(exports.o):(.data+0x11dc): undefined refe= rence to `ap_hook_form_logout_handler'
  server/.libs/libmain.a(exports.o):(.data+0x11e0): undefined refe= rence to `ap_hook_get_form_logout_handler'
  server/.libs/libmain.a(exports.o):(.data+0x11e4): undefined refe= rence to `ap_run_form_logout_handler'

I read the comment in AP_IMPLEMENT_HOOK_RUN_ALL rega= rding 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 differen= t 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,=
            &nb= sp;            (requ= est_rec*, const char*, const char*,
            &nb= sp;            = const char*, const char*));
 
+APR_DECLARE_EXTERNAL_HOOK(auth, AUTH, int, form_logout_handler, (reque= st_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_handl= er, (request_rec* r), (r), OK, DECLINED)
+
 static void *create_auth_form_dir_config(apr_pool_t * p, char *d)
 {
     auth_form_config_rec *conf =3D apr_pcalloc(p, size= of(*conf));
@@ -1200,6 +1208,9 @@ static int authenticate_form_logout_handler(reque= st_rec * r)
 
     conf =3D ap_get_module_config(r->per_dir_config= , &auth_form_module);
 
+    /* run the form logout hook as long as the apache s= ession still contains useful data */
+    auth_run_form_logout_handler(r);
+
     /* remove the username and password, effectively l= ogging 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: e= xpected declaration specifiers before 'auth_hook_form_logout_handler'<= /o:p>

so I guess there's a = bit more work required for setting up a new namespace/link prefix.

Back with the first a= ppraoch (using AP_DECLARE_HOOK and friends) I compared this with other hook= s, 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 di= screpancies with my AP_DECLARE* patch.

Anyone care to shed some light on this for me ? Is i= t preferrable to get it done via AP_DECLARE_*and friends or should I use AP= R_DECLARE_* and if so,

then how would I take= care of the above mentioned error messages ?

(If anyone is interested in the "why": I n= eed to clean up data in my custom form auth provider on logout. I figured t= he proper way was to do this via a hook.)

--_000_AB1691BE05AE7F4992697F2A0835627A948D875CVOEXM10Winterna_--