Solved Problem with Prosody and LDAP authentication

The_Educated_Fool

New Member


Messages: 8

Hello!

I'm new to this forum and FreeBSD, so I hope I'm addressing my problem at the right location.
First of all I want to say thanks for this great community/ forum and that I already have learned much by reading through some of the threads here. :)

My problem:
I'm currently migrating my server from Linux (Debian) to FreeBSD (11.1).
I had Prosody running on my Linux server, using LDAP for user authentication. So I (should) have a working configuration for this.
When I now try to set this up the same way in FreeBSD, it seems like there is a problem with the 'auth_ldap' module in Prosody. I see the following error in Prosody's log:
Code:
Jan 08 20:36:11 general   info   Hello and welcome to Prosody version 0.10.0
Jan 08 20:36:11 general   info   Prosody is using the select backend for connection handling
Jan 08 20:36:11 modulemanager   error   Error initializing module 'auth_ldap' on '<myserver>': error loading module 'lualdap' from file '/usr/local/lib/lua/5.1/lualdap.so':
   /usr/local/lib/lua/5.1/lualdap.so: Undefined symbol "lua_setglobal"
stack traceback:
   /usr/local/lib/prosody/core/modulemanager.lua:31: in function </usr/local/lib/prosody/core/modulemanager.lua:31>
   [C]: at 0x00461710
   [C]: in function '_real_require'
   /usr/local/lib/prosody/../../bin/prosody:185: in function 'require'
   /usr/local/lib/prosody/modules/mod_auth_ldap.lua:5: in main chunk
   [C]: in function 'pcall'
   /usr/local/lib/prosody/core/modulemanager.lua:177: in function 'do_load_module'
   /usr/local/lib/prosody/core/modulemanager.lua:255: in function 'load'
   /usr/local/lib/prosody/core/usermanager.lua:66: in function </usr/local/lib/prosody/core/usermanager.lua:38>
   /usr/local/lib/prosody/util/events.lua:78: in function 'fire_event'
   /usr/local/lib/prosody/core/hostmanager.lua:113: in function 'activate'
   /usr/local/lib/prosody/core/hostmanager.lua:59: in function </usr/local/lib/prosody/core/hostmanager.lua:50>
   /usr/local/lib/prosody/util/events.lua:78: in function 'fire_event'
   /usr/local/lib/prosody/../../bin/prosody:358: in function 'prepare_to_start'
   /usr/local/lib/prosody/../../bin/prosody:427: in main chunk
   [C]: at 0x00404020

I've installed prosody (v 0.10.0) as package via pkg. It automatically installed some lua5.1 packages as well. Since I've read that prosody 0.10.0 can also run with lua5.2, I tried to change to that version of lua, but without success. (When I install lua5.2, pkg removes some of the related lua5.1 packages, which results in prosody gets removed as well.)

Does anyone have an idea what could be my problem? Is this maybe a bug in the latest prosody port? Should I report an issue for that?

Any help is welcome!

Thanks,
Fool
 

SirDice

Administrator
Staff member
Administrator
Moderator

Reaction score: 12,038
Messages: 38,489

It looks like an issue with LUA not being able to load the LDAP module, not an issue with LDAP itself.
Code:
Jan 08 20:36:11 modulemanager   error   Error initializing module 'auth_ldap' on '<myserver>': error loading module 'lualdap' from file '/usr/local/lib/lua/5.1/lualdap.so':
   /usr/local/lib/lua/5.1/lualdap.so: Undefined symbol "lua_setglobal"

What does pkg which /usr/local/lib/lua/5.1/lualdap.so output? I'm wondering where it came from as I can't seem to find any specific LUA LDAP modules.
 
OP
T

The_Educated_Fool

New Member


Messages: 8

Oh, I'm sorry!
Found my mistake for that: I installed, removed etc. lua5.1 and lua5.2 quite a lot. I now remember that I copied over the lualdap.so from the /usr/local/lib/lua/5.2 into the 5.1 folder because it wasn't available there.
So I assume the problem with the undefined symbol "lua_setglobal" comes from using a lua5.2 module with lua5.1. :(
pkg which /usr/local/lib/lua/5.1/lualdap.so therefore of course returns
Code:
/usr/local/lib/lua/5.1/lualdap.so was not found in the database
.

I now removed again everything from lua5.1, lua5.2 and prosody and did a fresh install of prosody via pkg install prosody.
Now the error message in prosody's log is a simple
Code:
Jan 09 21:12:09 modulemanager   error   Error initializing module 'auth_ldap' on '<myserver>': /usr/local/lib/prosody/../../bin/prosody:185: module 'lualdap' not found:
   no field package.preload['lualdap']
   no file '/usr/local/lib/prosody/lualdap.lua'
   no file '/usr/local/share/lua/5.1/lualdap.lua'
   no file '/usr/local/share/lua/5.1/lualdap/init.lua'
   no file '/usr/local/lib/lua/5.1/lualdap.lua'
   no file '/usr/local/lib/lua/5.1/lualdap/init.lua'
   no file '/usr/local/lib/prosody/lualdap.so'
   no file '/usr/local/lib/lua/5.1/lualdap.so'
   no file '/usr/local/lib/lua/5.1/loadall.so'

It seems like there is no lualdap module for lua5.1 available in FreeBSD, only for lua5.2 - right?
So the only solution seems to me to run Prosody with lua5.2. Does someone know how to do that?
I figured out that that I can modify the prosody script to use lua5.2 instead of lua5.1.
But when I install the necessary lua5.2 modules (e.g. lua52-luafilesystem), this will result in pkg to remove the related lua5.1 module and therefore the removal of prosody itself...

Any help is welcome - thanks!
 
OP
T

The_Educated_Fool

New Member


Messages: 8

Hi!

I was able to solve the problem. :)
Here's what I did:
I manually downloaded lualdap and the additionally required compat from github (https://github.com/luaforge/lualdap and https://github.com/luaforge/compat).
I then used the patch file from net/lualdap (which is configured for lua5.2 but not the required lua5.1 as I need it for Prosody) and patched the downloaded lualdap.c file with it.
Then I was able to successfully compile lualdap, install it and now it finally works! Hurray!
(Without the patch from net/lualdap I got segmentation faults.)

Fool

PS: How can I mark this thread as solved? I'm blind and cannot find it...
 

SirDice

Administrator
Staff member
Administrator
Moderator

Reaction score: 12,038
Messages: 38,489

The net/lualdap port appears to respect DEFAULT_VERSIONS. So just add this to /etc/make.conf in order to build it for LUA 5.1:
Code:
DEFAULT_VERSIONS+=lua=5.1
 
Top