diff options
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/mod_admin_telnet.lua | 12 | ||||
-rw-r--r-- | plugins/mod_auth_internal_hashed.lua | 4 | ||||
-rw-r--r-- | plugins/mod_auth_internal_plain.lua | 4 | ||||
-rw-r--r-- | plugins/mod_storage_internal.lua | 8 | ||||
-rw-r--r-- | plugins/mod_storage_sql.lua | 11 | ||||
-rw-r--r-- | plugins/muc/muc.lib.lua | 2 |
6 files changed, 38 insertions, 3 deletions
diff --git a/plugins/mod_admin_telnet.lua b/plugins/mod_admin_telnet.lua index 62fb10a0..9d3186d6 100644 --- a/plugins/mod_admin_telnet.lua +++ b/plugins/mod_admin_telnet.lua @@ -228,6 +228,7 @@ function commands.help(session, data) print [[user:create(jid, password) - Create the specified user account]] print [[user:password(jid, password) - Set the password for the specified user account]] print [[user:delete(jid) - Permanently remove the specified user account]] + print [[user:list(hostname) - List users on the specified host]] elseif section == "server" then print [[server:version() - Show the server's version number]] print [[server:uptime() - Show how long the server has been running]] @@ -952,6 +953,17 @@ function def_env.user:password(jid, password) end end +function def_env.user:list(host) + if not host then + return nil, "No host given"; + end + local print = self.session.print; + for user in um.users(host) do + print(user.."@"..host); + end + return true; +end + def_env.xmpp = {}; local st = require "util.stanza"; diff --git a/plugins/mod_auth_internal_hashed.lua b/plugins/mod_auth_internal_hashed.lua index b61fba80..4535f9c9 100644 --- a/plugins/mod_auth_internal_hashed.lua +++ b/plugins/mod_auth_internal_hashed.lua @@ -102,6 +102,10 @@ function provider.user_exists(username) return true; end +function provider.users() + return datamanager.users(host, "accounts"); +end + function provider.create_user(username, password) if password == nil then return datamanager.store(username, host, "accounts", {}); diff --git a/plugins/mod_auth_internal_plain.lua b/plugins/mod_auth_internal_plain.lua index b7723dd7..7514164d 100644 --- a/plugins/mod_auth_internal_plain.lua +++ b/plugins/mod_auth_internal_plain.lua @@ -52,6 +52,10 @@ function provider.user_exists(username) return true; end +function provider.users() + return datamanager.users(host, "accounts"); +end + function provider.create_user(username, password) return datamanager.store(username, host, "accounts", {password = password}); end diff --git a/plugins/mod_storage_internal.lua b/plugins/mod_storage_internal.lua index 039202dd..972ecbee 100644 --- a/plugins/mod_storage_internal.lua +++ b/plugins/mod_storage_internal.lua @@ -5,8 +5,8 @@ local host = module.host; local driver = {}; local driver_mt = { __index = driver }; -function driver:open(store) - return setmetatable({ store = store }, driver_mt); +function driver:open(store, typ) + return setmetatable({ store = store, type = typ }, driver_mt); end function driver:get(user) return datamanager.load(user, host, self.store); @@ -20,6 +20,10 @@ function driver:stores(username) return datamanager.stores(username, host); end +function driver:users() + return datamanager.users(host, self.store, self.type); +end + function driver:purge(user) return datamanager.purge(user, host); end diff --git a/plugins/mod_storage_sql.lua b/plugins/mod_storage_sql.lua index c9a45fca..f6fa94e7 100644 --- a/plugins/mod_storage_sql.lua +++ b/plugins/mod_storage_sql.lua @@ -298,6 +298,17 @@ function keyval_store:set(username, data) end if success then return ret, err; else return rollback(nil, ret); end end +function keyval_store:users() + local stmt, err = dosql("SELECT DISTINCT `user` FROM `prosody` WHERE `host`=? AND `store`=?", host, self.store); + if not stmt then + return rollback(nil, err); + end + local next = stmt:rows(); + return commit(function() + local row = next(); + return row and row[1]; + end); +end local function map_store_get(key) local stmt, err = getsql("SELECT * FROM `prosody` WHERE `host`=? AND `user`=? AND `store`=? AND `key`=?", key or ""); diff --git a/plugins/muc/muc.lib.lua b/plugins/muc/muc.lib.lua index a7603535..6ba7b621 100644 --- a/plugins/muc/muc.lib.lua +++ b/plugins/muc/muc.lib.lua @@ -522,7 +522,7 @@ function room_mt:handle_to_occupant(origin, stanza) -- PM, vCards, etc end end elseif not current_nick then -- not in room - if type == "error" or type == "result" and stanza.name == "iq" then + if (type == "error" or type == "result") and stanza.name == "iq" then local id = stanza.attr.id; stanza.attr.from, stanza.attr.to, stanza.attr.id = deconstruct_stanza_id(self, stanza); if stanza.attr.id then |