< prev index next >

src/java.base/unix/classes/sun/net/dns/ResolverConfigurationImpl.java

Print this page
rev 59383 : [mq]: final
   1 /*
   2  * Copyright (c) 2002, 2019, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   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
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 160                     public LinkedList<String> run() {
 161                         LinkedList<String> ll;
 162 
 163                         // first try search keyword (max 6 domains)
 164                         ll = resolvconf("search", 6, 1);
 165                         if (ll.size() > 0) {
 166                             return ll;
 167                         }
 168 
 169                         return null;
 170 
 171                     } /* run */
 172 
 173                 });
 174         if (sl != null) {
 175             return sl;
 176         }
 177 
 178         // No search keyword so use local domain
 179 
 180 
 181         // LOCALDOMAIN has absolute priority on Solaris
 182 
 183         String localDomain = localDomain0();
 184         if (localDomain != null && !localDomain.isEmpty()) {
 185             sl = new LinkedList<>();
 186             sl.add(localDomain);
 187             return sl;
 188         }
 189 
 190         // try domain keyword in /etc/resolv.conf
 191 
 192         sl = java.security.AccessController.doPrivileged(
 193                  new java.security.PrivilegedAction<>() {
 194                     public LinkedList<String> run() {
 195                         LinkedList<String> ll;
 196 
 197                         ll = resolvconf("domain", 1, 1);
 198                         if (ll.size() > 0) {
 199                             return ll;
 200                         }
 201                         return null;
 202 
 203                     } /* run */
 204                 });
 205         if (sl != null) {
 206             return sl;
 207         }
 208 
 209         // no local domain so try fallback (RPC) domain or


 236     }
 237 
 238     @SuppressWarnings("unchecked")
 239     public List<String> nameservers() {
 240         synchronized (lock) {
 241             loadConfig();
 242 
 243             // List is mutable so return a shallow copy
 244 
 245           return (List<String>)nameservers.clone();
 246 
 247         }
 248     }
 249 
 250     public Options options() {
 251         return opts;
 252     }
 253 
 254 
 255     // --- Native methods --
 256 
 257     static native String localDomain0();
 258 
 259     static native String fallbackDomain0();
 260 
 261     static {
 262         jdk.internal.loader.BootLoader.loadLibrary("net");
 263     }
 264 
 265 }
 266 
 267 /**
 268  * Implementation of {@link ResolverConfiguration.Options}
 269  */
 270 class OptionsImpl extends ResolverConfiguration.Options {
 271 }
   1 /*
   2  * Copyright (c) 2002, 2020, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   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
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 160                     public LinkedList<String> run() {
 161                         LinkedList<String> ll;
 162 
 163                         // first try search keyword (max 6 domains)
 164                         ll = resolvconf("search", 6, 1);
 165                         if (ll.size() > 0) {
 166                             return ll;
 167                         }
 168 
 169                         return null;
 170 
 171                     } /* run */
 172 
 173                 });
 174         if (sl != null) {
 175             return sl;
 176         }
 177 
 178         // No search keyword so use local domain
 179 










 180         // try domain keyword in /etc/resolv.conf
 181 
 182         sl = java.security.AccessController.doPrivileged(
 183                  new java.security.PrivilegedAction<>() {
 184                     public LinkedList<String> run() {
 185                         LinkedList<String> ll;
 186 
 187                         ll = resolvconf("domain", 1, 1);
 188                         if (ll.size() > 0) {
 189                             return ll;
 190                         }
 191                         return null;
 192 
 193                     } /* run */
 194                 });
 195         if (sl != null) {
 196             return sl;
 197         }
 198 
 199         // no local domain so try fallback (RPC) domain or


 226     }
 227 
 228     @SuppressWarnings("unchecked")
 229     public List<String> nameservers() {
 230         synchronized (lock) {
 231             loadConfig();
 232 
 233             // List is mutable so return a shallow copy
 234 
 235           return (List<String>)nameservers.clone();
 236 
 237         }
 238     }
 239 
 240     public Options options() {
 241         return opts;
 242     }
 243 
 244 
 245     // --- Native methods --


 246 
 247     static native String fallbackDomain0();
 248 
 249     static {
 250         jdk.internal.loader.BootLoader.loadLibrary("net");
 251     }
 252 
 253 }
 254 
 255 /**
 256  * Implementation of {@link ResolverConfiguration.Options}
 257  */
 258 class OptionsImpl extends ResolverConfiguration.Options {
 259 }
< prev index next >