提交 28b17b74 编写于 作者: D dxu

7065902: (file) test/java/nio/file/Files/Misc.java fails on Solaris 11 when run as root

Reviewed-by: alanb
上级 1dba94ef
/* /*
* Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -313,8 +313,14 @@ public class Misc { ...@@ -313,8 +313,14 @@ public class Misc {
acl.add(0, entry); acl.add(0, entry);
view.setAcl(acl); view.setAcl(acl);
try { try {
assertTrue(!isWritable(file)); if (isRoot()) {
assertTrue(!isExecutable(file)); // root has all permissions
assertTrue(isWritable(file));
assertTrue(isExecutable(file));
} else {
assertTrue(!isWritable(file));
assertTrue(!isExecutable(file));
}
} finally { } finally {
// Restore ACL // Restore ACL
acl.remove(0); acl.remove(0);
...@@ -353,4 +359,12 @@ public class Misc { ...@@ -353,4 +359,12 @@ public class Misc {
if (!okay) if (!okay)
throw new RuntimeException("Assertion Failed"); throw new RuntimeException("Assertion Failed");
} }
private static boolean isRoot() {
if (System.getProperty("os.name").startsWith("Windows"))
return false;
Path passwd = Paths.get("/etc/passwd");
return Files.isWritable(passwd);
}
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册