--- a/src/hotspot/os/aix/attachListener_aix.cpp Wed May 09 06:51:41 2018 +0200
+++ b/src/hotspot/os/aix/attachListener_aix.cpp Wed May 09 07:48:31 2018 +0100
@@ -235,7 +235,12 @@
if (res == 0) {
RESTARTABLE(::chmod(initial_path, S_IREAD|S_IWRITE), res);
if (res == 0) {
- res = ::rename(initial_path, path);
+ // make sure the file is owned by the effective user and effective group
+ // e.g. the group could be inherited from the directory in case the s bit is set
+ RESTARTABLE(::chown(initial_path, geteuid(), getegid()), res);
+ if (res == 0) {
+ res = ::rename(initial_path, path);
+ }
}
}
if (res == -1) {
--- a/src/hotspot/os/bsd/attachListener_bsd.cpp Wed May 09 06:51:41 2018 +0200
+++ b/src/hotspot/os/bsd/attachListener_bsd.cpp Wed May 09 07:48:31 2018 +0100
@@ -215,7 +215,8 @@
RESTARTABLE(::chmod(initial_path, S_IREAD|S_IWRITE), res);
if (res == 0) {
// make sure the file is owned by the effective user and effective group
- // (this is the default on linux, but not on mac os)
+ // e.g. default behavior on mac is that new files inherit the group of
+ // the directory that they are created in
RESTARTABLE(::chown(initial_path, geteuid(), getegid()), res);
if (res == 0) {
res = ::rename(initial_path, path);
--- a/src/hotspot/os/linux/attachListener_linux.cpp Wed May 09 06:51:41 2018 +0200
+++ b/src/hotspot/os/linux/attachListener_linux.cpp Wed May 09 07:48:31 2018 +0100
@@ -215,7 +215,12 @@
if (res == 0) {
RESTARTABLE(::chmod(initial_path, S_IREAD|S_IWRITE), res);
if (res == 0) {
- res = ::rename(initial_path, path);
+ // make sure the file is owned by the effective user and effective group
+ // e.g. the group could be inherited from the directory in case the s bit is set
+ RESTARTABLE(::chown(initial_path, geteuid(), getegid()), res);
+ if (res == 0) {
+ res = ::rename(initial_path, path);
+ }
}
}
if (res == -1) {