equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. Oracle designates this |
7 * published by the Free Software Foundation. Oracle designates this |
147 // first try the search keyword in /etc/resolv.conf |
147 // first try the search keyword in /etc/resolv.conf |
148 |
148 |
149 sl = java.security.AccessController.doPrivileged( |
149 sl = java.security.AccessController.doPrivileged( |
150 new java.security.PrivilegedAction<LinkedList<String>>() { |
150 new java.security.PrivilegedAction<LinkedList<String>>() { |
151 public LinkedList<String> run() { |
151 public LinkedList<String> run() { |
152 LinkedList ll; |
152 LinkedList<String> ll; |
153 |
153 |
154 // first try search keyword (max 6 domains) |
154 // first try search keyword (max 6 domains) |
155 ll = resolvconf("search", 6, 1); |
155 ll = resolvconf("search", 6, 1); |
156 if (ll.size() > 0) { |
156 if (ll.size() > 0) { |
157 return ll; |
157 return ll; |
171 |
171 |
172 // LOCALDOMAIN has absolute priority on Solaris |
172 // LOCALDOMAIN has absolute priority on Solaris |
173 |
173 |
174 String localDomain = localDomain0(); |
174 String localDomain = localDomain0(); |
175 if (localDomain != null && localDomain.length() > 0) { |
175 if (localDomain != null && localDomain.length() > 0) { |
176 sl = new LinkedList(); |
176 sl = new LinkedList<String>(); |
177 sl.add(localDomain); |
177 sl.add(localDomain); |
178 return sl; |
178 return sl; |
179 } |
179 } |
180 |
180 |
181 // try domain keyword in /etc/resolv.conf |
181 // try domain keyword in /etc/resolv.conf |
196 if (sl != null) { |
196 if (sl != null) { |
197 return sl; |
197 return sl; |
198 } |
198 } |
199 |
199 |
200 // no local domain so try fallback (RPC) domain or |
200 // no local domain so try fallback (RPC) domain or |
201 // hostname |
201 // hostName |
202 |
202 |
203 sl = new LinkedList<>(); |
203 sl = new LinkedList<>(); |
204 String domain = fallbackDomain0(); |
204 String domain = fallbackDomain0(); |
205 if (domain != null && domain.length() > 0) { |
205 if (domain != null && domain.length() > 0) { |
206 sl.add(domain); |
206 sl.add(domain); |
214 |
214 |
215 ResolverConfigurationImpl() { |
215 ResolverConfigurationImpl() { |
216 opts = new OptionsImpl(); |
216 opts = new OptionsImpl(); |
217 } |
217 } |
218 |
218 |
|
219 @SuppressWarnings("unchecked") |
219 public List<String> searchlist() { |
220 public List<String> searchlist() { |
220 synchronized (lock) { |
221 synchronized (lock) { |
221 loadConfig(); |
222 loadConfig(); |
222 |
223 |
223 // List is mutable so return a shallow copy |
224 // List is mutable so return a shallow copy |
224 return (List)searchlist.clone(); |
225 return (List<String>)searchlist.clone(); |
225 } |
226 } |
226 } |
227 } |
227 |
228 |
|
229 @SuppressWarnings("unchecked") |
228 public List<String> nameservers() { |
230 public List<String> nameservers() { |
229 synchronized (lock) { |
231 synchronized (lock) { |
230 loadConfig(); |
232 loadConfig(); |
231 |
233 |
232 // List is mutable so return a shallow copy |
234 // List is mutable so return a shallow copy |
233 return (List)nameservers.clone(); |
235 |
234 } |
236 return (List<String>)nameservers.clone(); |
|
237 |
|
238 } |
235 } |
239 } |
236 |
240 |
237 public Options options() { |
241 public Options options() { |
238 return opts; |
242 return opts; |
239 } |
243 } |