Skip to content

Commit 08dc34c

Browse files
authored
Merge pull request #4331 from esl/fix-ldap-dialyzer
Fix ldap dialyzer warnings on Erlang 27
2 parents 7dbbbdb + 2ce02e3 commit 08dc34c

File tree

3 files changed

+14
-9
lines changed

3 files changed

+14
-9
lines changed

src/eldap_filter_yecc.yrl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ Erlang code.
5454

5555
'and'(Value) -> eldap:'and'(eldap_utils:maybe_b2list(Value)).
5656
'or'(Value) -> eldap:'or'(eldap_utils:maybe_b2list(Value)).
57-
'not'(Value) -> eldap:'not'(eldap_utils:maybe_b2list(Value)).
57+
'not'(Value) -> eldap:'not'(Value).
5858
equal(Desc, Value) -> eldap:equalityMatch(Desc, eldap_utils:maybe_b2list(Value)).
5959
approx(Desc, Value) -> eldap:approxMatch(Desc, eldap_utils:maybe_b2list(Value)).
6060
greater(Desc, Value) -> eldap:greaterOrEqual(Desc, eldap_utils:maybe_b2list(Value)).
@@ -68,4 +68,4 @@ final(Value) -> {final, eldap_utils:maybe_b2list(Value)}.
6868
xattr(Value) -> {type, eldap_utils:maybe_b2list(Value)}.
6969
matchingrule(Value) -> {matchingRule, eldap_utils:maybe_b2list(Value)}.
7070
value_of(Token) -> iolist_to_binary(element(3, Token)).
71-
flatten(List) -> lists:flatten(List).
71+
flatten(List) -> lists:flatten(List).

src/eldap_utils.erl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ match_filter_name({<<"%u">>, [Value | _]}, NewUIDs) when Value /= <<"">> ->
191191
end;
192192
match_filter_name({Name, [Value | _]}, _NewUIDs) when Value /= <<"">> ->
193193
case binary:match(Value, <<"*">>) of
194-
nomatch -> [eldap:equalityMatch(Name, Value)];
194+
nomatch -> [eldap:equalityMatch(maybe_b2list(Name), maybe_b2list(Value))];
195195
_ -> [eldap:substrings(maybe_b2list(Name),
196196
generate_substring_list(Value))]
197197
end;

src/mongoose_ldap_worker.erl

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,18 +72,23 @@ call_eldap(Request, State) ->
7272
{Result, State}
7373
end.
7474

75+
connect_opts(State = #{port := Port,
76+
root_dn := RootDN,
77+
password := Password}) ->
78+
AnonAuth = RootDN =:= <<>> andalso Password =:= <<>>,
79+
SSLConfig = case State of
80+
#{tls := TLSOptions} -> [{sslopts, just_tls:make_ssl_opts(TLSOptions)}];
81+
#{} -> []
82+
end,
83+
[{port, Port}, {anon_auth, AnonAuth}] ++ SSLConfig.
84+
7585
connect(State = #{handle := none,
7686
servers := Servers,
7787
port := Port,
7888
root_dn := RootDN,
7989
password := Password,
8090
connect_interval := ConnectInterval}) ->
81-
AnonAuth = RootDN =:= <<>> andalso Password =:= <<>>,
82-
SSLConfig = case State of
83-
#{tls := TLSOptions} -> [{sslopts, just_tls:make_ssl_opts(TLSOptions)}];
84-
#{} -> []
85-
end,
86-
case eldap:open(Servers, [{port, Port}, {anon_auth, AnonAuth}] ++ SSLConfig) of
91+
case eldap:open(Servers, connect_opts(State)) of
8792
{ok, Handle} ->
8893
case eldap:simple_bind(Handle, RootDN, Password) of
8994
ok ->

0 commit comments

Comments
 (0)