Github user aledsage commented on a diff in the pull request:
https://github.com/apache/incubator-brooklyn/pull/896#discussion_r39493339
--- Diff:
utils/common/src/main/java/org/apache/brooklyn/util/io/FileUtil.java ---
@@ -73,36 +77,11 @@ public static void setFilePermissionsTo700(File file)
throws IOException {
}
}
- // When we move to java 7, we can use Files.setPosixFilePermissions
+ private static final Set<PosixFilePermission> posixPermissions600 =
PosixFilePermissions.fromString("rw-------");
+
public static void setFilePermissionsTo600(File file) throws
IOException {
file.createNewFile();
- file.setExecutable(false, false);
- file.setReadable(false, false);
- file.setWritable(false, false);
- file.setReadable(true, true);
- file.setWritable(true, true);
-
- boolean setRead = file.setReadable(false, false) &
file.setReadable(true, true);
- boolean setWrite = file.setWritable(false, false) &
file.setWritable(true, true);
- boolean setExec = file.setExecutable(false, false);
-
- if (setRead && setWrite && setExec) {
- if (LOG.isTraceEnabled()) LOG.trace("Set permissions to 600
for file {}", file.getAbsolutePath());
- } else {
- if (loggedSetFilePermissionsWarning) {
- if (LOG.isTraceEnabled()) LOG.trace("Failed to set
permissions to 600 for file {}: setRead={}, setWrite={}, setExecutable={}",
- new Object[] {file.getAbsolutePath(), setRead,
setWrite, setExec});
- } else {
- if (Os.isMicrosoftWindows()) {
--- End diff --
On windows, will we get an `UnsupportedOperationException` from
`Files.setPosixFilePermissions`? If so, it would be good to preserve the old
behaviour, rather than fail: to log about it (but to guard that log with the
`loggedSetFilePermissionsWarning` check so that we only log once).
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---