You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mina.apache.org by gn...@apache.org on 2012/09/12 09:20:08 UTC
svn commit: r1383814 -
/mina/sshd/trunk/sshd-core/src/main/java/org/apache/sshd/client/channel/ChannelShell.java
Author: gnodet
Date: Wed Sep 12 07:20:08 2012
New Revision: 1383814
URL: http://svn.apache.org/viewvc?rev=1383814&view=rev
Log:
[SSHD-184] The client does not support sending environment variables when creating a shell channel
Modified:
mina/sshd/trunk/sshd-core/src/main/java/org/apache/sshd/client/channel/ChannelShell.java
Modified: mina/sshd/trunk/sshd-core/src/main/java/org/apache/sshd/client/channel/ChannelShell.java
URL: http://svn.apache.org/viewvc/mina/sshd/trunk/sshd-core/src/main/java/org/apache/sshd/client/channel/ChannelShell.java?rev=1383814&r1=1383813&r2=1383814&view=diff
==============================================================================
--- mina/sshd/trunk/sshd-core/src/main/java/org/apache/sshd/client/channel/ChannelShell.java (original)
+++ mina/sshd/trunk/sshd-core/src/main/java/org/apache/sshd/client/channel/ChannelShell.java Wed Sep 12 07:20:08 2012
@@ -19,6 +19,7 @@
package org.apache.sshd.client.channel;
import java.util.HashMap;
+import java.util.LinkedHashMap;
import java.util.Map;
import org.apache.sshd.common.PtyMode;
@@ -42,6 +43,7 @@ public class ChannelShell extends Channe
private int ptyWidth;
private int ptyHeight;
private Map<PtyMode, Integer> ptyModes;
+ private Map<String, String> env = new LinkedHashMap<String, String>();
public ChannelShell() {
ptyType = System.getenv("TERM");
@@ -141,6 +143,10 @@ public class ChannelShell extends Channe
this.ptyModes = ptyModes;
}
+ public void setEnv(String key, String value) {
+ env.put(key, value);
+ }
+
protected void doOpen() throws Exception {
super.doOpen();
@@ -176,11 +182,18 @@ public class ChannelShell extends Channe
session.writePacket(buffer);
}
-// log.info("Send SSH_MSG_CHANNEL_REQUEST env");
-// buffer = session.createBuffer(SshConstants.Message.SSH_MSG_CHANNEL_REQUEST);
-// buffer.putInt(recipient);
-// buffer.putString("env");
-// session.writePacket(buffer);
+ if (!env.isEmpty()) {
+ log.info("Send SSH_MSG_CHANNEL_REQUEST env");
+ for (Map.Entry<String, String> entry : env.entrySet()) {
+ buffer = session.createBuffer(SshConstants.Message.SSH_MSG_CHANNEL_REQUEST, 0);
+ buffer.putInt(recipient);
+ buffer.putString("env");
+ buffer.putBoolean(false);
+ buffer.putString(entry.getKey());
+ buffer.putString(entry.getValue());
+ session.writePacket(buffer);
+ }
+ }
log.info("Send SSH_MSG_CHANNEL_REQUEST shell");
buffer = session.createBuffer(SshConstants.Message.SSH_MSG_CHANNEL_REQUEST, 0);