8177398: Exclude dot files ending with .conf from krb5.conf's includedir
authorweijun
Fri, 26 Jan 2018 09:37:10 +0800
changeset 48672 77baeab90732
parent 48671 a47ee8b3d308
child 48673 e321560ac819
8177398: Exclude dot files ending with .conf from krb5.conf's includedir Reviewed-by: mullan
src/java.security.jgss/share/classes/sun/security/krb5/Config.java
test/jdk/sun/security/krb5/config/Include.java
--- a/src/java.security.jgss/share/classes/sun/security/krb5/Config.java	Thu Jan 25 13:40:36 2018 -0800
+++ b/src/java.security.jgss/share/classes/sun/security/krb5/Config.java	Fri Jan 26 09:37:10 2018 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -578,7 +578,8 @@
                             if (Files.isDirectory(p)) continue;
                             String name = p.getFileName().toString();
                             if (name.matches("[a-zA-Z0-9_-]+") ||
-                                    name.endsWith(".conf")) {
+                                    (!name.startsWith(".") &&
+                                            name.endsWith(".conf"))) {
                                 // if dir is absolute, so is p
                                 readConfigFileLines(p, content, dups);
                             }
--- a/test/jdk/sun/security/krb5/config/Include.java	Thu Jan 25 13:40:36 2018 -0800
+++ b/test/jdk/sun/security/krb5/config/Include.java	Fri Jan 26 09:37:10 2018 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug 8029994 8177085
+ * @bug 8029994 8177085 8177398
  * @summary Support "include" and "includedir" in krb5.conf
  * @modules java.security.jgss/sun.security.krb5
  * @compile -XDignore.symbol.file Include.java
@@ -53,6 +53,7 @@
         Path df2 = Paths.get("d/f2");       // another file
         Path df3 = Paths.get("d/f.3");      // third file bad name
         Path df4 = Paths.get("d/f4.conf");  // fourth file
+        Path df5 = Paths.get("d/.f5.conf"); // fifth file is dotfile
 
         // OK: The base file can be missing
         System.setProperty("java.security.krb5.conf", "no-such-file");
@@ -103,6 +104,8 @@
         Files.write(ddf, (krb5Conf + "ddf").getBytes());
         // fx4 will be loaded
         Files.write(df4, (krb5Conf + "df4").getBytes());
+        // fx5 will be excluded
+        Files.write(df5, (krb5Conf + "df5").getBytes());
 
         // OK: All good files read
         tryReload(true);