I saw those but figured since I was not using any AUTH_DECLARE I would be
fine. I'm now using

diff --git a/include/mod_auth.h b/include/mod_auth.h
index 9b9561e..8807a5c 100644
--- a/include/mod_auth.h
+++ b/include/mod_auth.h
@@ -134,6 +134,30 @@ APR_DECLARE_OPTIONAL_FN(void, ap_authn_cache_store,
                         (request_rec*, const char*, const char*,
                          const char*, const char*));

+/* Create a set of AUTH_DECLARE(type), AUTH_DECLARE_NONSTD(type) and
+ * AUTH_DECLARE_DATA with appropriate export and import tags for the
platform
+ */
+
+#if !defined(WIN32)
+  #define AUTH_DECLARE(type)         type
+  #define AUTH_DECLARE_NONSTD(type)  type
+  #define AUTH_DECLARE_DATA
+#elif defined(AUTH_DECLARE_STATIC)
+  #define AUTH_DECLARE(type)         type __stdcall
+  #define AUTH_DECLARE_NONSTD(type)  type
+  #define AUTH_DECLARE_DATA
+#elif defined(AUTH_DECLARE_EXPORT)
+  #define AUTH_DECLARE(type)         __declspec(dllexport) type __stdcall
+  #define AUTH_DECLARE_NONSTD(type)  __declspec(dllexport) type
+  #define AUTH_DECLARE_DATA          __declspec(dllexport)
+#else
+  #define AUTH_DECLARE(type)         __declspec(dllimport) type __stdcall
+  #define AUTH_DECLARE_NONSTD(type)  __declspec(dllimport) type
+  #define AUTH_DECLARE_DATA          __declspec(dllimport)
+#endif
+
+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..317db2f 100644
--- a/modules/aaa/mod_auth_form.c
+++ b/modules/aaa/mod_auth_form.c
@@ -1200,6 +1202,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);

@@ -1298,3 +1303,9 @@ AP_DECLARE_MODULE(auth_form) =
     auth_form_cmds,              /* command apr_table_t */
     register_hooks               /* register hooks */
 };
+
+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)


and it compiles/links fine but loading my module I get "undefined symbol:
auth_hook_form_logout_handler". Looking into mod_auth_form.so (readelf -a)
I don't see any symbol "auth_hook_form_logout_handler" nor anything close
to it. The only hook related symbols in mod_auth_form.so are ap_hook_ stuff.

The reason why I didn't include those macros in the first place is that I'm
running on Linux (SLES) and figured they would do exactly nothing for me
because
  #if !defined(WIN32)
    #define AUTH_DECLARE(type)         type
    #define AUTH_DECLARE_NONSTD(type)  type
    #define AUTH_DECLARE_DATA
  #elif (...)

Feels like I'm missing something obvious here..



On Fri, Nov 29, 2013 at 8:52 PM, Plüm, Rüdiger, Vodafone Group <
ruediger.pl...@vodafone.com> wrote:

>  I guess your second example is correct (with EXTERNAL), but you miss the
> following 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
> platform
>
> */
>
> #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üdiger
>
>
>
> *Von:* Thomas Eckert [mailto:thomas.r.w.eck...@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 = 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.)
>

Reply via email to