Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

J9 Allow attachment as root #1631

Merged
merged 2 commits into from
May 3, 2024
Merged

J9 Allow attachment as root #1631

merged 2 commits into from
May 3, 2024

Conversation

FelixMarxIBM
Copy link
Contributor

@FelixMarxIBM FelixMarxIBM commented May 3, 2024

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

if ((ROOT_UID == myUid) && (ROOT_UID != targetUid)) {
  IPC.chownFileToTargetUid(replyFileAbsolutePath, targetUid);
}

https://github.com/eclipse-openj9/openj9/blob/master/jcl/src/java.base/share/classes/openj9/internal/tools/attach/target/CommonDirectory.java#L418-L426

/**
* 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()));
}

@raphw raphw merged commit 156ba85 into raphw:master May 3, 2024
10 checks passed
@raphw raphw self-assigned this May 3, 2024
@raphw raphw added the bug label May 3, 2024
@raphw raphw added this to the 1.14.12 milestone May 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants