From 1283a59465bd1477b55a14d7f06afd428e8787c2 Mon Sep 17 00:00:00 2001 From: Evgeniy Khramtsov Date: Wed, 3 Feb 2010 12:20:04 +0000 Subject: [PATCH] Added new acl for mod_register: access_from. This acl is applied if existing account tries to register a new account (either via s2s or c2s). The default action is to deny such operations. SVN Revision: 2958 --- src/mod_register.erl | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/src/mod_register.erl b/src/mod_register.erl index 1618b9565..378e5da2e 100644 --- a/src/mod_register.erl +++ b/src/mod_register.erl @@ -163,12 +163,17 @@ process_iq(From, To, {User, Server} -> try_set_password(User, Server, Password, IQ_Rec, SubEl); _ -> - case try_register(User, Server, Password, - Source, Lang) of - ok -> - exmpp_iq:result(IQ_Rec, SubEl); - {error, Error} -> - exmpp_iq:error(IQ_Rec, Error) + case check_from(From, Server) of + allow -> + case try_register(User, Server, Password, + Source, Lang) of + ok -> + exmpp_iq:result(IQ_Rec, SubEl); + {error, Error} -> + exmpp_iq:error(IQ_Rec, Error) + end; + deny -> + exmpp_iq:error(IQ_Rec, 'forbidden') end end; true -> @@ -283,6 +288,14 @@ send_registration_notifications(UJID, Source) -> ok end. +check_from(JID, Server) -> + case {exmpp_jid:node_as_list(JID), exmpp_jid:prep_domain_as_list(JID)} of + {"", ""} -> + allow; + _ -> + Access = gen_mod:get_module_opt(Server, ?MODULE, access_from, none), + acl:match_rule(Server, Access, JID) + end. check_timeout(undefined) -> true;