[rabbitmq-discuss] Creating an auth plugin (Kerberos)

Simon Lundström simlu at su.se
Tue Dec 11 18:50:19 GMT 2012

On Tue, 2012-12-11 at 17:13:50 +0000, Tim Watson wrote:
> If your plugin is packaged as an .ez file (which rabbit plugins usually are) then I wonder if the .so file is not accessible?

I don't think this is it, because...

> This is a known issue with drivers, as no operating system I know of will allow dynamic loading from a non file system location. On the other hand, I think rabbit unpacks plugins that are enabled into RABBITMQ_PLUGINS_EXPAND_DIR - can you see the dynamic library (.so or .dylib) file in there?

..I see my .so there and if I use a static path it "works".

> Anyway, my suspicion is that when you're loading the NIF, it is not in the file system location you think it is. This could be because of the way plugins are expanded, but I'm just guessing there TBH. More likely perhaps, the name that you pass to code:priv_dir/1 is wrong. You're currently using `begin {ok, A} = application:get_application(?MODULE), A end` and I wonder if that's returning what you think it is? And *also* do you know if the application is actually fully loaded (and its environment setup correctly in the erlang node's application controller) at the time which the on_load target is being called? Perhaps calling application:get_env/1 is  not such a good idea when initialising a NIF.

This is almost what I suspect happens, but...

> Instead of doing that, try hard coding it:
> init() ->
>   Kinit = filename:join(code:priv_dir(rabbit_auth_backend_kerberos), "/kinit.so"),
>   erlang:load_nif(Kinit, 0).

..this code how ever doesn't work. It gives me:

=ERROR REPORT==== 11-Dec-2012::19:42:17 ===
NEIN: {error,bad_name}

=ERROR REPORT==== 11-Dec-2012::19:42:17 ===
Error in process <0.346.0> on node 'rabbit at rabbitmq-test-disk01.it.su.se' with exit value: {function_clause,[{filename,join,[{error,bad_na

when I use the following code:

I'm thinking my module isn't loaded yet and so that's why it doesn't appear in the list of loaded apps/modules.

If I use a static path I get the same error message(s) as I said before ("undefined function rabbit_auth_backend_kerberos:check_user_login/2").

I'll try your other suggestion to put kinit in a seperate module.

- Simon

More information about the rabbitmq-discuss mailing list