Comparison

prosodyctl @ 8718:c23cdeac5b61

prosodyctl: Use prosody.hosts instead of _G.hosts
author Kim Alvefur <zash@zash.se>
date Thu, 29 Mar 2018 20:51:16 +0200
parent 8701:b7a22baaf55f
child 8787:5dbebb7627ef
comparison
equal deleted inserted replaced
8717:9ddd0fbbe53a 8718:c23cdeac5b61
100 if not host then 100 if not host then
101 show_message [[Please specify a JID, including a host. e.g. alice@example.com]]; 101 show_message [[Please specify a JID, including a host. e.g. alice@example.com]];
102 return 1; 102 return 1;
103 end 103 end
104 104
105 if not hosts[host] then 105 if not prosody.hosts[host] then
106 show_warning("The host '%s' is not listed in the configuration file (or is not enabled).", host) 106 show_warning("The host '%s' is not listed in the configuration file (or is not enabled).", host)
107 show_warning("The user will not be able to log in until this is changed."); 107 show_warning("The user will not be able to log in until this is changed.");
108 hosts[host] = startup.make_host(host); --luacheck: ignore 122/hosts 108 prosody.hosts[host] = startup.make_host(host); --luacheck: ignore 122
109 end 109 end
110 110
111 if prosodyctl.user_exists{ user = user, host = host } then 111 if prosodyctl.user_exists{ user = user, host = host } then
112 show_message [[That user already exists]]; 112 show_message [[That user already exists]];
113 return 1; 113 return 1;
139 if not host then 139 if not host then
140 show_message [[Please specify a JID, including a host. e.g. alice@example.com]]; 140 show_message [[Please specify a JID, including a host. e.g. alice@example.com]];
141 return 1; 141 return 1;
142 end 142 end
143 143
144 if not hosts[host] then 144 if not prosody.hosts[host] then
145 show_warning("The host '%s' is not listed in the configuration file (or is not enabled).", host) 145 show_warning("The host '%s' is not listed in the configuration file (or is not enabled).", host)
146 show_warning("The user will not be able to log in until this is changed."); 146 show_warning("The user will not be able to log in until this is changed.");
147 hosts[host] = startup.make_host(host); --luacheck: ignore 122/hosts 147 prosody.hosts[host] = startup.make_host(host); --luacheck: ignore 122
148 end 148 end
149 149
150 if not prosodyctl.user_exists { user = user, host = host } then 150 if not prosodyctl.user_exists { user = user, host = host } then
151 show_message [[That user does not exist, use prosodyctl adduser to create a new user]] 151 show_message [[That user does not exist, use prosodyctl adduser to create a new user]]
152 return 1; 152 return 1;
178 if not host then 178 if not host then
179 show_message [[Please specify a JID, including a host. e.g. alice@example.com]]; 179 show_message [[Please specify a JID, including a host. e.g. alice@example.com]];
180 return 1; 180 return 1;
181 end 181 end
182 182
183 if not hosts[host] then 183 if not prosody.hosts[host] then
184 show_warning("The host '%s' is not listed in the configuration file (or is not enabled).", host) 184 show_warning("The host '%s' is not listed in the configuration file (or is not enabled).", host)
185 hosts[host] = startup.make_host(host); --luacheck: ignore 122/hosts 185 prosody.hosts[host] = startup.make_host(host); --luacheck: ignore 122
186 end 186 end
187 187
188 if not prosodyctl.user_exists { user = user, host = host } then 188 if not prosodyctl.user_exists { user = user, host = host } then
189 show_message [[That user does not exist on this server]] 189 show_message [[That user does not exist on this server]]
190 return 1; 190 return 1;
524 local distinguished_name; 524 local distinguished_name;
525 if arg[#arg]:find("^/") then 525 if arg[#arg]:find("^/") then
526 distinguished_name = table.remove(arg); 526 distinguished_name = table.remove(arg);
527 end 527 end
528 local conf = openssl.config.new(); 528 local conf = openssl.config.new();
529 conf:from_prosody(hosts, configmanager, arg); 529 conf:from_prosody(prosody.hosts, configmanager, arg);
530 if distinguished_name then 530 if distinguished_name then
531 local dn = {}; 531 local dn = {};
532 for k, v in distinguished_name:gmatch("/([^=/]+)=([^/]+)") do 532 for k, v in distinguished_name:gmatch("/([^=/]+)=([^/]+)") do
533 table.insert(dn, k); 533 table.insert(dn, k);
534 dn[k] = v; 534 dn[k] = v;
749 if subcmd ~= "import" then -- hostnames are optional for import 749 if subcmd ~= "import" then -- hostnames are optional for import
750 if not arg[1] then 750 if not arg[1] then
751 show_message"You need to supply at least one hostname" 751 show_message"You need to supply at least one hostname"
752 arg = { "--help" }; 752 arg = { "--help" };
753 end 753 end
754 if arg[1] ~= "--help" and not hosts[arg[1]] then 754 if arg[1] ~= "--help" and not prosody.hosts[arg[1]] then
755 show_message(error_messages["no-such-host"]); 755 show_message(error_messages["no-such-host"]);
756 return 1; 756 return 1;
757 end 757 end
758 end 758 end
759 return cert_commands[subcmd](arg); 759 return cert_commands[subcmd](arg);