Software / code / prosody
Comparison
prosodyctl @ 4827:fefbfd76d2d3
prosodyctl: Show an error if the user doesn't supply a hostname to the certificate commands
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Wed, 09 May 2012 01:11:27 +0200 |
| parent | 4826:1c4852da78c8 |
| child | 4872:b2059452fb55 |
comparison
equal
deleted
inserted
replaced
| 4826:1c4852da78c8 | 4827:fefbfd76d2d3 |
|---|---|
| 203 local error_messages = setmetatable({ | 203 local error_messages = setmetatable({ |
| 204 ["invalid-username"] = "The given username is invalid in a Jabber ID"; | 204 ["invalid-username"] = "The given username is invalid in a Jabber ID"; |
| 205 ["invalid-hostname"] = "The given hostname is invalid"; | 205 ["invalid-hostname"] = "The given hostname is invalid"; |
| 206 ["no-password"] = "No password was supplied"; | 206 ["no-password"] = "No password was supplied"; |
| 207 ["no-such-user"] = "The given user does not exist on the server"; | 207 ["no-such-user"] = "The given user does not exist on the server"; |
| 208 ["no-such-host"] = "The given hostname does not exist in the config"; | |
| 208 ["unable-to-save-data"] = "Unable to store, perhaps you don't have permission?"; | 209 ["unable-to-save-data"] = "Unable to store, perhaps you don't have permission?"; |
| 209 ["no-pidfile"] = "There is no 'pidfile' option in the configuration file, see http://prosody.im/doc/prosodyctl#pidfile for help"; | 210 ["no-pidfile"] = "There is no 'pidfile' option in the configuration file, see http://prosody.im/doc/prosodyctl#pidfile for help"; |
| 210 ["no-posix"] = "The mod_posix module is not enabled in the Prosody config file, see http://prosody.im/doc/prosodyctl for more info"; | 211 ["no-posix"] = "The mod_posix module is not enabled in the Prosody config file, see http://prosody.im/doc/prosodyctl for more info"; |
| 211 ["no-such-method"] = "This module has no commands"; | 212 ["no-such-method"] = "This module has no commands"; |
| 212 ["not-running"] = "Prosody is not running"; | 213 ["not-running"] = "Prosody is not running"; |
| 646 conf_file:close(); | 647 conf_file:close(); |
| 647 print(""); | 648 print(""); |
| 648 show_message("Config written to " .. conf_filename); | 649 show_message("Config written to " .. conf_filename); |
| 649 return nil, conf_filename; | 650 return nil, conf_filename; |
| 650 else | 651 else |
| 651 show_usage("cert config HOSTNAME", "generates config for OpenSSL") | 652 show_usage("cert config HOSTNAME", "builds a config for OpenSSL") |
| 652 end | 653 end |
| 653 end | 654 end |
| 654 | 655 |
| 655 function cert_commands.key(arg) | 656 function cert_commands.key(arg) |
| 656 if #arg >= 1 and arg[1] ~= "--help" then | 657 if #arg >= 1 and arg[1] ~= "--help" then |
| 712 | 713 |
| 713 function commands.cert(arg) | 714 function commands.cert(arg) |
| 714 if #arg >= 1 and arg[1] ~= "--help" then | 715 if #arg >= 1 and arg[1] ~= "--help" then |
| 715 local subcmd = table.remove(arg, 1); | 716 local subcmd = table.remove(arg, 1); |
| 716 if type(cert_commands[subcmd]) == "function" then | 717 if type(cert_commands[subcmd]) == "function" then |
| 718 if not hosts[arg[1]] then | |
| 719 show_message(error_messages["no-such-host"]); | |
| 720 return | |
| 721 end | |
| 717 return cert_commands[subcmd](arg); | 722 return cert_commands[subcmd](arg); |
| 718 end | 723 end |
| 719 end | 724 end |
| 720 show_usage("cert config|request|generate|key", "Helpers for X.509 certificates.") | 725 show_usage("cert config|request|generate|key", "Helpers for X.509 certificates.") |
| 721 end | 726 end |