Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/processone/ejabberd.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/xmpp_codec.hrl2
-rw-r--r--src/ejabberd_c2s.erl6
-rw-r--r--src/xmpp_codec.erl5
-rw-r--r--test/ejabberd_SUITE.erl40
-rw-r--r--test/ejabberd_SUITE_data/ejabberd.yml2
-rw-r--r--test/suite.erl32
-rw-r--r--tools/xmpp_codec.spec1
7 files changed, 56 insertions, 32 deletions
diff --git a/include/xmpp_codec.hrl b/include/xmpp_codec.hrl
index 5428aad11..8ffb37808 100644
--- a/include/xmpp_codec.hrl
+++ b/include/xmpp_codec.hrl
@@ -522,7 +522,7 @@
-type version() :: #version{}.
-record(bind, {jid :: jid:jid(),
- resource :: binary()}).
+ resource = <<>> :: binary()}).
-type bind() :: #bind{}.
-record(rosterver_feature, {}).
diff --git a/src/ejabberd_c2s.erl b/src/ejabberd_c2s.erl
index 02540259a..f7d8e9dbb 100644
--- a/src/ejabberd_c2s.erl
+++ b/src/ejabberd_c2s.erl
@@ -907,8 +907,12 @@ wait_for_bind(#sm_resume{} = Pkt, StateData) ->
wait_for_bind(Pkt, StateData) when ?IS_STREAM_MGMT_PACKET(Pkt) ->
fsm_next_state(wait_for_bind, dispatch_stream_mgmt(Pkt, StateData));
wait_for_bind(#iq{type = set,
- sub_els = [#bind{resource = R}]} = IQ, StateData) ->
+ sub_els = [#bind{resource = R0}]} = IQ, StateData) ->
U = StateData#state.user,
+ R = case R0 of
+ <<>> -> new_uniq_id();
+ _ -> R0
+ end,
case resource_conflict_action(U, StateData#state.server, R) of
closenew ->
Err = xmpp:make_error(IQ, xmpp:err_conflict()),
diff --git a/src/xmpp_codec.erl b/src/xmpp_codec.erl
index a0181e1e6..f8f8b205f 100644
--- a/src/xmpp_codec.erl
+++ b/src/xmpp_codec.erl
@@ -29737,7 +29737,7 @@ encode_legacy_auth_username_cdata(_val, _acc) ->
decode_bind(__TopXMLNS, __IgnoreEls,
{xmlel, <<"bind">>, _attrs, _els}) ->
{Jid, Resource} = decode_bind_els(__TopXMLNS,
- __IgnoreEls, _els, undefined, undefined),
+ __IgnoreEls, _els, undefined, <<>>),
{bind, Jid, Resource}.
decode_bind_els(__TopXMLNS, __IgnoreEls, [], Jid,
@@ -29800,8 +29800,7 @@ encode_bind({bind, Jid, Resource}, __TopXMLNS) ->
'encode_bind_$jid'(Jid, __TopXMLNS, _acc) ->
[encode_bind_jid(Jid, __TopXMLNS) | _acc].
-'encode_bind_$resource'(undefined, __TopXMLNS, _acc) ->
- _acc;
+'encode_bind_$resource'(<<>>, __TopXMLNS, _acc) -> _acc;
'encode_bind_$resource'(Resource, __TopXMLNS, _acc) ->
[encode_bind_resource(Resource, __TopXMLNS) | _acc].
diff --git a/test/ejabberd_SUITE.erl b/test/ejabberd_SUITE.erl
index b5aa50bdb..4e02389d4 100644
--- a/test/ejabberd_SUITE.erl
+++ b/test/ejabberd_SUITE.erl
@@ -148,9 +148,13 @@ do_init_per_group(component, Config) ->
set_opt(server_port, Port,
set_opt(stream_version, undefined,
set_opt(lang, <<"">>, Config))))));
-do_init_per_group(_GroupName, Config) ->
+do_init_per_group(GroupName, Config) ->
Pid = start_event_relay(),
- set_opt(event_relay, Pid, Config).
+ NewConfig = set_opt(event_relay, Pid, Config),
+ case GroupName of
+ anonymous -> set_opt(anonymous, true, NewConfig);
+ _ -> NewConfig
+ end.
end_per_group(mnesia, _Config) ->
ok;
@@ -176,7 +180,7 @@ end_per_group(s2s, _Config) ->
ejabberd_config:add_option(s2s_use_starttls, false);
end_per_group(_GroupName, Config) ->
stop_event_relay(Config),
- ok.
+ set_opt(anonymous, false, Config).
init_per_testcase(stop_ejabberd, Config) ->
open_session(bind(auth(connect(Config))));
@@ -186,8 +190,8 @@ init_per_testcase(TestCase, OrigConfig) ->
name, ?config(tc_group_properties, OrigConfig)),
Server = ?config(server, OrigConfig),
Resource = case TestGroup of
- generic ->
- randoms:get_string();
+ anonymous ->
+ <<"">>;
legacy_auth ->
randoms:get_string();
_ ->
@@ -278,7 +282,7 @@ legacy_auth_tests() ->
test_legacy_auth_fail]}.
no_db_tests() ->
- [{generic, [parallel],
+ [{anonymous, [parallel],
[test_connect_bad_xml,
test_connect_unexpected_xml,
test_connect_unknown_ns,
@@ -293,7 +297,6 @@ no_db_tests() ->
test_starttls,
test_zlib,
test_auth,
- test_auth_fail,
test_bind,
test_open_session,
codec_failure,
@@ -306,7 +309,8 @@ no_db_tests() ->
stats,
disco]},
{presence_and_s2s, [sequence],
- [presence,
+ [test_auth_fail,
+ presence,
s2s_dialback,
s2s_optional,
s2s_required,
@@ -507,17 +511,17 @@ groups() ->
{riak, [sequence], db_tests(riak)}].
all() ->
- [{group, ldap},
+ [%%{group, ldap},
{group, no_db},
- {group, mnesia},
- {group, redis},
- {group, mysql},
- {group, pgsql},
- {group, sqlite},
- {group, extauth},
- {group, riak},
- {group, component},
- {group, s2s},
+ %% {group, mnesia},
+ %% {group, redis},
+ %% {group, mysql},
+ %% {group, pgsql},
+ %% {group, sqlite},
+ %% {group, extauth},
+ %% {group, riak},
+ %% {group, component},
+ %% {group, s2s},
stop_ejabberd].
stop_ejabberd(Config) ->
diff --git a/test/ejabberd_SUITE_data/ejabberd.yml b/test/ejabberd_SUITE_data/ejabberd.yml
index 128be2aed..c9ea5fd7a 100644
--- a/test/ejabberd_SUITE_data/ejabberd.yml
+++ b/test/ejabberd_SUITE_data/ejabberd.yml
@@ -327,7 +327,7 @@ Welcome to this XMPP server."
mod_time: []
mod_version: []
"localhost":
- auth_method: internal
+ auth_method: [internal, anonymous]
"ldap.localhost":
ldap_servers:
- "localhost"
diff --git a/test/suite.erl b/test/suite.erl
index e10c7e0c4..42c5dcfbe 100644
--- a/test/suite.erl
+++ b/test/suite.erl
@@ -74,6 +74,7 @@ init_config(Config) ->
{slave_nick, <<"slave_nick!@#$%^&*()'\"`~<>+-/;:_=[]{}|\\">>},
{room_subject, <<"hello, world!@#$%^&*()'\"`~<>+-/;:_=[]{}|\\">>},
{certfile, CertFile},
+ {anonymous, false},
{type, client},
{xmlns, ?NS_CLIENT},
{ns_stream, ?NS_STREAM},
@@ -253,11 +254,15 @@ auth(Config) ->
auth(Config, ShouldFail) ->
Type = ?config(type, Config),
+ IsAnonymous = ?config(anonymous, Config),
Mechs = ?config(mechs, Config),
HaveMD5 = lists:member(<<"DIGEST-MD5">>, Mechs),
HavePLAIN = lists:member(<<"PLAIN">>, Mechs),
HaveExternal = lists:member(<<"EXTERNAL">>, Mechs),
- if HavePLAIN ->
+ HaveAnonymous = lists:member(<<"ANONYMOUS">>, Mechs),
+ if HaveAnonymous and IsAnonymous ->
+ auth_SASL(<<"ANONYMOUS">>, Config, ShouldFail);
+ HavePLAIN ->
auth_SASL(<<"PLAIN">>, Config, ShouldFail);
HaveMD5 ->
auth_SASL(<<"DIGEST-MD5">>, Config, ShouldFail);
@@ -272,17 +277,25 @@ auth(Config, ShouldFail) ->
end.
bind(Config) ->
+ U = ?config(user, Config),
+ S = ?config(server, Config),
+ R = ?config(resource, Config),
case ?config(type, Config) of
client ->
- #iq{type = result, sub_els = [#bind{}]} =
+ #iq{type = result, sub_els = [#bind{jid = JID}]} =
send_recv(
- Config,
- #iq{type = set,
- sub_els = [#bind{resource = ?config(resource, Config)}]});
+ Config, #iq{type = set, sub_els = [#bind{resource = R}]}),
+ case ?config(anonymous, Config) of
+ false ->
+ {U, S, R} = jid:tolower(JID),
+ Config;
+ true ->
+ {User, S, Resource} = jid:tolower(JID),
+ set_opt(user, User, set_opt(resource, Resource, Config))
+ end;
component ->
- ok
- end,
- Config.
+ Config
+ end.
open_session(Config) ->
open_session(Config, false).
@@ -478,6 +491,9 @@ sasl_new(<<"PLAIN">>, User, Server, Password) ->
sasl_new(<<"EXTERNAL">>, _User, _Server, _Password) ->
{<<"">>,
fun(_) -> ct:fail(sasl_challenge_is_not_expected) end};
+sasl_new(<<"ANONYMOUS">>, _User, _Server, _Password) ->
+ {<<"">>,
+ fun(_) -> ct:fail(sasl_challenge_is_not_expected) end};
sasl_new(<<"DIGEST-MD5">>, User, Server, Password) ->
{<<"">>,
fun (ServerIn) ->
diff --git a/tools/xmpp_codec.spec b/tools/xmpp_codec.spec
index 6824cf387..1f9b50066 100644
--- a/tools/xmpp_codec.spec
+++ b/tools/xmpp_codec.spec
@@ -621,6 +621,7 @@
min = 0, max = 1},
#ref{name = bind_resource,
min = 0, max = 1,
+ default = <<"">>,
label = '$resource'}]}).
-xml(legacy_auth_username,