Skip to content

Commit

Permalink
Add property to allow disabling user check for J9 which does not seem…
Browse files Browse the repository at this point in the history
… to be implemented.
  • Loading branch information
raphw committed Apr 29, 2024
1 parent 5b7c966 commit f04d254
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -1627,6 +1627,13 @@ protected Connection doConnect(File socket) {
*/
class ForOpenJ9 extends AbstractBase {

/**
* Property to indicate that the attachment does not validate that the attach file is owned by
* the current user. J9 requires this by its documentation but it does not appear to always be
* implemented.
*/
public static final String IGNORE_USER = "net.bytebuddy.attach.j9.ignoreuser";

/**
* The temporary folder for attachment files for OpenJ9 VMs.
*/
Expand Down Expand Up @@ -1688,10 +1695,11 @@ public static VirtualMachine attach(String processId, int timeout, Dispatcher di
if (vmFolder == null) {
throw new IllegalStateException("No descriptor files found in " + directory);
}
boolean ignoreUser = Boolean.getBoolean(IGNORE_USER);
long userId = dispatcher.userId();
virtualMachines = new ArrayList<Properties>();
for (File aVmFolder : vmFolder) {
if (aVmFolder.isDirectory() && dispatcher.getOwnerIdOf(aVmFolder) == userId) {
if (aVmFolder.isDirectory() && (ignoreUser || dispatcher.getOwnerIdOf(aVmFolder) == userId)) {
File attachInfo = new File(aVmFolder, "attachInfo");
if (attachInfo.isFile()) {
Properties virtualMachine = new Properties();
Expand Down

0 comments on commit f04d254

Please sign in to comment.