diff options
Diffstat (limited to 'plugins/mod_admin_shell.lua')
-rw-r--r-- | plugins/mod_admin_shell.lua | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/plugins/mod_admin_shell.lua b/plugins/mod_admin_shell.lua index d085ce43..0b8d3c43 100644 --- a/plugins/mod_admin_shell.lua +++ b/plugins/mod_admin_shell.lua @@ -631,6 +631,7 @@ describe_command [[module:load(module, host) - Load the specified module on the function def_env.module:load(name, hosts) hosts = get_hosts_with_module(hosts); + local already_loaded = set.new(); -- Load the module for each host local ok, err, count, mod = true, nil, 0; for host in hosts do @@ -655,10 +656,18 @@ function def_env.module:load(name, hosts) self.session.print("Note: Module will not be loaded after restart unless enabled in configuration"); end end + else + already_loaded:add(host); end end - return ok, (ok and "Module loaded onto "..count.." host"..(count ~= 1 and "s" or "")) or ("Last error: "..tostring(err)); + if not ok then + return ok, "Last error: "..tostring(err); + end + if already_loaded == hosts then + return ok, "Module already loaded"; + end + return ok, "Module loaded onto "..count.." host"..(count ~= 1 and "s" or ""); end describe_command [[module:unload(module, host) - The same, but just unloads the module from memory]] @@ -978,7 +987,7 @@ available_columns = { return capitalize(cert_status); end -- no certificate status, - if session.cert_chain_errors then + if type(session.cert_chain_errors) == "table" then local cert_errors = set.new(session.cert_chain_errors[1]); if cert_errors:contains("certificate has expired") then return "Expired"; @@ -989,6 +998,7 @@ available_columns = { -- TODO borrow more logic from mod_s2s/friendly_cert_error() return "Untrusted"; end + -- TODO cert_chain_errors can be a string, handle that return "Unknown"; end; }; @@ -1769,7 +1779,11 @@ function def_env.user:setrole(jid, host, new_role) elseif prosody.hosts[userhost] and not um.user_exists(username, userhost) then return nil, "No such user"; end - return um.set_user_role(username, host, new_role); + if userhost == host then + return um.set_user_role(username, userhost, new_role); + else + return um.set_jid_role(jid, host, new_role); + end end describe_command [[user:addrole(jid, host, role) - Add a secondary role to a user]] @@ -1780,6 +1794,8 @@ function def_env.user:addrole(jid, host, new_role) return nil, "No such host: "..host; elseif prosody.hosts[userhost] and not um.user_exists(username, userhost) then return nil, "No such user"; + elseif userhost ~= host then + return nil, "Can't add roles outside users own host" end return um.add_user_secondary_role(username, host, new_role); end @@ -1792,6 +1808,8 @@ function def_env.user:delrole(jid, host, role_name) return nil, "No such host: "..host; elseif prosody.hosts[userhost] and not um.user_exists(username, userhost) then return nil, "No such user"; + elseif userhost ~= host then + return nil, "Can't remove roles outside users own host" end return um.remove_user_secondary_role(username, host, role_name); end |