130 lines
5.6 KiB
Diff
130 lines
5.6 KiB
Diff
|
--- remote-ssh/src/main/java/org/jline/builtins/ssh/ShellCommand.java.orig 2020-12-11 02:25:01.000000000 -0700
|
||
|
+++ remote-ssh/src/main/java/org/jline/builtins/ssh/ShellCommand.java 2020-12-13 21:00:45.364500609 -0700
|
||
|
@@ -18,6 +18,7 @@ import java.util.logging.Logger;
|
||
|
import org.apache.sshd.server.Environment;
|
||
|
import org.apache.sshd.server.ExitCallback;
|
||
|
import org.apache.sshd.server.SessionAware;
|
||
|
+import org.apache.sshd.server.channel.ChannelSession;
|
||
|
import org.apache.sshd.server.command.Command;
|
||
|
import org.apache.sshd.server.session.ServerSession;
|
||
|
|
||
|
@@ -59,7 +60,7 @@ public class ShellCommand implements Com
|
||
|
this.session = session;
|
||
|
}
|
||
|
|
||
|
- public void start(final Environment env) throws IOException {
|
||
|
+ public void start(ChannelSession channel, final Environment env) throws IOException {
|
||
|
this.env = env;
|
||
|
new Thread(this::run).start();
|
||
|
}
|
||
|
@@ -84,7 +85,7 @@ public class ShellCommand implements Com
|
||
|
}
|
||
|
}
|
||
|
|
||
|
- public void destroy() {
|
||
|
+ public void destroy(ChannelSession session) {
|
||
|
}
|
||
|
|
||
|
}
|
||
|
--- remote-ssh/src/main/java/org/jline/builtins/ssh/ShellFactoryImpl.java.orig 2020-12-11 02:25:01.000000000 -0700
|
||
|
+++ remote-ssh/src/main/java/org/jline/builtins/ssh/ShellFactoryImpl.java 2020-12-13 21:00:45.365500608 -0700
|
||
|
@@ -15,14 +15,15 @@ import java.io.OutputStream;
|
||
|
import java.util.Map;
|
||
|
import java.util.function.Consumer;
|
||
|
|
||
|
-import org.apache.sshd.common.Factory;
|
||
|
import org.apache.sshd.common.channel.PtyMode;
|
||
|
import org.apache.sshd.server.Environment;
|
||
|
import org.apache.sshd.server.ExitCallback;
|
||
|
import org.apache.sshd.server.SessionAware;
|
||
|
import org.apache.sshd.server.Signal;
|
||
|
+import org.apache.sshd.server.channel.ChannelSession;
|
||
|
import org.apache.sshd.server.command.Command;
|
||
|
import org.apache.sshd.server.session.ServerSession;
|
||
|
+import org.apache.sshd.server.shell.ShellFactory;
|
||
|
import org.jline.terminal.Attributes;
|
||
|
import org.jline.terminal.Attributes.ControlChar;
|
||
|
import org.jline.terminal.Attributes.InputFlag;
|
||
|
@@ -36,7 +37,7 @@ import org.jline.terminal.TerminalBuilde
|
||
|
* SSHD {@link org.apache.sshd.server.command.Command} factory which provides access to
|
||
|
* Shell.
|
||
|
*/
|
||
|
-public class ShellFactoryImpl implements Factory<Command> {
|
||
|
+public class ShellFactoryImpl implements ShellFactory {
|
||
|
private final Consumer<Ssh.ShellParams> shell;
|
||
|
|
||
|
public ShellFactoryImpl(Consumer<Ssh.ShellParams> shell) {
|
||
|
@@ -63,7 +64,7 @@ public class ShellFactoryImpl implements
|
||
|
}
|
||
|
}
|
||
|
|
||
|
- public Command create() {
|
||
|
+ public Command createShell(ChannelSession channel) throws IOException {
|
||
|
return new ShellImpl();
|
||
|
}
|
||
|
|
||
|
@@ -100,7 +101,7 @@ public class ShellFactoryImpl implements
|
||
|
this.session = session;
|
||
|
}
|
||
|
|
||
|
- public void start(final Environment env) throws IOException {
|
||
|
+ public void start(ChannelSession channel, final Environment env) throws IOException {
|
||
|
try {
|
||
|
new Thread(() -> {
|
||
|
try {
|
||
|
@@ -216,7 +217,7 @@ public class ShellFactoryImpl implements
|
||
|
}
|
||
|
}
|
||
|
terminal.setAttributes(attr);
|
||
|
- env.addSignalListener(signals -> {
|
||
|
+ env.addSignalListener((channel, signal) -> {
|
||
|
terminal.setSize(new Size(Integer.parseInt(env.getEnv().get("COLUMNS")),
|
||
|
Integer.parseInt(env.getEnv().get("LINES"))));
|
||
|
terminal.raise(Terminal.Signal.WINCH);
|
||
|
@@ -229,6 +230,10 @@ public class ShellFactoryImpl implements
|
||
|
}
|
||
|
|
||
|
public void destroy() {
|
||
|
+ this.destroy(null);
|
||
|
+ }
|
||
|
+
|
||
|
+ public void destroy(ChannelSession session) {
|
||
|
if (!closed) {
|
||
|
closed = true;
|
||
|
flush(out, err);
|
||
|
--- remote-ssh/src/main/java/org/jline/builtins/ssh/Ssh.java.orig 2020-12-11 02:25:01.000000000 -0700
|
||
|
+++ remote-ssh/src/main/java/org/jline/builtins/ssh/Ssh.java 2020-12-13 21:00:45.366500608 -0700
|
||
|
@@ -20,8 +20,10 @@ import org.apache.sshd.client.channel.Cl
|
||
|
import org.apache.sshd.client.channel.ClientChannelEvent;
|
||
|
import org.apache.sshd.client.future.ConnectFuture;
|
||
|
import org.apache.sshd.client.session.ClientSession;
|
||
|
+import org.apache.sshd.common.NamedResource;
|
||
|
import org.apache.sshd.common.channel.PtyMode;
|
||
|
import org.apache.sshd.common.config.keys.FilePasswordProvider;
|
||
|
+import org.apache.sshd.common.session.SessionContext;
|
||
|
import org.apache.sshd.common.util.io.NoCloseInputStream;
|
||
|
import org.apache.sshd.common.util.io.NoCloseOutputStream;
|
||
|
import org.apache.sshd.server.SshServer;
|
||
|
@@ -362,7 +364,7 @@ public class Ssh {
|
||
|
server.setHost(ip);
|
||
|
server.setShellFactory(new ShellFactoryImpl(shell));
|
||
|
server.setCommandFactory(new ScpCommandFactory.Builder()
|
||
|
- .withDelegate(command -> new ShellCommand(execute, command)).build());
|
||
|
+ .withDelegate((channel, command) -> new ShellCommand(execute, command)).build());
|
||
|
server.setSubsystemFactories(Collections.singletonList(
|
||
|
new SftpSubsystemFactory.Builder().build()
|
||
|
));
|
||
|
@@ -390,8 +392,10 @@ public class Ssh {
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
- public String getPassword(String resourceKey) throws IOException {
|
||
|
- return readLine("Enter password for " + resourceKey + ":", false);
|
||
|
+ public String getPassword(SessionContext session, NamedResource resourceKey, int retryIndex) throws IOException {
|
||
|
+ if (retryIndex == 0)
|
||
|
+ return readLine("Enter password for " + resourceKey.getName() + ":", false);
|
||
|
+ return readLine("Enter password again for " + resourceKey.getName() + ":", false);
|
||
|
}
|
||
|
|
||
|
@Override
|