[rabbitmq-discuss] Creating an auth plugin (Kerberos)
Tim Watson
tim at rabbitmq.com
Wed Jan 30 13:42:03 GMT 2013
Hi Simon
On 30 Jan 2013, at 12:31, Simon Lundström wrote:
> On Fri, 2012-12-28 at 14:10:25 +0000, Tim Watson wrote:
>> Here's what I did. Firstly, I tweaked the package.mk so that the plugin got included in the release bundle,
>
> Please elaborate on this. Why should I do this? I use `make dist` when I
> build the plugin (see below also).
>
Sure, but if you don't put `RELEASABLE:=true` in the package.mk then the plugin doesn't make it into the right directory.
>> plus I had to add some noise to the compiler flags in order to build the native library on 64bit Mac OS (Lion).
>
> Hm, I'm on 64bit Mac OS (Lion 10.7.5) and I don't get any noise. I'm
> using some flags though:
>
> rabbitmq-public-umbrella/rabbitmq-auth-backend-kerberos$ LDFLAGS="-L/usr/heimdal/lib -undefined dynamic_lookup -dynamiclib" CFLAGS="-I/usr/heimdal/include -I/usr/local/Cellar/erlang/R15B02/lib/erlang/usr/include/" make dist
>
Well that's fine, I did it through CC_OPTS in package.mk like so:
CC_OPTS:=-g -Wall -pedantic -std=c99 -O2 -arch x86_64 -fPIC -bundle -flat_namespace -undefined suppress -I/Users/t4/Library/Erlang/Current/lib/erlang/erts-5.9.1/include $(CFLAGS) $(LDFLAGS)
If your erlang is 32bit you wouldn't need the -arch check, and I suppose '-undefined suppress' isn't very structured. :/
>> Then I made sure that the hard coded path which the on_load function uses to locate the image was exactly where $RABBITMQ_PLUGINS_EXPAND_DIR points to, plus the app+vsn/priv/.... etc.
>
> Hm, how did you change the path for on_load?
>
Like I said below, I changed it to look in the *right* place:
Kinit = "/tmp/rabbitmq-rabbit-plugins-scratch/rabbitmq_auth_backend_kerberos-0.0.0/priv/kinit",
erlang:load_nif(Kinit, 0).
>
>> I suspect your problem is that you're not calculating the location of the directory into which the plugins are exploded properly. Take a look at rabbit_plugins:setup/0 to see how all these things are calculated, then try and mimic this behaviour to locate your target directory dynamically (and correctly!) at runtime.
>
> Ah, it seems that you are using 3.x (because I can't find the setup/0 function
> in rabbitmq-server/src/rabbit_plugins.erl)? I'm still on 2.8.7 but I'd recon
> this is the time to upgrade and make my plugin >3.x only.
>
Yes - that's a good plan anyway. Like I said, you can use some os:getenv/1 calls to find the right directory path to look in, and rabbit_plugins:setup/0 uses these so you can copy the approach from there. From what I recall, you can use RABBITMQ_PLUGINS_SCRATCH_DIR but I'm not 100% sure that gets set in all cases. It's probably worth looking at the various scripts in ../rabbitmq-server/scripts to figure out which environment variables are *always* set and the generate a relative path using the filename module.
Cheers,
Tim
More information about the rabbitmq-discuss
mailing list