From fa962495db1effce1b52c7f73b06e6ef2e0d2ac9 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Thu, 31 Jul 2014 06:56:21 +0100 Subject: configmanager: nameprep VirtualHost and Component names --- core/configmanager.lua | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/core/configmanager.lua b/core/configmanager.lua index d175b54b..c8aa7b9a 100644 --- a/core/configmanager.lua +++ b/core/configmanager.lua @@ -17,6 +17,9 @@ local envload = require"util.envload".envload; local deps = require"util.dependencies"; local path_sep = package.config:sub(1,1); +local have_encodings, encodings = pcall(require, "util.encodings"); +local nameprep = have_encodings and encodings.stringprep.nameprep or function (host) return host:lower(); end + module "configmanager" local parsers = {}; @@ -170,6 +173,7 @@ do rawset(env, "__currenthost", "*") -- Default is global function env.VirtualHost(name) + name = nameprep(name); if rawget(config, name) and rawget(config[name], "component_module") then error(format("Host %q clashes with previously defined %s Component %q, for services use a sub-domain like conference.%s", name, config[name].component_module:gsub("^%a+$", { component = "external", muc = "MUC"}), name, name), 0); @@ -187,6 +191,7 @@ do env.Host, env.host = env.VirtualHost, env.VirtualHost; function env.Component(name) + name = nameprep(name); if rawget(config, name) and rawget(config[name], "defined") and not rawget(config[name], "component_module") then error(format("Component %q clashes with previously defined Host %q, for services use a sub-domain like conference.%s", name, name, name), 0); -- cgit v1.2.3 From 318fd416c990cbaa851384ebfbd02d861c549a37 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Thu, 31 Jul 2014 06:58:15 +0100 Subject: prosodyctl: Improve JID splitting and normalization for adduser/passwd/deluser --- prosodyctl | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/prosodyctl b/prosodyctl index d341a75b..6a6414f6 100755 --- a/prosodyctl +++ b/prosodyctl @@ -268,6 +268,8 @@ local show_yesno = prosodyctl.show_yesno; local show_prompt = prosodyctl.show_prompt; local read_password = prosodyctl.read_password; +local jid_split = require "util.jid".prepped_split; + local prosodyctl_timeout = (config.get("*", "prosodyctl_timeout") or 5) * 2; ----------------------- local commands = {}; @@ -278,7 +280,7 @@ function commands.adduser(arg) show_usage([[adduser JID]], [[Create the specified user account in Prosody]]); return 1; end - local user, host = arg[1]:match("([^@]+)@(.+)"); + local user, host = jid_split(arg[1]); if not user and host then show_message [[Failed to understand JID, please supply the JID you want to create]] show_usage [[adduser user@host]] @@ -317,7 +319,7 @@ function commands.passwd(arg) show_usage([[passwd JID]], [[Set the password for the specified user account in Prosody]]); return 1; end - local user, host = arg[1]:match("([^@]+)@(.+)"); + local user, host = jid_split(arg[1]) if not user and host then show_message [[Failed to understand JID, please supply the JID you want to set the password for]] show_usage [[passwd user@host]] @@ -356,7 +358,7 @@ function commands.deluser(arg) show_usage([[deluser JID]], [[Permanently remove the specified user account from Prosody]]); return 1; end - local user, host = arg[1]:match("([^@]+)@(.+)"); + local user, host = jid_split(arg[1]); if not user and host then show_message [[Failed to understand JID, please supply the JID you want to set the password for]] show_usage [[passwd user@host]] -- cgit v1.2.3 From 56339d76da26b41c723b5b44d660f9462622a3b4 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Thu, 31 Jul 2014 06:59:12 +0100 Subject: prosodyctl: Remove nonsensical warning --- prosodyctl | 1 - 1 file changed, 1 deletion(-) diff --git a/prosodyctl b/prosodyctl index 6a6414f6..38dac363 100755 --- a/prosodyctl +++ b/prosodyctl @@ -372,7 +372,6 @@ function commands.deluser(arg) if not hosts[host] then show_warning("The host '%s' is not listed in the configuration file (or is not enabled).", host) - show_warning("The user will not be able to log in until this is changed."); hosts[host] = make_host(host); end -- cgit v1.2.3