Software /
code /
prosody
Comparison
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 |
comparison
equal
deleted
inserted
replaced
5595:b9c836dc8f2a | 5599:34e9f237b915 |
---|---|
698 if not conn.getpeerchain then | 698 if not conn.getpeerchain then |
699 if conn.dohandshake then | 699 if conn.dohandshake then |
700 error("This version of LuaSec does not support certificate viewing"); | 700 error("This version of LuaSec does not support certificate viewing"); |
701 end | 701 end |
702 else | 702 else |
703 local certs = conn:getpeerchain(); | 703 local cert = conn:getpeercertificate(); |
704 local cert = certs[1]; | |
705 if cert then | 704 if cert then |
705 local certs = conn:getpeerchain(); | |
706 local digest = cert:digest("sha1"); | 706 local digest = cert:digest("sha1"); |
707 if not cert_set[digest] then | 707 if not cert_set[digest] then |
708 local chain_valid, chain_errors = conn:getpeerverification(); | 708 local chain_valid, chain_errors = conn:getpeerverification(); |
709 cert_set[digest] = { | 709 cert_set[digest] = { |
710 { | 710 { |
955 local um = require"core.usermanager"; | 955 local um = require"core.usermanager"; |
956 | 956 |
957 def_env.user = {}; | 957 def_env.user = {}; |
958 function def_env.user:create(jid, password) | 958 function def_env.user:create(jid, password) |
959 local username, host = jid_split(jid); | 959 local username, host = jid_split(jid); |
960 if um.user_exists(username, host) then | 960 if not hosts[host] then |
961 return nil, "No such host: "..host; | |
962 elseif um.user_exists(username, host) then | |
961 return nil, "User exists"; | 963 return nil, "User exists"; |
962 end | 964 end |
963 local ok, err = um.create_user(username, password, host); | 965 local ok, err = um.create_user(username, password, host); |
964 if ok then | 966 if ok then |
965 return true, "User created"; | 967 return true, "User created"; |
968 end | 970 end |
969 end | 971 end |
970 | 972 |
971 function def_env.user:delete(jid) | 973 function def_env.user:delete(jid) |
972 local username, host = jid_split(jid); | 974 local username, host = jid_split(jid); |
973 if not um.user_exists(username, host) then | 975 if not hosts[host] then |
976 return nil, "No such host: "..host; | |
977 elseif um.user_exists(username, host) then | |
974 return nil, "No such user"; | 978 return nil, "No such user"; |
975 end | 979 end |
976 local ok, err = um.delete_user(username, host); | 980 local ok, err = um.delete_user(username, host); |
977 if ok then | 981 if ok then |
978 return true, "User deleted"; | 982 return true, "User deleted"; |
981 end | 985 end |
982 end | 986 end |
983 | 987 |
984 function def_env.user:password(jid, password) | 988 function def_env.user:password(jid, password) |
985 local username, host = jid_split(jid); | 989 local username, host = jid_split(jid); |
986 if not um.user_exists(username, host) then | 990 if not hosts[host] then |
991 return nil, "No such host: "..host; | |
992 elseif um.user_exists(username, host) then | |
987 return nil, "No such user"; | 993 return nil, "No such user"; |
988 end | 994 end |
989 local ok, err = um.set_password(username, password, host); | 995 local ok, err = um.set_password(username, password, host); |
990 if ok then | 996 if ok then |
991 return true, "User password changed"; | 997 return true, "User password changed"; |