Project

General

Profile

How to get the plugin config from a handler

Added by cfsmp3 20 days ago

I'm porting some custom changes from 1.4.35 to 1.4.45. They happen to be in the auth code, which I saw was quited changed.

in this function

static handler_t mod_auth_check_basic(server *srv, connection *con, void *p_d, const struct http_auth_require_t *require, const struct http_auth_backend_t *backend) {

p_d is always NULL when the function is called. The default implementation inside that function doesn't need the config (it has UNUSED (p_d) )

But I do. I can't find how to make sure p_d is passed with the actual plugin config.

Looks like the function is called through a couple layers of functions pointers, plus it's registered in a tuple that has p_d set up as NULL (and cannot be changed to the actual value because it's static which means all parts of the tuple needs to be constants).

So well, how I can have that function receive a no NULL p_d?


Replies (3)

RE: How to get the plugin config from a handler - Added by cfsmp3 20 days ago

Adding to this, I've "solved" it by directly passing p_d from the caller, like this:

static handler_t mod_auth_uri_handler(server *srv, connection *con, void *p_d) {
...
- return scheme->checkfn(srv, con, scheme->p_d, dauth->require, p->conf.auth_backend);
+ return scheme->checkfn(srv, con, p_d, dauth->require, p->conf.auth_backend);

So I replaced scheme->p_d (which is NULL and I don't know how to change that)with the p_d that handler_t mod_auth_uri_handler.

This is working for me, but most likely it's breaking other stuff I haven't noticed yet, and well, I'd like not to butcher the code :-)

RE: How to get the plugin config from a handler - Added by gstrauss 13 days ago

cfsmp3 I'll have to look a bit more closely at the code later this week. Auth occurs early in request, and there may be complications based on what info is available at the time of auth processing in complex lighttpd configs.

RE: How to get the plugin config from a handler - Added by gstrauss 8 days ago

Are you using your module (plugin_data *) to as a singleton? If so, see 'plugin_data_singleton' in mod_extforward.c and mod_openssl.c in lighttpd git master.

If you need to patch configuration based on the current request, then you do not need (plugin_data *) to do so -- just modify your patch_connection() routine to fill in a pointer to your module (plugin_config), which you can store temporarily on the stack.

    (1-3/3)