Skip to content

Commit

Permalink
Merge branch 'sessions' of https://github.com/tpoliaw/jline3 into tpo…
Browse files Browse the repository at this point in the history
…liaw-sessions
  • Loading branch information
gnodet committed May 6, 2019
2 parents afe59b2 + 860c0d6 commit c37db13
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public void start(final Environment env) throws IOException {
private void run() {
int exitStatus = 0;
try {
execute.accept(new Ssh.ExecuteParams(command, env.getEnv(), in, out, err));
execute.accept(new Ssh.ExecuteParams(command, env.getEnv(), session, in, out, err));
} catch (RuntimeException e) {
exitStatus = 1;
LOGGER.log(Level.SEVERE, "Unable to start shell", e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ public void run(Environment env) throws Exception {
terminal.raise(Terminal.Signal.WINCH);
}, Signal.WINCH);

shell.accept(new Ssh.ShellParams(env.getEnv(), terminal, this::destroy));
shell.accept(new Ssh.ShellParams(env.getEnv(), session, terminal, this::destroy));
} catch (Throwable t) {
t.printStackTrace();
}
Expand Down
15 changes: 13 additions & 2 deletions remote-ssh/src/main/java/org/jline/builtins/ssh/Ssh.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.apache.sshd.server.SshServer;
import org.apache.sshd.server.keyprovider.SimpleGeneratorHostKeyProvider;
import org.apache.sshd.server.scp.ScpCommandFactory;
import org.apache.sshd.server.session.ServerSession;
import org.apache.sshd.server.subsystem.sftp.SftpSubsystemFactory;
import org.jline.builtins.Options;
import org.jline.builtins.Options.HelpException;
Expand All @@ -43,14 +44,19 @@ public static class ShellParams {
private final Map<String, String> env;
private final Terminal terminal;
private final Runnable closer;
public ShellParams(Map<String, String> env, Terminal terminal, Runnable closer) {
private final ServerSession session;
public ShellParams(Map<String, String> env, ServerSession session, Terminal terminal, Runnable closer) {
this.env = env;
this.session = session;
this.terminal = terminal;
this.closer = closer;
}
public Map<String, String> getEnv() {
return env;
}
public ServerSession getSession() {
return session;
}
public Terminal getTerminal() {
return terminal;
}
Expand All @@ -62,11 +68,13 @@ public Runnable getCloser() {
public static class ExecuteParams {
private final String command;
private final Map<String, String> env;
private final ServerSession session;
private final InputStream in;
private final OutputStream out;
private final OutputStream err;
public ExecuteParams(String command, Map<String, String> env, InputStream in, OutputStream out, OutputStream err) {
public ExecuteParams(String command, Map<String, String> env, ServerSession session, InputStream in, OutputStream out, OutputStream err) {
this.command = command;
this.session = session;
this.env = env;
this.in = in;
this.out = out;
Expand All @@ -78,6 +86,9 @@ public String getCommand() {
public Map<String, String> getEnv() {
return env;
}
public ServerSession getSession() {
return session;
}
public InputStream getIn() {
return in;
}
Expand Down

0 comments on commit c37db13

Please sign in to comment.