Merge with backout
authorMatthew Wild <mwild1@gmail.com>
Fri, 21 May 2010 18:45:33 +0000 (19:45 +0100)
committerMatthew Wild <mwild1@gmail.com>
Fri, 21 May 2010 18:45:33 +0000 (19:45 +0100)
13 files changed:
1  2 
core/configmanager.lua
core/eventmanager.lua
core/usermanager.lua
net/xmppclient_listener.lua
plugins/mod_offline.lua
plugins/mod_posix.lua
plugins/mod_presence.lua
plugins/muc/muc.lib.lua
prosody
prosodyctl
util/sasl.lua
util/sasl/digest-md5.lua
util/sasl/scram.lua

index 0f20fd3ee124f8fc2b2a7c14b1cef243535d107f,9b03e1c7ad539eed1ed6526ebef5c3ce3164b5eb..54fb0a9ae82fdb61d22f4d1600f27855f84a3d46
        function parsers.lua.load(data, filename)
                local env;
                -- The ' = true' are needed so as not to set off __newindex when we assign the functions below
-               env = setmetatable({ Host = true; host = true; Component = true, component = true,
 -              env = setmetatable({
 -                      Host = true, host = true, VirtualHost = true,
 -                      Component = true, component = true,
 -                      Include = true, include = true, RunScript = dofile }, {
 -                              __index = function (t, k)
 -                                      return rawget(_G, k) or
 -                                              function (settings_table)
 -                                                      config[__currenthost or "*"][k] = settings_table;
 -                                              end;
 -                              end,
 -                              __newindex = function (t, k, v)
 -                                      set(env.__currenthost or "*", "core", k, v);
 -                              end
 -              });
++              env = setmetatable({ Host = true, host = true, VirtualHost = true, Component = true, component = true,
 +                                                      Include = true, include = true, RunScript = dofile }, { __index = function (t, k)
 +                                                                                              return rawget(_G, k) or
 +                                                                                                              function (settings_table)
 +                                                                                                                      config[__currenthost or "*"][k] = settings_table;
 +                                                                                                              end;
 +                                                                              end,
 +                                                              __newindex = function (t, k, v)
 +                                                                                      set(env.__currenthost or "*", "core", k, v);
 +                                                                              end});
                
                rawset(env, "__currenthost", "*") -- Default is global
-               function env.Host(name)
+               function env.VirtualHost(name)
                        if rawget(config, name) and rawget(config[name].core, "component_module") then
                                error(format("Host %q clashes with previously defined %s Component %q, for services use a sub-domain like conference.%s",
                                        name, config[name].core.component_module:gsub("^%a+$", { component = "external", muc = "MUC"}), name, name), 0);
Simple merge
index 925ac774071489eedae3dfae20bd3547d23f9452,4fef936ee9de5de04c28d49931de8d20de458b2b..42e49d389ad5f00115492a45f9ccc61bd9e72188
@@@ -14,15 -14,42 +14,21 @@@ local ipairs = ipairs
  local hashes = require "util.hashes";
  local jid_bare = require "util.jid".bare;
  local config = require "core.configmanager";
+ local hosts = hosts;
+ local require_provisioning = config.get("*", "core", "cyrus_require_provisioning") or false;
  
 -local prosody = _G.prosody;
 -
  module "usermanager"
  
 -local new_default_provider;
 -
 -local function host_handler(host)
 -      local host_session = hosts[host];
 -      host_session.events.add_handler("item-added/auth-provider", function (provider)
 -              if config.get(host, "core", "authentication") == provider.name then
 -                      host_session.users = provider;
 -              end
 -      end);
 -      host_session.events.add_handler("item-removed/auth-provider", function (provider)
 -              if host_session.users == provider then
 -                      host_session.users = new_default_provider(host);
 -              end
 -      end);
 -      host_session.users = new_default_provider(host); -- Start with the default usermanager provider
 -end
 -prosody.events.add_handler("host-activated", host_handler);
 -prosody.events.add_handler("component-activated", host_handler);
 -
+ local function is_cyrus(host) return config.get(host, "core", "sasl_backend") == "cyrus"; end
 -function new_default_provider(host)
 -      local provider = { name = "default" };
 -      
 -      function provider:test_password(username, password)
 -              if is_cyrus(host) then return nil, "Legacy auth not supported with Cyrus SASL."; end
 -              local credentials = datamanager.load(username, host, "accounts") or {};
 -      
 +function validate_credentials(host, username, password, method)
 +      log("debug", "User '%s' is being validated", username);
++      if is_cyrus(host) then return nil, "Legacy auth not supported with Cyrus SASL."; end
 +      local credentials = datamanager.load(username, host, "accounts") or {};
 +
 +      if method == nil then method = "PLAIN"; end
 +      if method == "PLAIN" and credentials.password then -- PLAIN, do directly
                if password == credentials.password then
                        return true;
                else
  end
  
  function get_password(username, host)
-   return (datamanager.load(username, host, "accounts") or {}).password
 -      return hosts[host].users:get_password(username);
++      if is_cyrus(host) then return nil, "Passwords unavailable for Cyrus SASL."; end
++      return (datamanager.load(username, host, "accounts") or {}).password
+ end
 -
+ function set_password(username, host, password)
 -      return hosts[host].users:set_password(username, password);
++      if is_cyrus(host) then return nil, "Passwords unavailable for Cyrus SASL."; end
++      local account = datamanager.load(username, host, "accounts");
++      if account then
++              account.password = password;
++              return datamanager.store(username, host, "accounts", account);
++      end
++      return nil, "Account not available.";
  end
  
  function user_exists(username, host)
 -      return hosts[host].users:user_exists(username);
++      if not(require_provisioning) and is_cyrus(host) then return true; end
 +      return datamanager.load(username, host, "accounts") ~= nil; -- FIXME also check for empty credentials
  end
  
  function create_user(username, password, host)
 -      return hosts[host].users:create_user(username, password);
++      if not(require_provisioning) and is_cyrus(host) then return nil, "Account creation/modification not available with Cyrus SASL."; end
 +      return datamanager.store(username, host, "accounts", {password = password});
  end
  
  function get_supported_methods(host)
Simple merge
diff --cc plugins/mod_offline.lua
index c74d011e7c0b2145bf66328d2c42c693e9bfcca4,24aef9ed58120f8802003f210bcf7aadf51eee35..0000000000000000000000000000000000000000
deleted file mode 100644,100644
+++ /dev/null
@@@ -1,56 -1,56 +1,0 @@@
---- Prosody IM
---- Copyright (C) 2008-2009 Matthew Wild
---- Copyright (C) 2008-2009 Waqas Hussain
---- 
---- This project is MIT/X11 licensed. Please see the
---- COPYING file in the source package for more information.
----
--
\r
- local datamanager = require "util.datamanager";\r
- local st = require "util.stanza";\r
- local datetime = require "util.datetime";\r
 -
 -local datamanager = require "util.datamanager";
 -local st = require "util.stanza";
 -local datetime = require "util.datetime";
--local ipairs = ipairs;
- local jid_split = require "util.jid".split;\r
\r
- module:add_feature("msgoffline");\r
\r
- module:hook("message/offline/store", function(event)\r
-       local origin, stanza = event.origin, event.stanza;\r
-       local to = stanza.attr.to;\r
-       local node, host;\r
-       if to then\r
-               node, host = jid_split(to)\r
-       else\r
-               node, host = origin.username, origin.host;\r
-       end\r
-       \r
-       stanza.attr.stamp, stanza.attr.stamp_legacy = datetime.datetime(), datetime.legacy();\r
-       local result = datamanager.list_append(node, host, "offline", st.preserialize(stanza));\r
-       stanza.attr.stamp, stanza.attr.stamp_legacy = nil, nil;\r
-       \r
-       return true;\r
- end);\r
\r
- module:hook("message/offline/broadcast", function(event)\r
-       local origin = event.origin;\r
-       local node, host = origin.username, origin.host;\r
-       \r
-       local data = datamanager.list_load(node, host, "offline");\r
-       if not data then return true; end\r
-       for _, stanza in ipairs(data) do\r
-               stanza = st.deserialize(stanza);\r
-               stanza:tag("delay", {xmlns = "urn:xmpp:delay", from = host, stamp = stanza.attr.stamp}):up(); -- XEP-0203\r
-               stanza:tag("x", {xmlns = "jabber:x:delay", from = host, stamp = stanza.attr.stamp_legacy}):up(); -- XEP-0091 (deprecated)\r
-               stanza.attr.stamp, stanza.attr.stamp_legacy = nil, nil;\r
-               origin.send(stanza);\r
-       end\r
-       return true;\r
- end);\r
\r
- module:hook("message/offline/delete", function(event)\r
-       local origin = event.origin;\r
-       local node, host = origin.username, origin.host;\r
\r
-       return datamanager.list_store(node, host, "offline", nil);\r
- end);\r
 -local jid_split = require "util.jid".split;
 -
 -module:add_feature("msgoffline");
 -
 -module:hook("message/offline/store", function(event)
 -      local origin, stanza = event.origin, event.stanza;
 -      local to = stanza.attr.to;
 -      local node, host;
 -      if to then
 -              node, host = jid_split(to)
 -      else
 -              node, host = origin.username, origin.host;
 -      end
 -      
 -      stanza.attr.stamp, stanza.attr.stamp_legacy = datetime.datetime(), datetime.legacy();
 -      local result = datamanager.list_append(node, host, "offline", st.preserialize(stanza));
 -      stanza.attr.stamp, stanza.attr.stamp_legacy = nil, nil;
 -      
 -      return true;
 -end);
 -
 -module:hook("message/offline/broadcast", function(event)
 -      local origin = event.origin;
 -      local node, host = origin.username, origin.host;
 -      
 -      local data = datamanager.list_load(node, host, "offline");
 -      if not data then return true; end
 -      for _, stanza in ipairs(data) do
 -              stanza = st.deserialize(stanza);
 -              stanza:tag("delay", {xmlns = "urn:xmpp:delay", from = host, stamp = stanza.attr.stamp}):up(); -- XEP-0203
 -              stanza:tag("x", {xmlns = "jabber:x:delay", from = host, stamp = stanza.attr.stamp_legacy}):up(); -- XEP-0091 (deprecated)
 -              stanza.attr.stamp, stanza.attr.stamp_legacy = nil, nil;
 -              origin.send(stanza);
 -      end
 -      return true;
 -end);
 -
 -module:hook("message/offline/delete", function(event)
 -      local origin = event.origin;
 -      local node, host = origin.username, origin.host;
 -
 -      return datamanager.list_store(node, host, "offline", nil);
 -end);
Simple merge
Simple merge
index ad45bbfd462caed12d70937cd0d173a646c98765,273e21ce94214b585d54580b60eb658b6d59f5af..18c80325bbd1bce5db492b36643407d4d1b4bf65
@@@ -319,7 -357,7 +319,12 @@@ function room_mt:handle_to_occupant(ori
                                                                :tag("item", {affiliation=affiliation or "none", role=role or "none"}):up()
                                                                :tag("status", {code='110'}));
                                                end
 -                                              self:send_history(from, stanza);
++                                              if self._data.whois == 'anyone' then -- non-anonymous?
++                                                      self:_route_stanza(st.stanza("message", {from=to, to=from, type='groupchat'})
++                                                              :tag("x", {xmlns='http://jabber.org/protocol/muc#user'})
++                                                              :tag("status", {code='100'}));
++                                              end
 +                                              self:send_history(from);
                                        else -- banned
                                                local reply = st.error_reply(stanza, "auth", "forbidden"):up();
                                                reply.tags[1].attr.code = "403";
@@@ -743,7 -784,7 +751,7 @@@ en
  function room_mt:set_role(actor, occupant_jid, role, callback, reason)
        if role == "none" then role = nil; end
        if role and role ~= "moderator" and role ~= "participant" and role ~= "visitor" then return nil, "modify", "not-acceptable"; end
--      if self:get_affiliation(actor) ~= "owner" then return nil, "cancel", "not-allowed"; end
++      if self:get_role(self._jid_nick[actor]) ~= "moderator" then return nil, "cancel", "not-allowed"; end
        local occupant = self._occupants[occupant_jid];
        if not occupant then return nil, "modify", "not-acceptable"; end
        if occupant.affiliation == "owner" or occupant.affiliation == "admin" then return nil, "cancel", "not-allowed"; end
@@@ -796,9 -837,9 +804,6 @@@ function room_mt:_route_stanza(stanza
                                end
                        end
                end
--              if self._data.whois == 'anyone' then
--                  muc_child:tag('status', { code = '100' });
--              end
        end
        self:route_stanza(stanza);
        if muc_child then
diff --cc prosody
Simple merge
diff --cc prosodyctl
Simple merge
diff --cc util/sasl.lua
Simple merge
Simple merge
Simple merge