mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-09 10:05:24 +02:00
Bug 162018 - try setting ssh environment through jsch
This commit is contained in:
parent
43613a11b6
commit
2cf0186dbd
1 changed files with 20 additions and 0 deletions
|
@ -20,11 +20,13 @@ import java.io.BufferedReader;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
|
import java.util.Hashtable;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
|
|
||||||
import com.jcraft.jsch.Channel;
|
import com.jcraft.jsch.Channel;
|
||||||
|
import com.jcraft.jsch.ChannelShell;
|
||||||
import com.jcraft.jsch.Session;
|
import com.jcraft.jsch.Session;
|
||||||
|
|
||||||
import org.eclipse.rse.services.shells.AbstractHostShell;
|
import org.eclipse.rse.services.shells.AbstractHostShell;
|
||||||
|
@ -56,6 +58,24 @@ public class SshHostShell extends AbstractHostShell implements IHostShell {
|
||||||
// ((ChannelShell)fChannel).setPty(false);
|
// ((ChannelShell)fChannel).setPty(false);
|
||||||
//}
|
//}
|
||||||
|
|
||||||
|
//Try to set the user envionment. On most sshd configurations, this will
|
||||||
|
//not work since in sshd_config, PermitUserEnvironment and AcceptEnv
|
||||||
|
//settings are disabled. Still, it's worth a try.
|
||||||
|
if (environment!=null && environment.length>0 && fChannel instanceof ChannelShell) {
|
||||||
|
Hashtable envTable=new Hashtable();
|
||||||
|
for(int i=0; i<environment.length; i++) {
|
||||||
|
String curStr=environment[i];
|
||||||
|
int curLen=environment[i].length();
|
||||||
|
int idx = curStr.indexOf('=');
|
||||||
|
if (idx>0 && idx<curLen-1) {
|
||||||
|
String key=environment[i].substring(0, idx);
|
||||||
|
String value=environment[i].substring(idx+1, curLen);
|
||||||
|
envTable.put(key, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
((ChannelShell)fChannel).setEnv(envTable);
|
||||||
|
}
|
||||||
|
|
||||||
fStdoutHandler = new SshShellOutputReader(this, new BufferedReader(new InputStreamReader(fChannel.getInputStream())), false);
|
fStdoutHandler = new SshShellOutputReader(this, new BufferedReader(new InputStreamReader(fChannel.getInputStream())), false);
|
||||||
fStderrHandler = new SshShellOutputReader(this, null,true);
|
fStderrHandler = new SshShellOutputReader(this, null,true);
|
||||||
OutputStream outputStream = fChannel.getOutputStream();
|
OutputStream outputStream = fChannel.getOutputStream();
|
||||||
|
|
Loading…
Add table
Reference in a new issue