mod_presence: Re-probe for contacts presence after outgoing 'subscribed' (fixes ...
[prosody.git] / prosodyctl
index 88daf11b16296b645134090395ddfceb66e8ec78..4c3ae981521e6ee2b109589fc729ba09af18cf45 100755 (executable)
@@ -220,6 +220,7 @@ local error_messages = setmetatable({
                ["no-such-host"] = "The given hostname does not exist in the config";
                ["unable-to-save-data"] = "Unable to store, perhaps you don't have permission?";
                ["no-pidfile"] = "There is no 'pidfile' option in the configuration file, see http://prosody.im/doc/prosodyctl#pidfile for help";
+               ["invalid-pidfile"] = "The 'pidfile' option in the configuration file is not a string, see http://prosody.im/doc/prosodyctl#pidfile for help";
                ["no-posix"] = "The mod_posix module is not enabled in the Prosody config file, see http://prosody.im/doc/prosodyctl for more info";
                ["no-such-method"] = "This module has no commands";
                ["not-running"] = "Prosody is not running";
@@ -268,6 +269,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 +281,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 +320,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 +359,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]]
@@ -370,7 +373,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
 
@@ -546,7 +548,7 @@ function commands.about(arg)
                print("  "..path);
        end
        print("");
-       local luarocks_status = (pcall(require, "luarocks.loader") and "Installed ("..(luarocks.cfg.program_version or "2.x+")..")")
+       local luarocks_status = (pcall(require, "luarocks.loader") and "Installed ("..(package.loaded["luarocks.cfg"].program_version or "2.x+")..")")
                or (pcall(require, "luarocks.require") and "Installed (1.x)")
                or "Not installed";
        print("LuaRocks:        ", luarocks_status);
@@ -670,6 +672,11 @@ function cert_commands.config(arg)
                                        v = arg[1]
                                elseif k == "emailAddress" then
                                        v = "xmpp@" .. arg[1];
+                               elseif k == "countryName" then
+                                       local tld = arg[1]:match"%.([a-z]+)$";
+                                       if tld and #tld == 2 and tld ~= "uk" then
+                                               v = tld:upper();
+                                       end
                                end
                                nv = show_prompt(("%s (%s):"):format(k, nv or v));
                                nv = (not nv or nv == "") and v or nv;
@@ -679,7 +686,12 @@ function cert_commands.config(arg)
                                conf.distinguished_name[k] = nv ~= "." and nv or nil;
                        end
                end
-               local conf_file = io.open(conf_filename, "w");
+               local conf_file, err = io.open(conf_filename, "w");
+               if not conf_file then
+                       show_warning("Could not open OpenSSL config file for writing");
+                       show_warning(err);
+                       os.exit(1);
+               end
                conf_file:write(conf:serialize());
                conf_file:close();
                print("");