aboutsummaryrefslogtreecommitdiffstats
path: root/lib/kernel
diff options
context:
space:
mode:
authorRaimo Niskanen <raimo@erlang.org>2010-02-03 15:23:12 +0100
committerBjörn Gustavsson <bjorn@erlang.org>2010-02-09 13:41:42 +0100
commit8de5ac7737bd6f121af35ca60e22f0696bbdc06b (patch)
tree62cbd5c553a1bcd20305dcc2d4e97ae0103baa56 /lib/kernel
parent0377ecdfb001c4dc1b507ebc06211f29b19048e3 (diff)
downloadotp-8de5ac7737bd6f121af35ca60e22f0696bbdc06b.tar.gz
otp-8de5ac7737bd6f121af35ca60e22f0696bbdc06b.tar.bz2
otp-8de5ac7737bd6f121af35ca60e22f0696bbdc06b.zip
inet_res: /etc/resolv.conf: use domain as default search list
When the search list option in /etc/resolv.conf was empty, the domain option was not used as default search domain. That has been fixed in this patch.
Diffstat (limited to 'lib/kernel')
-rw-r--r--lib/kernel/src/inet_db.erl19
-rw-r--r--lib/kernel/test/inet_res_SUITE.erl2
2 files changed, 16 insertions, 5 deletions
diff --git a/lib/kernel/src/inet_db.erl b/lib/kernel/src/inet_db.erl
index 9cdffb5f2c..00c3a6af9c 100644
--- a/lib/kernel/src/inet_db.erl
+++ b/lib/kernel/src/inet_db.erl
@@ -1011,13 +1011,22 @@ handle_call(Request, From, #state{db=Db}=State) ->
case inet_parse:resolv(
Fname, {chars,Bin}) of
{ok,Opts} ->
+ Search =
+ lists:foldl(
+ fun ({search,L}, _) ->
+ L;
+ ({domain,""}, S) ->
+ S;
+ ({domain,D}, _) ->
+ [D];
+ (_, S) ->
+ S
+ end, [], Opts),
[del_ns,
clear_search,
- clear_cache
- |[Opt ||
- {T,_}=Opt <- Opts,
- (T =:= nameserver orelse
- T =:= search)]];
+ clear_cache,
+ {search,Search}
+ |[Opt || {nameserver,_}=Opt <- Opts]];
_ -> error
end
end,
diff --git a/lib/kernel/test/inet_res_SUITE.erl b/lib/kernel/test/inet_res_SUITE.erl
index 5c6e689253..20e3e690d3 100644
--- a/lib/kernel/test/inet_res_SUITE.erl
+++ b/lib/kernel/test/inet_res_SUITE.erl
@@ -331,11 +331,13 @@ files_monitor(suite) ->
files_monitor(doc) ->
["Tests monitoring of /etc/hosts and /etc/resolv.conf, but not them"];
files_monitor(Config) when is_list(Config) ->
+ Search = inet_db:res_option(search),
HostsFile = inet_db:res_option(hosts_file),
ResolvConf = inet_db:res_option(resolv_conf),
Inet6 = inet_db:res_option(inet6),
try do_files_monitor(Config)
after
+ inet_db:res_option(search, Search),
inet_db:res_option(resolv_conf, ResolvConf),
inet_db:res_option(hosts_file, HostsFile),
inet_db:res_option(inet6, Inet6)