Software /
code /
prosody
Changeset
5160:da7fe5de82fb
Merge 0.9 -> trunk (like this?)
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sat, 29 Sep 2012 01:05:17 +0200 |
parents | 5159:0638ff1e1a5a (diff) 5143:a86efd60425f (current diff) |
children | 5162:cda4d3f01ddd |
files | prosodyctl |
diffstat | 11 files changed, 75 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/Makefile Sun Sep 23 01:13:08 2012 +0500 +++ b/Makefile Sat Sep 29 01:05:17 2012 +0200 @@ -52,7 +52,8 @@ $(MAKE) install -C util-src %.install: % - sed "s|^CFG_SOURCEDIR=.*;$$|CFG_SOURCEDIR='$(INSTALLEDSOURCE)';|; \ + sed "1s/\blua\b/$(RUNWITH)/; \ + s|^CFG_SOURCEDIR=.*;$$|CFG_SOURCEDIR='$(INSTALLEDSOURCE)';|; \ s|^CFG_CONFIGDIR=.*;$$|CFG_CONFIGDIR='$(INSTALLEDCONFIG)';|; \ s|^CFG_DATADIR=.*;$$|CFG_DATADIR='$(INSTALLEDDATA)';|; \ s|^CFG_PLUGINDIR=.*;$$|CFG_PLUGINDIR='$(INSTALLEDMODULES)/';|;" < $^ > $@
--- a/configure Sun Sep 23 01:13:08 2012 +0500 +++ b/configure Sat Sep 29 01:05:17 2012 +0200 @@ -16,6 +16,7 @@ CC=gcc CXX=g++ LD=gcc +RUNWITH=lua CFLAGS="-fPIC -Wall" LDFLAGS="-shared" @@ -171,6 +172,9 @@ --linker=*) LD="$value" ;; + --runwith=*) + RUNWITH="$value" + ;; *) echo "Error: Unknown flag: $1" exit 1 @@ -341,6 +345,7 @@ CC=$CC CXX=$CXX LD=$LD +RUNWITH=$RUNWITH EOF
--- a/core/storagemanager.lua Sun Sep 23 01:13:08 2012 +0500 +++ b/core/storagemanager.lua Sat Sep 29 01:05:17 2012 +0200 @@ -118,6 +118,13 @@ function datamanager.store(username, host, datastore, data) return open(host, datastore):set(username, data); end +function datamanager.users(host, datastore, typ) + local driver = open(host, datastore, typ); + if not driver.users then + return function() log("warn", "storage driver %s does not support listing users", driver.name) end + end + return driver:users(); +end function datamanager.stores(username, host, typ) return get_driver(host):stores(username, typ); end
--- a/core/usermanager.lua Sun Sep 23 01:13:08 2012 +0500 +++ b/core/usermanager.lua Sat Sep 29 01:05:17 2012 +0200 @@ -96,6 +96,10 @@ return storagemanager.purge(username, host); end +function users(host) + return hosts[host].users.users(); +end + function get_sasl_handler(host, session) return hosts[host].users.get_sasl_handler(session); end
--- a/plugins/mod_admin_telnet.lua Sun Sep 23 01:13:08 2012 +0500 +++ b/plugins/mod_admin_telnet.lua Sat Sep 29 01:05:17 2012 +0200 @@ -228,6 +228,7 @@ 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 @@ 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";
--- a/plugins/mod_auth_internal_hashed.lua Sun Sep 23 01:13:08 2012 +0500 +++ b/plugins/mod_auth_internal_hashed.lua Sat Sep 29 01:05:17 2012 +0200 @@ -102,6 +102,10 @@ 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", {});
--- a/plugins/mod_auth_internal_plain.lua Sun Sep 23 01:13:08 2012 +0500 +++ b/plugins/mod_auth_internal_plain.lua Sat Sep 29 01:05:17 2012 +0200 @@ -52,6 +52,10 @@ 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
--- a/plugins/mod_storage_internal.lua Sun Sep 23 01:13:08 2012 +0500 +++ b/plugins/mod_storage_internal.lua Sat Sep 29 01:05:17 2012 +0200 @@ -5,8 +5,8 @@ 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 @@ 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
--- a/plugins/mod_storage_sql.lua Sun Sep 23 01:13:08 2012 +0500 +++ b/plugins/mod_storage_sql.lua Sat Sep 29 01:05:17 2012 +0200 @@ -298,6 +298,17 @@ 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 "");
--- a/plugins/muc/muc.lib.lua Sun Sep 23 01:13:08 2012 +0500 +++ b/plugins/muc/muc.lib.lua Sat Sep 29 01:05:17 2012 +0200 @@ -522,7 +522,7 @@ 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
--- a/util/datamanager.lua Sun Sep 23 01:13:08 2012 +0500 +++ b/util/datamanager.lua Sat Sep 29 01:05:17 2012 +0200 @@ -282,6 +282,25 @@ list = "list"; } +function users(host, store, typ) + typ = type_map[typ or "keyval"]; + local store_dir = format("%s/%s/%s", data_path, encode(host), encode(store)); + + local mode, err = lfs.attributes(store_dir, "mode"); + if not mode then + return function() log("debug", err or (store_dir .. " does not exist")) end + end + local next, state = lfs.dir(store_dir); + return function(state) + for node in next, state do + local file, ext = node:match("^(.*)%.([dalist]+)$"); + if file and ext == typ then + return decode(file); + end + end + end, state; +end + function stores(username, host, typ) typ = type_map[typ or "keyval"]; local store_dir = format("%s/%s/", data_path, encode(host));