Bug 197536 - [remotecdt] RemoteRunLaunchDelegate#remoteShellExec not compatible with Windows remote system
Summary: [remotecdt] RemoteRunLaunchDelegate#remoteShellExec not compatible with Windo...
Status: NEW
Alias: None
Product: CDT
Classification: Tools
Component: cdt-debug (show other bugs)
Version: 6.0   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: cdt-debug-inbox@eclipse.org CLA
QA Contact: Jonah Graham CLA
URL:
Whiteboard:
Keywords: helpwanted
Depends on:
Blocks:
 
Reported: 2007-07-23 15:33 EDT by Troy Brant CLA
Modified: 2020-09-04 15:20 EDT (History)
5 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Troy Brant CLA 2007-07-23 15:33:11 EDT
Build ID: I20070625-1500

Steps To Reproduce:
1. In the remote CDT launch config, select a connection to a remote system running Windows
2. In "Remote Absolute File Path for C/C++ Application", browse for and select any path
3. Set a breakpoint on org.eclipse.rse.internal.remotecdt.RemoteRunLaunchDelegate#remoteShellExec line 278.
4. Look at remote_command parameter. You should see 
"chmod +x [path];exit"
For instance, my remote_command param is 
"chmod +x C:/Documents\ and\ Settings/user/rsetemp;exit". 

There are three problems here for Windows: 
 1) ";" is not recognized as a command delimeter. Use " && " instead.
 2) If the [path] parameter is absolute, it uses a forward slash after the drive letter, which is invalid in Windows. In windows, forward slashes everywhere else in a path are kosher, just not after the drive letter. After stepping through your code, though, I see you just call remotePath.toString() in remoteFileDownload line 255, where remotePath is an instance of org.eclipse.core.runtime.Path. I don't know why Path doesn't just use backslashes for windows and forward slashes for linux.
 3) spaceEscapify only works for linux paths. In windows, the backslashes are interpreted as path delimeters, not escape chars. Instead of escaping the spaces, you could just add escaped quotes around the entire path.

So, when all the fixes above are put in place, 

"chmod +x C:/Documents\ and\ Settings/user/rsetemp;exit"

would become

"chmod +x \"C:\\Documents and Settings\\user\\rsetemp\" && exit"

And, incidentally, this valid Unix syntax as well.
Comment 1 Troy Brant CLA 2007-07-23 15:43:39 EDT
Also, is there a reason IHostFile or AbstractRemoteFile don't have more functionality dealing with permissions? There's canRead and canWrite for both of these classes, but why aren't there canExecute, setReadable, setWriteable, setExecutable?

I say this because it seems instead of sending the "chmod +x" command to the shell, you could just wrap the target file in an instance of an AbstractRemoteFile, and call setExecutable() (if it existed) on it.

Are there plans to make setting/getting permissions more robust in the future?
Comment 2 Troy Brant CLA 2007-07-23 17:17:41 EDT
(In reply to comment #0)

> "chmod +x \"C:\\Documents and Settings\\user\\rsetemp\" && exit"
> 
> And, incidentally, this valid Unix syntax as well.
> 

On review, I'm wrong about that. Backslashes aren't valid path delimeters in Unix.
Comment 3 Troy Brant CLA 2007-07-26 01:15:29 EDT
Changed the product from "DSDP" to "Target Management". Seems that's where the bug belonged in the first place.
Comment 4 Martin Oberhuber CLA 2008-05-20 17:50:49 EDT
Drasch do you think that this is relevant for WB?
Comment 5 Martin Oberhuber CLA 2008-05-30 13:24:15 EDT
I agree that we should check whether the remote system is windows style. Unfortunately that's not too easy if we want to do it dynamically -- an "SSH Only" connection can be done to Windows, or UNIX.

I think that as a starting point we should use the static configuration that users can do via the SystemType already now. That way we would fix the issue for "Dstore Windows" vs "DStore other":
  IRSESystemType#isWindows()
e.g.
  if (subSystem.getHost().getSystemType().isWindows()) {...}

For the chmod issue, this is legacy code and we could now take advantage of the new IFileService#setFilePermissions() method if it's available (can be checked via  IFilePermissionsService#getCapabilities():

IService fs = subSystem.getService();
if (fs instanceof IFilePermissionsService) {
  IFilePermissionsService ps = (IFilePermissionsService)fs;
  if (ps.getCapabilties() & IFilePermissionsService.FS_CAN_SET_PERMISSIONS != 0)
     /*...*/
  }


-- though I'm slightly more in favor of keeping chmod for now, but only executing it if we're not on windows.

Setting "helpwanted", Community patches for would be appreciated for this.
Comment 6 Martin Oberhuber CLA 2008-09-23 13:03:31 EDT
Anna do you want to have a look?
Comment 7 Anna Dushistova CLA 2009-04-16 12:06:35 EDT
Don't have time for it right now.
Comment 8 Martin Oberhuber CLA 2009-04-30 11:52:29 EDT
Moving into CDT as per bug 267065.
Comment 9 Jonah Graham CLA 2019-12-30 18:54:50 EST
This bug was assigned and targeted at a now released milestone (or Future or Next that isn't being used by CDT). As that milestone has now passed, the milestone field has been cleared. If this bug has been fixed, please set the milestone to the version it was fixed in and mark the bug as resolved.