From 241f825d41c4af2c99b5a56388bd2fe21f1098e6 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Tue, 29 Sep 2009 13:59:35 +0100 Subject: Makefile: Don't combine variable export with assignment for compatibility with other shells (thanks Filip) --- util-src/Makefile | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) 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 -- cgit v1.2.3 From 5407a9c88dc9ae485e6eb82f5482669b6556253f Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Tue, 29 Sep 2009 14:06:43 +0100 Subject: util.signal: Change ifdef to allow signal.kill() on Solaris (thanks Filip) --- util-src/lsignal.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 */ -- cgit v1.2.3 From d059f42d87dec4b77e0aad6fb1383bc95399d8c1 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Tue, 29 Sep 2009 14:22:02 +0100 Subject: util.pposix: Compatibility with Solaris systems (thanks Filip) --- util-src/pposix.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) 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; } -- cgit v1.2.3 From e094c8b08b002896c440c3b55785bcf119007c91 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Tue, 29 Sep 2009 19:05:32 +0100 Subject: util.encodings: Don't throw an error but return nil when passed nil or a non-string value --- util-src/encodings.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/util-src/encodings.c b/util-src/encodings.c index 65d7d501..bee4365c 100644 --- a/util-src/encodings.c +++ b/util-src/encodings.c @@ -124,8 +124,12 @@ static const luaL_Reg Reg_base64[] = static int stringprep_prep(lua_State *L, const Stringprep_profile *profile) { + if(!lua_isstring(L, 1)) { + lua_pushnil(L); + return 1; + } size_t len; - const char *s = luaL_checklstring(L, 1, &len); + const char *s = lua_tolstring(L, 1, &len); char string[1024]; int ret; if (len >= 1024) { -- cgit v1.2.3 From d937a3e04370ddb4a3bbb172e152b89ce8036cfd Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Tue, 29 Sep 2009 19:54:31 +0100 Subject: mod_saslauth: Prep username used for authenticating a session --- plugins/mod_saslauth.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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 -- cgit v1.2.3 From 3a70cdac4976bc5ee4cbac96800f8eae18621be1 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Wed, 30 Sep 2009 11:01:21 +0100 Subject: hostmanager: Only load vhosts, not components --- core/hostmanager.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 -- cgit v1.2.3 From 955ff89a519865808714c89025645c225df1637c Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Wed, 30 Sep 2009 11:02:31 +0100 Subject: componentmanager: Use create_component for, er, creating components --- core/componentmanager.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/componentmanager.lua b/core/componentmanager.lua index 08868236..a17d4091 100644 --- a/core/componentmanager.lua +++ b/core/componentmanager.lua @@ -51,7 +51,8 @@ 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 -- cgit v1.2.3 From afe32590a124663f31b680cce0dd3bfc14f34c4b Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Wed, 30 Sep 2009 11:03:11 +0100 Subject: componentmanager: Fire event on component activation --- core/componentmanager.lua | 2 ++ 1 file changed, 2 insertions(+) diff --git a/core/componentmanager.lua b/core/componentmanager.lua index a17d4091..208f42e4 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; @@ -58,6 +59,7 @@ function load_enabled_components(config) 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 -- cgit v1.2.3 From f9a8d01543ed2a8ed49ffcf4e9c3f24565a26bdd Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Wed, 30 Sep 2009 11:05:01 +0100 Subject: componentmanager: Preserve existing events table (if any) when registering a component --- core/componentmanager.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/componentmanager.lua b/core/componentmanager.lua index 208f42e4..34f97c25 100644 --- a/core/componentmanager.lua +++ b/core/componentmanager.lua @@ -83,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) @@ -93,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 -- cgit v1.2.3 From 271afa36733db02b9cace7261a16b8243505bf33 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Wed, 30 Sep 2009 11:05:26 +0100 Subject: modulemanager: Load modules for components, too --- core/modulemanager.lua | 1 + 1 file changed, 1 insertion(+) 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) -- cgit v1.2.3