The J9 attachment allows root to start the attachment and be excluded from some of the checks.
By checking all folders as root and also doing a chown on the replyFile, we are able to attach also to user owned JVMs as root.
This is also true upstream in openj9 while reading the attachinfo and writing the replyfile
/**
* Check if the file is owned by the UID. Note that UID 0 "owns" all files.
* @param f File or directory
* @param myUid user UID.
* @return true if the uid owns the file or uid == 0.
*/
public static boolean isFileOwnedByUid(File f, long myUid) {
return (0 == myUid) || (myUid == CommonDirectory.getFileOwner(f.getAbsolutePath()));
}
This PR aims to solve #1628
The J9 attachment allows
root
to start the attachment and be excluded from some of the checks. By checking all folders as root and also doing a chown on the replyFile, we are able to attach also to user owned JVMs as root.This is also true upstream in openj9 while reading the attachinfo and writing the replyfile
References: https://github.com/eclipse-openj9/openj9/blob/master/jcl/src/java.base/share/classes/openj9/internal/tools/attach/target/Reply.java#L88-L90
https://github.com/eclipse-openj9/openj9/blob/master/jcl/src/java.base/share/classes/openj9/internal/tools/attach/target/CommonDirectory.java#L418-L426