jsxc / xmpp-cloud-auth

:key: Authentication hub for Nextcloud+JSXC→Prosody, ejabberd, saslauthd, Postfix
https://www.jsxc.org
MIT License
59 stars 18 forks source link

Problem with Prosody 0.11.0 #74

Closed Failure404 closed 5 years ago

Failure404 commented 5 years ago

Hi, after updating to Prosody 0.11.0 xcauth doesn't seem to work anymore. Maybe I am doing something wrong but I don't know how to fix this. Any help is greatly appreciated.

modulemanager error Error initializing module 'auth_external' on 'localhost': modules/mod_auth_external.lua:23: attempt to index global 'lpty' (a nil value) stack traceback: mod_auth_external.lua:23: in main chunk [C]: in function 'xpcall' /usr/lib/prosody/core/modulemanager.lua:178: in function 'do_load_module' /usr/lib/prosody/core/modulemanager.lua:256: in function 'load' /usr/lib/prosody/core/usermanager.lua:67: in function '?' /usr/lib/prosody/util/events.lua:79: in function </usr/lib/prosody/util/events.lua:75> (...tail calls...) /usr/lib/prosody/core/hostmanager.lua:108: in function 'activate' /usr/lib/prosody/core/hostmanager.lua:58: in function '?' /usr/lib/prosody/util/events.lua:79: in function </usr/lib/prosody/util/events.lua:75> (...tail calls...) /usr/lib/prosody/util/startup.lua:327: in function 'prepare_to_start' /usr/lib/prosody/util/startup.lua:548: in function 'f' /usr/lib/prosody/util/async.lua:139: in function 'func' /usr/lib/prosody/util/async.lua:127: in function </usr/lib/prosody/util/async.lua:125>

Failure404 commented 5 years ago

I seem to have fixed this by moving line 23 below line 36 in mod_auth_external.lua https://github.com/jsxc/xmpp-cloud-auth/blob/master/prosody-modules/mod_auth_external.lua

chriscroome commented 5 years ago

I fixed it by downgrading lua-event:

apt-cache madison lua-event
 lua-event | 0.4.5-0~stretch1 | https://packages.prosody.im/debian stretch/main amd64 Packages
 lua-event |    0.4.3-2 | https://deb.debian.org/debian stretch/main amd64 Packages
apt-get install lua-event=0.4.3-2
service prosody restart

@Failure404 I'll now try your fix…

chriscroome commented 5 years ago

I seem to have fixed this by moving line 23 below line 36 in mod_auth_external.lua https://github.com/jsxc/xmpp-cloud-auth/blob/master/prosody-modules/mod_auth_external.lua

This works for me too, thanks!

chriscroome commented 5 years ago

Actually, it appears to have fixed one server but not the other, so I have down graded all the servers and put the package on hold:

apt-mark hold lua-event
chriscroome commented 5 years ago

These are the errors in /var/log/prosody/prosody.err:

Nov 26 21:01:40 modulemanager   error   Error initializing module 'auth_external' on 'office.coops.tech': /usr/lib/prosody/modules/mod_auth_external.lua:23: attempt to index global 'lpty' (a nil value)
stack traceback:
        /usr/lib/prosody/modules/mod_auth_external.lua:23: in main chunk
        [C]: in function 'xpcall'
        /usr/lib/prosody/core/modulemanager.lua:178: in function 'do_load_module'
        /usr/lib/prosody/core/modulemanager.lua:256: in function 'load'
        /usr/lib/prosody/core/usermanager.lua:67: in function '?'
        /usr/lib/prosody/util/events.lua:79: in function </usr/lib/prosody/util/events.lua:75>
        (...tail calls...)
        /usr/lib/prosody/core/hostmanager.lua:108: in function 'activate'
        /usr/lib/prosody/core/hostmanager.lua:58: in function '?'
        /usr/lib/prosody/util/events.lua:79: in function </usr/lib/prosody/util/events.lua:75>
        (...tail calls...)
        /usr/lib/prosody/util/startup.lua:327: in function 'prepare_to_start'
        /usr/lib/prosody/util/startup.lua:548: in function 'f'
        /usr/lib/prosody/util/async.lua:139: in function 'func'
        /usr/lib/prosody/util/async.lua:127: in function </usr/lib/prosody/util/async.lua:125>
Nov 26 21:39:25 net.server      error   libevent not found, falling back to select()
Nov 26 22:20:05 net.server      error   libevent not found, falling back to select()

The last two probably came after downgrading.

chriscroome commented 5 years ago

Note that in /usr/lib/prosody/module I have mod_auth_external.lua symlinked to /usr/lib/prosody/modules/xcauth/mod_auth_external.lua-xcauth-version.

chriscroome commented 5 years ago

This is what I have in /usr/lib/prosody/modules/xcauth/mod_auth_external.lua-xcauth-version:

--
-- Prosody IM
-- Copyright (C) 2010 Waqas Hussain
-- Copyright (C) 2010 Jeff Mitchell
-- Copyright (C) 2013 Mikael Nordfeldth
-- Copyright (C) 2013 Matthew Wild, finally came to fix it all
--
-- This project is MIT/X11 licensed. Please see the
-- COPYING file in the source package for more information.
--

local usermanager = require "core.usermanager";
local new_sasl = require "util.sasl".new;
local server = require "net.server";
local have_async, async = pcall(require, "util.async");

local log = module._log;
local host = module.host;

local script_type = module:get_option_string("external_auth_protocol", "generic");
local command = module:get_option_string("external_auth_command", "");
local read_timeout = module:get_option_number("external_auth_timeout", 5);
local auth_processes = module:get_option_number("external_auth_processes", 1);

local lpty, pty_options;
if command:sub(1,1) == "@" then
        -- Use a socket connection
        lpty = module:require "pseudolpty";
        log("info", "External auth with pseudolpty socket to %s", command:sub(2));
        pty_options = { log = log };
else
        lpty = assert(require "lpty", "mod_auth_external requires lpty: https://modules.prosody.im/mod_auth_external.html#installation");
        log("info", "External auth with pty command %s", command);
        pty_options = { throw_errors = false, no_local_echo = true, use_path = false };
end
-- following line moved from 24:
local blocking = module:get_option_boolean("external_auth_blocking", not(have_async and server.event and lpty.getfd));
assert(script_type == "ejabberd" or script_type == "generic",
        "Config error: external_auth_protocol must be 'ejabberd' or 'generic'");
assert(not host:find(":"), "Invalid hostname");
Failure404 commented 5 years ago

/usr/lib/prosody/modules/mod_auth_external.lua is being used but you modified /usr/lib/prosody/modules/xcauth/mod_auth_external.lua-xcauth-version ? edit: overlooked that you symlink it - maybe thats the problem? The error message clearly states line 23 in /usr/lib/prosody/modules/mod_auth_external.lua but in your symlinked mod_auth_external.lua-xcauth-version there is nothing with lpty near line 23 anymore...

chriscroome commented 5 years ago

@Failure404 thanks for looking at this, I have just doubled checked and your fix does indeed work, sorry for my confusion above.

sualko commented 5 years ago

@Failure404 it would be awesome if you could open a pull request. You should also be able to make this online via https://github.com/jsxc/xmpp-cloud-auth/edit/master/prosody-modules/mod_auth_external.lua