Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 364665 - Launching remote command fails if command must be set in initial request
Summary: Launching remote command fails if command must be set in initial request
Status: NEW
Alias: None
Product: Target Management
Classification: Tools
Component: RSE (show other bugs)
Version: 3.2.2   Edit
Hardware: PC Linux
: P3 major (vote)
Target Milestone: ---   Edit
Assignee: dsdp.tm.rse-inbox CLA
QA Contact: Martin Oberhuber CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-11-23 21:05 EST by Rob Stryker CLA
Modified: 2011-11-23 21:05 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Rob Stryker CLA 2011-11-23 21:05:49 EST
Given a remote server with the following characteristics:
   1) Rejects ssh connections with no attached command
   2) Rejects ssh connections if the attached command is not an approved command

From the CLI, the following commands give the following output:
   1)  Command:  ssh user@host 
       Output:   Connections require an approved command
   2)  Command:  ssh user@host 'ls'
       Output:   Invalid command ls
   3)  Command:  ssh user@host 'tail folder/i/own/*'
       Output:   (expected output, tail of files, etc)

When using RSE, the server's response is always the one from example 1... as if an initial command is not set when connecting to the host. 

My first attempt to fix it involved drilling down into IShellService.runCommand(etc). It is there revealed that the code in TerminalShellService.runCommand(etc) includes the following:

	ITerminalShell terminalShell = fTerminalService.launchTerminal("vt100",
		encoding, environment, initialWorkingDirectory, null, monitor);
	TerminalServiceHostShell hostShell = new TerminalServiceHostShell(
		terminalShell, initialWorkingDirectory, command, environment);

IT is clear here that the first command to launch the ITerminalShell passes null in as the command. It clearly tries to create a terminal with no command, then create a shell out of it. This would explain the rejection by the server, as the server will reject all ssh connections with no command. 

In my own code, I attempted the following:

	SshTerminalService sshTerminalService = (SshTerminalService)terminalService;
	tshell = new SshTerminalShell(sshTerminalService.getSessionProvider(), "vt100", 
		null, new String[]{}, null, command);

This is to force the command to be passed into the first shell command. However, even in this situation, the remote host still replies with "Connections require an approved command", the output from use-case 1. 

I am left with no way to simulate ssh user@host 'tail *.txt', or something similar. 

Any ideas?