Stewart Smith wrote:
> On Sun, 2008-08-03 at 17:58 -0700, Brian Aker wrote:
>> Hi!
>>
>> I worked out an example PAM authentication plugin this weekend. This
>> is about what I learned:
>>
>> Server:
>>
>> There is quite a bit more that needs to be done on the server right now:
>> 1) Final cleanup of old security context.
>> 2) THD needs to be split out sooner then later.
>> 3) We need to private'ize more of THD.
>> 4) We use a VOID pointer to pass in a structure to plugins for init/
>> finalize. I keep finding myself wondering if that should be a base
>> class that we inherit from (aka I am starting to see certain patterns
>> reoccurring in plugins).
>
> I'm increasingly of the view that teh plugin init function should then
> call functions in the server to register functionality.
>
> not the existing behaviour of casting then filling out the struct passed
> in as void*.
>
> e.g.
>
> struct auth_basic foo = { blah, blah blah };
>
> plugin_foo_init()
> {
> register_auth_module(&foo);
> register_func_module(&f);
> }
-1
I would prefer not to get into the game of the plugin developer having
to know a different function for each type of plugin they develop. Just
do something like krow suggests with a base class inheritance:
class plugin_base
{
protected:
typedef enum
{
STORAGE_ENGINE
, AUTHORIZATION
, AUTHENTICATION
, FUNCTION
, PARSER
, TOASTER
} plugin_type;
public:
inline plugin_type get_type() { return plugin_type; }
}
class auth_basic :public plugin_base {
auth_basic():
plugin_type(AUTHORIZATION);
}
auth_basic= new my_auth_plugin(); /* Or could use a separate memory
allocator */
func_plugin= new my_func_plugin();
Then, just have a single:
plugin_auth_init()
{
register_plugin(auth_basic);
register_plugin(func_plugin);
};
That way, plugin developers just call a single register_plugin()
function and the kernel takes care of allocating/assigning the passed-in
pointer to the appropriate HASH of plugins for that plugin_type...
Anyway, I just scrapped up the code above. It's probably got errors,
I'm just whiteboarding here...
-jay
_______________________________________________
Mailing list: https://launchpad.net/~drizzle-discuss
Post to : [email protected]
Unsubscribe : https://launchpad.net/~drizzle-discuss
More help : https://help.launchpad.net/ListHelp