@@ -1717,13 +1717,23 @@ public static VirtualMachine attach(String processId, int timeout, Dispatcher di
17171717 ? new File (dispatcher .getTemporaryFolder (processId ), ".com_ibm_tools_attach" )
17181718 : new File (temporary );
17191719 long userId = dispatcher .userId ();
1720- RandomAccessFile attachLock = new RandomAccessFile (new File (directory , "_attachlock" ), "rw" );
1720+ File attachLockFile = new File (directory , "_attachlock" );
1721+ boolean attachLockCreated = attachLockFile .createNewFile ();
1722+ RandomAccessFile attachLock = new RandomAccessFile (attachLockFile , "rw" );
17211723 try {
1724+ if (attachLockCreated || userId == 0 || dispatcher .getOwnerIdOf (attachLockFile ) == userId ) {
1725+ dispatcher .setPermissions (attachLockFile , 0666 );
1726+ }
17221727 FileLock attachLockLock = attachLock .getChannel ().lock ();
17231728 try {
17241729 List <Properties > virtualMachines ;
1725- RandomAccessFile master = new RandomAccessFile (new File (directory , "_master" ), "rw" );
1730+ File masterFile = new File (directory , "_master" );
1731+ boolean masterCreated = masterFile .createNewFile ();
1732+ RandomAccessFile master = new RandomAccessFile (masterFile , "rw" );
17261733 try {
1734+ if (masterCreated || userId == 0 || dispatcher .getOwnerIdOf (masterFile ) == userId ) {
1735+ dispatcher .setPermissions (masterFile , 0666 );
1736+ }
17271737 FileLock masterLock = master .getChannel ().lock ();
17281738 try {
17291739 File [] vmFolder = directory .listFiles ();
0 commit comments