Use 0755 instead of 0777 when creating a writable directory.
This matches the permissions used for output files and tree artifacts (see ActionMetadataHandler#setPathPermissions), as well as the behavior of UnixFileSystem#setWritable (which only touches the user bit).
PiperOrigin-RevId: 510111759
Change-Id: Iebd8e4d07dff86e12035afe2cab8ba0b4decbfd7
diff --git a/src/main/java/com/google/devtools/build/lib/vfs/AbstractFileSystem.java b/src/main/java/com/google/devtools/build/lib/vfs/AbstractFileSystem.java
index 1ff1435..51434af 100644
--- a/src/main/java/com/google/devtools/build/lib/vfs/AbstractFileSystem.java
+++ b/src/main/java/com/google/devtools/build/lib/vfs/AbstractFileSystem.java
@@ -141,7 +141,7 @@
throw new IOException(path + " (Not a directory)");
}
- chmod(path, 0777);
+ chmod(path, 0755);
return false;
}
diff --git a/src/main/native/unix_jni.cc b/src/main/native/unix_jni.cc
index 1af7983..477a4c3 100644
--- a/src/main/native/unix_jni.cc
+++ b/src/main/native/unix_jni.cc
@@ -576,7 +576,7 @@
return false;
}
// directory does not exist.
- if (::mkdir(path_chars, 0777) == -1) {
+ if (::mkdir(path_chars, 0755) == -1) {
PostException(env, errno, path_chars);
}
return true;
@@ -587,7 +587,7 @@
return false;
}
// Make sure the mode is correct.
- if ((statbuf.st_mode & 0777) != 0777 && ::chmod(path_chars, 0777) == -1) {
+ if ((statbuf.st_mode & 0755) != 0755 && ::chmod(path_chars, 0755) == -1) {
PostException(env, errno, path_chars);
}
return false;