Diff

plugins/mod_admin_telnet.lua @ 5599:34e9f237b915

Merge 0.9->trunk
author Kim Alvefur <zash@zash.se>
date Sat, 18 May 2013 13:20:46 +0200
parent 5593:98a485212592
parent 5598:3bb8aefd8ce0
child 5631:78bc91f0d74b
line wrap: on
line diff
--- a/plugins/mod_admin_telnet.lua	Sat May 18 12:03:03 2013 +0100
+++ b/plugins/mod_admin_telnet.lua	Sat May 18 13:20:46 2013 +0200
@@ -700,9 +700,9 @@
 				error("This version of LuaSec does not support certificate viewing");
 			end
 		else
-			local certs = conn:getpeerchain();
-			local cert = certs[1];
+			local cert = conn:getpeercertificate();
 			if cert then
+				local certs = conn:getpeerchain();
 				local digest = cert:digest("sha1");
 				if not cert_set[digest] then
 					local chain_valid, chain_errors = conn:getpeerverification();
@@ -957,7 +957,9 @@
 def_env.user = {};
 function def_env.user:create(jid, password)
 	local username, host = jid_split(jid);
-	if um.user_exists(username, host) then
+	if not hosts[host] then
+		return nil, "No such host: "..host;
+	elseif um.user_exists(username, host) then
 		return nil, "User exists";
 	end
 	local ok, err = um.create_user(username, password, host);
@@ -970,7 +972,9 @@
 
 function def_env.user:delete(jid)
 	local username, host = jid_split(jid);
-	if not um.user_exists(username, host) then
+	if not hosts[host] then
+		return nil, "No such host: "..host;
+	elseif um.user_exists(username, host) then
 		return nil, "No such user";
 	end
 	local ok, err = um.delete_user(username, host);
@@ -983,7 +987,9 @@
 
 function def_env.user:password(jid, password)
 	local username, host = jid_split(jid);
-	if not um.user_exists(username, host) then
+	if not hosts[host] then
+		return nil, "No such host: "..host;
+	elseif um.user_exists(username, host) then
 		return nil, "No such user";
 	end
 	local ok, err = um.set_password(username, password, host);