From bb7c05bbf4a558cb909c96ca216c3c7735840763 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Sat, 18 May 2013 13:11:44 +0200 Subject: mod_admin_telnet: Don't rely on getpeerchain returning an empty list --- plugins/mod_admin_telnet.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'plugins/mod_admin_telnet.lua') diff --git a/plugins/mod_admin_telnet.lua b/plugins/mod_admin_telnet.lua index 753e2d2c..92c11d4b 100644 --- a/plugins/mod_admin_telnet.lua +++ b/plugins/mod_admin_telnet.lua @@ -682,9 +682,9 @@ function def_env.s2s:showcert(domain) 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(); -- cgit v1.2.3 From aa4b5036e35c1e60d3eba1fc2eeeaf96ae76ab15 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Sat, 18 May 2013 13:19:31 +0200 Subject: mod_admin_telnet: Verify that the host exists in user commands (Thanks SkyBlue) --- plugins/mod_admin_telnet.lua | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'plugins/mod_admin_telnet.lua') diff --git a/plugins/mod_admin_telnet.lua b/plugins/mod_admin_telnet.lua index 92c11d4b..3d149623 100644 --- a/plugins/mod_admin_telnet.lua +++ b/plugins/mod_admin_telnet.lua @@ -939,7 +939,9 @@ local um = require"core.usermanager"; 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); @@ -952,7 +954,9 @@ end 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); @@ -965,7 +969,9 @@ end 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); -- cgit v1.2.3