diff options
author | Badlop <badlop@process-one.net> | 2011-08-17 20:43:19 +0400 |
---|---|---|
committer | Badlop <badlop@process-one.net> | 2011-08-17 21:25:59 +0400 |
commit | 7355e810a8871be18089822c5d92f32892737387 (patch) | |
tree | f89a78a466dc458687ec81f85156997f7aa944c4 | |
parent | 6eb5b0d298a634d65e9ef187ccce2b823ab0140b (diff) |
Fix problems detected by Dialyzer
-rw-r--r-- | src/cyrsasl.erl | 2 | ||||
-rw-r--r-- | src/cyrsasl_scram.erl | 16 | ||||
-rw-r--r-- | src/ejabberd_auth_storage.erl | 12 | ||||
-rw-r--r-- | src/ejabberd_piefxis.erl | 7 | ||||
-rw-r--r-- | src/mod_muc/mod_muc_room.erl | 61 | ||||
-rw-r--r-- | src/mod_stats.erl | 7 |
6 files changed, 47 insertions, 58 deletions
diff --git a/src/cyrsasl.erl b/src/cyrsasl.erl index fcfc2456a..570e9b56c 100644 --- a/src/cyrsasl.erl +++ b/src/cyrsasl.erl @@ -232,7 +232,7 @@ server_start(State, Mech, ClientIn) -> %% @spec (State, ClientIn) -> Ok | Continue | Error %% State = saslstate() %% ClientIn = string() -%% Ok = {ok, Props} +%% Ok = {ok, Props} | {ok, Props, ServerOut} %% Props = [Prop] %% Prop = [{Key, Value}] %% Key = atom() diff --git a/src/cyrsasl_scram.erl b/src/cyrsasl_scram.erl index 42f33d7e2..87d19a544 100644 --- a/src/cyrsasl_scram.erl +++ b/src/cyrsasl_scram.erl @@ -92,9 +92,7 @@ mech_step(#state{step = 2} = State, ClientIn) -> _Else -> {error, 'not-supported'} end - end; - _Else -> - {error, 'bad-protocol'} + end end; _Else -> {error, 'bad-protocol'} @@ -146,12 +144,8 @@ parse_attribute(Attribute) -> true -> if SecondChar == $= -> - case string:substr(Attribute, 3) of - String when is_list(String) -> - {lists:nth(1, Attribute), String}; - _Else -> - {error, 'bad-format failed'} - end; + String = string:substr(Attribute, 3), + {lists:nth(1, Attribute), String}; true -> {error, 'bad-format second char not equal sign'} end; @@ -191,7 +185,7 @@ unescape_username(EscapedUsername) -> is_alpha(Char) when Char >= $a, Char =< $z -> true; is_alpha(Char) when Char >= $A, Char =< $Z -> - true; + true; is_alpha(_) -> - true. + false. diff --git a/src/ejabberd_auth_storage.erl b/src/ejabberd_auth_storage.erl index c77dd2ce0..e8212d42a 100644 --- a/src/ejabberd_auth_storage.erl +++ b/src/ejabberd_auth_storage.erl @@ -122,12 +122,12 @@ start(Host) -> {iterationcount, int}]} ]), update_table(Host, Backend), - maybe_scram_passwords(Host), + maybe_scram_passwords(HostB), mnesia:create_table(reg_users_counter, [{ram_copies, [node()]}, {attributes, record_info(fields, reg_users_counter)}]), update_reg_users_counter_table(Host), - maybe_alert_password_scrammed_without_option(Host), + maybe_alert_password_scrammed_without_option(HostB), ok. stop(_Host) -> @@ -544,9 +544,9 @@ is_scrammed(Host) -> forced_scram -> true end. -action_password_format(Host) -> +action_password_format(HostB) -> OptionScram = is_option_scram(), - case {OptionScram, get_format_first_element(Host)} of + case {OptionScram, get_format_first_element(HostB)} of {true, scram} -> scram; {true, any} -> scram; {true, plain} -> must_scram; @@ -555,8 +555,8 @@ action_password_format(Host) -> {false, scram} -> forced_scram end. -get_format_first_element(Host) -> - case gen_storage:dirty_select(Host, passwd, []) of +get_format_first_element(HostB) -> + case gen_storage:dirty_select(HostB, passwd, []) of [] -> any; [#passwd{password = ""} | _] -> scram; [#passwd{} | _] -> plain diff --git a/src/ejabberd_piefxis.erl b/src/ejabberd_piefxis.erl index cea7f7c0d..58b15a166 100644 --- a/src/ejabberd_piefxis.erl +++ b/src/ejabberd_piefxis.erl @@ -163,9 +163,8 @@ add_user(El, Domain) -> Password = exmpp_xml:get_attribute(El,<<"password">>,none), add_user(El, Domain, User, PasswordFormat, Password). -%% @spec (El::xmlel(), Domain::string(), User::binary(), PasswordFormat, Password::binary() | none) +%% @spec (El::xmlel(), Domain::string(), User::binary(), PasswordFormat::binary(), Password::binary() | none) %% -> ok | {error, ErrorText::string()} -%% PasswordFormat = <<"plaintext">> | <<"scram">> %% @doc Add a new user to the database. %% If user already exists, it will be only updated. add_user(El, Domain, User, <<"plaintext">>, none) -> @@ -174,7 +173,7 @@ add_user(El, Domain, User, <<"plaintext">>, none) -> io:format(""), populate_user_with_elements(El, Domain, User), ok; -add_user(El, Domain, User, PasswordFormat, Password) -> +add_user(El, Domain, User, <<"scram">> = PasswordFormat, Password) -> Password2 = prepare_password(PasswordFormat, Password, El), case create_user(User,Password2,Domain) of ok -> @@ -217,7 +216,7 @@ populate_user_with_elements(El, Domain, User) -> %% -> ok | {atomic, exists} | {error, not_allowed} %% @doc Create a new user create_user(User,Password,Domain) -> - case ejabberd_auth:try_register(?BTL(User),?BTL(Domain),?BTL(Password)) of + case ejabberd_auth:try_register(?BTL(User),?BTL(Domain),Password) of {atomic,ok} -> ok; {atomic, exists} -> {atomic, exists}; {error, not_allowed} -> {error, not_allowed}; diff --git a/src/mod_muc/mod_muc_room.erl b/src/mod_muc/mod_muc_room.erl index c932e6fb7..6ac949dee 100644 --- a/src/mod_muc/mod_muc_room.erl +++ b/src/mod_muc/mod_muc_room.erl @@ -452,24 +452,24 @@ normal_state({route, From, ToNick, From, Err); _ -> ToJID = find_jid_by_nick(ToNick, StateData), - SrcIsVisitor = is_visitor(From, StateData), - DstIsModerator = is_moderator(ToJID, StateData), - PmFromVisitors = (StateData#state.config)#config.allow_private_messages_from_visitors, - if SrcIsVisitor == false; - PmFromVisitors == anyone; - (PmFromVisitors == moderators) and (DstIsModerator) -> - case ToJID of - false -> - ErrText = "Recipient is not in the conference room", - Err = exmpp_stanza:reply_with_error(Packet, - exmpp_stanza:error(Packet#xmlel.ns, 'item-not-found', - {Lang, translate:translate(Lang, ErrText)})), - ejabberd_router:route( - jid_replace_resource( - StateData#state.jid, - ToNick), - From, Err); - _ -> + case ToJID of + false -> + ErrText = "Recipient is not in the conference room", + Err = exmpp_stanza:reply_with_error(Packet, + exmpp_stanza:error(Packet#xmlel.ns, 'item-not-found', + {Lang, translate:translate(Lang, ErrText)})), + ejabberd_router:route( + jid_replace_resource( + StateData#state.jid, + ToNick), + From, Err); + _ -> + SrcIsVisitor = is_visitor(From, StateData), + DstIsModerator = is_moderator(ToJID, StateData), + PmFromVisitors = (StateData#state.config)#config.allow_private_messages_from_visitors, + if SrcIsVisitor == false; + PmFromVisitors == anyone; + (PmFromVisitors == moderators) and (DstIsModerator) -> {ok, #user{nick = FromNick}} = ?DICT:find(jlib:jid_tolower(From), StateData#state.users), @@ -477,18 +477,19 @@ normal_state({route, From, ToNick, jid_replace_resource( StateData#state.jid, FromNick), - ToJID, Packet) - end; - true -> - ErrText = "It is not allowed to send private messages", - Err = exmpp_stanza:reply_with_error(Packet, - exmpp_stanza:error(Packet#xmlel.ns, 'forbidden', - {Lang, translate:translate(Lang, ErrText)})), - ejabberd_router:route( - jid_replace_resource( - StateData#state.jid, - ToNick), - From, Err) + ToJID, Packet); + true -> + ErrText = "It is not allowed to send private messages", + Err = exmpp_stanza:reply_with_error(Packet, + exmpp_stanza:error(Packet#xmlel.ns, 'forbidden', + {Lang, translate:translate(Lang, ErrText)})), + ejabberd_router:route( + jid_replace_resource( + StateData#state.jid, + ToNick), + From, Err) + + end end end; {true, false} -> diff --git a/src/mod_stats.erl b/src/mod_stats.erl index a11564e94..b332ac826 100644 --- a/src/mod_stats.erl +++ b/src/mod_stats.erl @@ -162,12 +162,7 @@ get_local_stat(_Server, [], Name) when Name == <<"users/all-hosts/total">> -> ejabberd_auth:get_vh_registered_users_number(Host) + Total end, 0, ejabberd_config:get_global_option(hosts)), - case NumUsers of - {'EXIT', _Reason} -> - ?STATERR(<<"500">>, <<"Internal Server Error">>); - Users -> - ?STATVAL(list_to_binary(integer_to_list(Users)), <<"users">>) - end; + ?STATVAL(list_to_binary(integer_to_list(NumUsers)), <<"users">>); get_local_stat(_Server, _, Name) -> ?STATERR(<<"404">>, <<"Not Found">>). |