aboutsummaryrefslogtreecommitdiffstats
path: root/lib/kernel/src/inet.erl
diff options
context:
space:
mode:
authorRaimo Niskanen <[email protected]>2013-06-10 11:50:51 +0200
committerRaimo Niskanen <[email protected]>2013-06-10 11:50:51 +0200
commit429a774fad2696eb719834b627fc0a7322a48a34 (patch)
tree8207a997353193bbcb1a1fd87ac731771f4e6e6b /lib/kernel/src/inet.erl
parentf488b8eafe4186d2bc3cce57a534fdc68ebb186c (diff)
parent10671126a75d14977a769d9dfce461482093c5c8 (diff)
downloadotp-429a774fad2696eb719834b627fc0a7322a48a34.tar.gz
otp-429a774fad2696eb719834b627fc0a7322a48a34.tar.bz2
otp-429a774fad2696eb719834b627fc0a7322a48a34.zip
Merge branch 'maint'
Conflicts: lib/kernel/src/inet_db.erl
Diffstat (limited to 'lib/kernel/src/inet.erl')
-rw-r--r--lib/kernel/src/inet.erl39
1 files changed, 26 insertions, 13 deletions
diff --git a/lib/kernel/src/inet.erl b/lib/kernel/src/inet.erl
index 1a1f7b8cbc..6f65968fc2 100644
--- a/lib/kernel/src/inet.erl
+++ b/lib/kernel/src/inet.erl
@@ -947,21 +947,34 @@ gethostbyname_self(Name, Type) when is_atom(Name) ->
gethostbyname_self(Name, Type)
when is_list(Name), Type =:= inet;
is_list(Name), Type =:= inet6 ->
- case inet_db:gethostname() of
- Name ->
- {ok,make_hostent(Name,
- [translate_ip(loopback, Type)],
- [], Type)};
- Self ->
+ N = inet_db:tolower(Name),
+ Self = inet_db:gethostname(),
+ %%
+ %% This is the final fallback that pretends /etc/hosts has got
+ %% a line for the hostname on the loopback address.
+ %% Lookups into /etc/hosts are case insensitive and return
+ %% what is in the file. Therefore the letter case may differ between
+ %% the returned hostent record and the hostname that was asked for.
+ %%
+ case inet_db:tolower(Self) of
+ N ->
+ {ok,
+ make_hostent(
+ Self, [translate_ip(loopback, Type)], [], Type)};
+ _ ->
case inet_db:res_option(domain) of
- "" -> {error,nxdomain};
+ "" ->
+ {error,nxdomain};
Domain ->
- case lists:append([Self,".",Domain]) of
- Name ->
- {ok,make_hostent(Name,
- [translate_ip(loopback, Type)],
- [], Type)};
- _ -> {error,nxdomain}
+ FQDN = lists:append([Self,".",Domain]),
+ case inet_db:tolower(FQDN) of
+ N ->
+ {ok,
+ make_hostent(
+ FQDN,
+ [translate_ip(loopback, Type)], [], Type)};
+ _ ->
+ {error,nxdomain}
end
end
end;