8172017: Two tests sun/security/krb5/auto/ReplayCacheTestProc.java and rcache_usemd5.sh fail on Solaris
authorweijun
Thu, 05 Jan 2017 22:37:52 +0800
changeset 42998 1a5bb301d855
parent 42997 5f83f2054eca
child 42999 110c2df82517
8172017: Two tests sun/security/krb5/auto/ReplayCacheTestProc.java and rcache_usemd5.sh fail on Solaris Reviewed-by: mullan
jdk/test/sun/security/krb5/auto/ReplayCacheTestProc.java
--- a/jdk/test/sun/security/krb5/auto/ReplayCacheTestProc.java	Thu Jan 05 08:51:03 2017 +0100
+++ b/jdk/test/sun/security/krb5/auto/ReplayCacheTestProc.java	Thu Jan 05 22:37:52 2017 +0800
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug 7152176 8168518
+ * @bug 7152176 8168518 8172017
  * @summary More krb5 tests
  * @library ../../../../java/security/testlibrary/ /test/lib
  * @run main/othervm/timeout=300 ReplayCacheTestProc
@@ -75,19 +75,28 @@
     private static String HOST = "localhost";
 
     private static final String SERVICE;
+    private static long uid;
+    private static String cwd;
 
     static {
         String tmp = System.getProperty("test.service");
         SERVICE = (tmp == null) ? "service" : tmp;
+        uid = jdk.internal.misc.VM.geteuid();
+        // Where should the rcache be saved. KRB5RCACHEDIR is not
+        // recognized on Solaris (might be supported on Solaris 12),
+        // and directory name is different when launched by root.
+        // See manpage krb5envvar(5) on KRB5RCNAME.
+        if (System.getProperty("os.name").startsWith("SunOS")) {
+            if (uid == 0) {
+                cwd = "/var/krb5/rcache/root/";
+            } else {
+                cwd = "/var/krb5/rcache/";
+            }
+        } else {
+            cwd = System.getProperty("user.dir");
+        }
     }
 
-    // Where should the rcache be saved. It seems KRB5RCACHEDIR is not
-    // recognized on Solaris. Maybe version too low? I see 1.6.
-    private static String cwd =
-            System.getProperty("os.name").startsWith("SunOS") ?
-                "/var/krb5/rcache/" :
-                System.getProperty("user.dir");
-
     private static MessageDigest md5, sha256;
 
     static {
@@ -99,7 +108,6 @@
         }
     }
 
-    private static long uid;
 
     public static void main0(String[] args) throws Exception {
         System.setProperty("java.security.krb5.conf", OneKDC.KRB5_CONF);
@@ -114,8 +122,6 @@
             Ex[] result;
             int numPerType = 2; // number of acceptors per type
 
-            uid = jdk.internal.misc.VM.geteuid();
-
             KDC kdc = KDC.create(OneKDC.REALM, HOST, 0, true);
             for (int i=0; i<nc; i++) {
                 kdc.addPrincipal(client(i), OneKDC.PASS);