aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/componentmanager.lua11
-rw-r--r--core/hostmanager.lua2
-rw-r--r--core/modulemanager.lua1
-rw-r--r--plugins/mod_saslauth.lua8
-rw-r--r--util-src/Makefile15
-rw-r--r--util-src/lsignal.c2
-rw-r--r--util-src/pposix.c14
7 files changed, 37 insertions, 16 deletions
diff --git a/core/componentmanager.lua b/core/componentmanager.lua
index 08868236..34f97c25 100644
--- a/core/componentmanager.lua
+++ b/core/componentmanager.lua
@@ -14,6 +14,7 @@ local configmanager = require "core.configmanager";
local modulemanager = require "core.modulemanager";
local core_route_stanza = core_route_stanza;
local jid_split = require "util.jid".split;
+local fire_event = require "core.eventmanager".fire_event;
local events_new = require "util.events".new;
local st = require "util.stanza";
local hosts = hosts;
@@ -51,12 +52,14 @@ function load_enabled_components(config)
for host, host_config in pairs(defined_hosts) do
if host ~= "*" and ((host_config.core.enabled == nil or host_config.core.enabled) and type(host_config.core.component_module) == "string") then
- hosts[host] = { type = "component", host = host, connected = false, s2sout = {}, events = events_new() };
+ hosts[host] = create_component(host);
+ hosts[host].connected = false;
components[host] = default_component_handler;
local ok, err = modulemanager.load(host, host_config.core.component_module);
if not ok then
log("error", "Error loading %s component %s: %s", tostring(host_config.core.component_module), tostring(host), tostring(err));
else
+ fire_event("component-activated", host, host_config);
log("debug", "Activated %s component: %s", host_config.core.component_module, host);
end
end
@@ -80,9 +83,9 @@ function handle_stanza(origin, stanza)
end
end
-function create_component(host, component)
+function create_component(host, component, events)
-- TODO check for host well-formedness
- return { type = "component", host = host, connected = true, s2sout = {}, events = events_new() };
+ return { type = "component", host = host, connected = true, s2sout = {}, events = events or events_new() };
end
function register_component(host, component, session)
@@ -90,7 +93,7 @@ function register_component(host, component, session)
local old_events = hosts[host] and hosts[host].events;
components[host] = component;
- hosts[host] = session or create_component(host, component);
+ hosts[host] = session or create_component(host, component, old_events);
-- Add events object if not already one
if not hosts[host].events then
diff --git a/core/hostmanager.lua b/core/hostmanager.lua
index ba363273..4934e7b2 100644
--- a/core/hostmanager.lua
+++ b/core/hostmanager.lua
@@ -24,7 +24,7 @@ local function load_enabled_hosts(config)
local defined_hosts = config or configmanager.getconfig();
for host, host_config in pairs(defined_hosts) do
- if host ~= "*" and (host_config.core.enabled == nil or host_config.core.enabled) then
+ if host ~= "*" and (host_config.core.enabled == nil or host_config.core.enabled) and not host_config.core.component_module then
activate(host, host_config);
end
end
diff --git a/core/modulemanager.lua b/core/modulemanager.lua
index 250551ed..a1ed8981 100644
--- a/core/modulemanager.lua
+++ b/core/modulemanager.lua
@@ -96,6 +96,7 @@ function load_modules_for_host(host)
end
end
eventmanager.add_event_hook("host-activated", load_modules_for_host);
+eventmanager.add_event_hook("component-activated", load_modules_for_host);
--
function load(host, module_name, config)
diff --git a/plugins/mod_saslauth.lua b/plugins/mod_saslauth.lua
index 32269221..f196e483 100644
--- a/plugins/mod_saslauth.lua
+++ b/plugins/mod_saslauth.lua
@@ -52,14 +52,14 @@ local function handle_status(session, status)
if status == "failure" then
session.sasl_handler = nil;
elseif status == "success" then
- if not session.sasl_handler.username then -- TODO move this to sessionmanager
+ local username = nodeprep(session.sasl_handler.username);
+ session.sasl_handler = nil;
+ if not username then -- TODO move this to sessionmanager
module:log("warn", "SASL succeeded but we didn't get a username!");
- session.sasl_handler = nil;
session:reset_stream();
return;
end
- sm_make_authenticated(session, session.sasl_handler.username);
- session.sasl_handler = nil;
+ sm_make_authenticated(session, username);
session:reset_stream();
end
end
diff --git a/util-src/Makefile b/util-src/Makefile
index 3b7ca7bc..fdf97c53 100644
--- a/util-src/Makefile
+++ b/util-src/Makefile
@@ -24,21 +24,28 @@ clean:
encodings.o: encodings.c
$(CC) $(CFLAGS) -I$(LUA_INCDIR) -c -o encodings.o encodings.c
encodings.so: encodings.o
- export MACOSX_DEPLOYMENT_TARGET="10.3"; $(LD) $(LFLAGS) -o encodings.so encodings.o -L$(LUA_LIBDIR) -llua$(LUA_SUFFIX) -lidn
+ MACOSX_DEPLOYMENT_TARGET="10.3"; export MACOSX_DEPLOYMENT_TARGET;
+ $(LD) $(LFLAGS) -o encodings.so encodings.o -L$(LUA_LIBDIR) -llua$(LUA_SUFFIX) -lidn
hashes.o: hashes.c
$(CC) $(CFLAGS) -I$(LUA_INCDIR) -c -o hashes.o hashes.c
hashes.so: hashes.o
- export MACOSX_DEPLOYMENT_TARGET="10.3"; $(LD) $(LFLAGS) -o hashes.so hashes.o -L$(LUA_LIBDIR) -llua$(LUA_SUFFIX) -lcrypto
+ MACOSX_DEPLOYMENT_TARGET="10.3";
+ export MACOSX_DEPLOYMENT_TARGET;
+ $(LD) $(LFLAGS) -o hashes.so hashes.o -L$(LUA_LIBDIR) -llua$(LUA_SUFFIX) -lcrypto
pposix.o: pposix.c
$(CC) $(CFLAGS) -I$(LUA_INCDIR) -c -o pposix.o pposix.c
pposix.so: pposix.o
- export MACOSX_DEPLOYMENT_TARGET="10.3"; $(LD) $(LFLAGS) -o pposix.so pposix.o -L$(LUA_LIBDIR) -llua$(LUA_SUFFIX)
+ MACOSX_DEPLOYMENT_TARGET="10.3";
+ export MACOSX_DEPLOYMENT_TARGET;
+ $(LD) $(LFLAGS) -o pposix.so pposix.o -L$(LUA_LIBDIR) -llua$(LUA_SUFFIX)
lsignal.o: lsignal.c
$(CC) $(CFLAGS) -I$(LUA_INCDIR) -c -o lsignal.o lsignal.c
signal.so: lsignal.o
- export MACOSX_DEPLOYMENT_TARGET="10.3"; $(LD) $(LFLAGS) -o signal.so lsignal.o
+ MACOSX_DEPLOYMENT_TARGET="10.3";
+ export MACOSX_DEPLOYMENT_TARGET;
+ $(LD) $(LFLAGS) -o signal.so lsignal.o
diff --git a/util-src/lsignal.c b/util-src/lsignal.c
index 158efcd6..80799e4a 100644
--- a/util-src/lsignal.c
+++ b/util-src/lsignal.c
@@ -301,7 +301,7 @@ static int l_raise(lua_State *L)
return 1;
}
-#ifdef _POSIX_SOURCE
+#if defined _POSIX_SOURCE || (defined(sun) || defined(__sun))
/* define some posix only functions */
diff --git a/util-src/pposix.c b/util-src/pposix.c
index d27a84b1..265245e0 100644
--- a/util-src/pposix.c
+++ b/util-src/pposix.c
@@ -91,10 +91,14 @@ static int lc_daemonize(lua_State *L)
const char * const facility_strings[] = {
"auth",
+#if !(defined(sun) || defined(__sun))
"authpriv",
+#endif
"cron",
"daemon",
+#if !(defined(sun) || defined(__sun))
"ftp",
+#endif
"kern",
"local0",
"local1",
@@ -113,10 +117,14 @@ const char * const facility_strings[] = {
};
int facility_constants[] = {
LOG_AUTH,
+#if !(defined(sun) || defined(__sun))
LOG_AUTHPRIV,
+#endif
LOG_CRON,
LOG_DAEMON,
+#if !(defined(sun) || defined(__sun))
LOG_FTP,
+#endif
LOG_KERN,
LOG_LOCAL0,
LOG_LOCAL1,
@@ -365,11 +373,13 @@ int string2resource(const char *s) {
if (!strcmp(s, "CPU")) return RLIMIT_CPU;
if (!strcmp(s, "DATA")) return RLIMIT_DATA;
if (!strcmp(s, "FSIZE")) return RLIMIT_FSIZE;
- if (!strcmp(s, "MEMLOCK")) return RLIMIT_MEMLOCK;
if (!strcmp(s, "NOFILE")) return RLIMIT_NOFILE;
+ if (!strcmp(s, "STACK")) return RLIMIT_STACK;
+#if !(defined(sun) || defined(__sun))
+ if (!strcmp(s, "MEMLOCK")) return RLIMIT_MEMLOCK;
if (!strcmp(s, "NPROC")) return RLIMIT_NPROC;
if (!strcmp(s, "RSS")) return RLIMIT_RSS;
- if (!strcmp(s, "STACK")) return RLIMIT_STACK;
+#endif
return -1;
}