mina-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kyle Miller <k...@kylemiller.com>
Subject Re: [sshd] ChannelSession NPE with a subsystem command, trying to implement sftp
Date Tue, 17 Nov 2009 18:15:31 GMT
I applied that patch and I was able to login and do a ls.  Thanks for the
quick turn around.

On Fri, Nov 13, 2009 at 11:06 AM, Guillaume Nodet <gnodet@gmail.com> wrote:

> I've also worked on a *very basic* and initial support for SFTP if you
> want to have a look at it.
>      https://issues.apache.org/jira/browse/SSHD-55
>
>
> On Thu, Nov 12, 2009 at 08:42, Guillaume Nodet <gnodet@gmail.com> wrote:
> > Subsystems are not really supported yet.
> > The error you see is already reported at
> > https://issues.apache.org/jira/browse/SSHD-48 I think.
> > I'll fix it asap.
> >
> > On Wed, Nov 11, 2009 at 15:57, Kyle Miller <kyle@kylemiller.com> wrote:
> >> I am using mina sshd version 0.2.0.
> >>
> >> I created a simple main, and sftp command factory and command and tried
> to
> >> connect to my daemon with my OS X command line sftp client, and a few
> other
> >> graphical clients and it all ends the same way.  With a NPE in the
> >> ChannelSession.doWriteData line 260.  After debugging through the code
> the
> >> SFTP commands come in with a subsystem type, when that happens the
> shellIn
> >> and shellOut streams in ChannelSession remain null hence the NPE.  I
> have
> >> included the stack trace as well as my classes to demonstrate the issue.
> >>
> >> 2009-11-11 08:50:45,710 [NioProcessor-2] WARN
> >> org.apache.sshd.server.session.ServerSession - Exception caught
> >> java.lang.NullPointerException
> >>    at
> >>
> org.apache.sshd.server.channel.ChannelSession.doWriteData(ChannelSession.java:260)
> >>    at
> >>
> org.apache.sshd.common.channel.AbstractChannel.handleData(AbstractChannel.java:116)
> >>    at
> >>
> org.apache.sshd.common.session.AbstractSession.channelData(AbstractSession.java:863)
> >>    at
> >>
> org.apache.sshd.server.session.ServerSession.handleMessage(ServerSession.java:195)
> >>    at
> >>
> org.apache.sshd.common.session.AbstractSession.decode(AbstractSession.java:490)
> >>    at
> >>
> org.apache.sshd.common.session.AbstractSession.messageReceived(AbstractSession.java:214)
> >>    at
> >>
> org.apache.sshd.common.AbstractSessionIoHandler.messageReceived(AbstractSessionIoHandler.java:58)
> >>    at
> >>
> org.apache.mina.core.filterchain.DefaultIoFilterChain$TailFilter.messageReceived(DefaultIoFilterChain.java:721)
> >>    at
> >>
> org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextMessageReceived(DefaultIoFilterChain.java:433)
> >>    at
> >>
> org.apache.mina.core.filterchain.DefaultIoFilterChain.access$1200(DefaultIoFilterChain.java:47)
> >>    at
> >>
> org.apache.mina.core.filterchain.DefaultIoFilterChain$EntryImpl$1.messageReceived(DefaultIoFilterChain.java:801)
> >>    at
> >>
> org.apache.mina.core.filterchain.IoFilterAdapter.messageReceived(IoFilterAdapter.java:119)
> >>    at
> >>
> org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextMessageReceived(DefaultIoFilterChain.java:433)
> >>    at
> >>
> org.apache.mina.core.filterchain.DefaultIoFilterChain.fireMessageReceived(DefaultIoFilterChain.java:425)
> >>    at
> >>
> org.apache.mina.core.polling.AbstractPollingIoProcessor.read(AbstractPollingIoProcessor.java:603)
> >>    at
> >>
> org.apache.mina.core.polling.AbstractPollingIoProcessor.process(AbstractPollingIoProcessor.java:563)
> >>    at
> >>
> org.apache.mina.core.polling.AbstractPollingIoProcessor.process(AbstractPollingIoProcessor.java:552)
> >>    at
> >>
> org.apache.mina.core.polling.AbstractPollingIoProcessor.access$400(AbstractPollingIoProcessor.java:56)
> >>    at
> >>
> org.apache.mina.core.polling.AbstractPollingIoProcessor$Processor.run(AbstractPollingIoProcessor.java:891)
> >>    at
> >>
> org.apache.mina.util.NamePreservingRunnable.run(NamePreservingRunnable.java:64)
> >>    at
> >>
> java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
> >>    at
> >>
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
> >>    at java.lang.Thread.run(Thread.java:637)
> >>
> >>
> >> ====================================================
> >>
> >> import org.apache.sshd.SshServer;
> >> import
> org.apache.sshd.server.keyprovider.SimpleGeneratorHostKeyProvider;
> >> import org.apache.sshd.util.BogusPasswordAuthenticator;
> >> import org.apache.sshd.util.EchoShellFactory;
> >>
> >> public class Sftpd {
> >>
> >>    public static void main(String[] args) throws IOException {
> >>
> >>        SshServer sshd = SshServer.setUpDefaultServer();
> >>        sshd.setKeyPairProvider(new
> >> SimpleGeneratorHostKeyProvider("hostkey.ser"));
> >>        sshd.setPasswordAuthenticator(new BogusPasswordAuthenticator());
> >>        sshd.setShellFactory(new EchoShellFactory());
> >> //        sshd.setShellFactory(new ProcessShellFactory(new String[] {
> >> "/bin/sh", "-i", "-l" }));
> >>        sshd.setPort(2222);
> >>        sshd.setCommandFactory(new SftpCommandFactory());
> >>        sshd.start();
> >>
> >>    }
> >>
> >> }
> >>
> >>
> >> ======================================================
> >> import org.apache.sshd.server.CommandFactory;
> >> import org.apache.sshd.server.command.UnknownCommand;
> >> import org.slf4j.Logger;
> >> import org.slf4j.LoggerFactory;
> >>
> >>
> >> public class SftpCommandFactory implements CommandFactory {
> >>    private final Logger log =
> >> LoggerFactory.getLogger(SftpCommandFactory.class);
> >>
> >>    public Command createCommand(String command) {
> >>        log.info("SFtP: "+command);
> >>        String[] args = command.split(" ");
> >>
> >>
> >>        if (args.length > 0 && "sftp".equals(args[0])) return new
> >> SftpCommand(args);
> >>
> >>        return new UnknownCommand(command);
> >>    }
> >>
> >> }
> >>
> >> ==============================================================
> >>
> >> import java.io.IOException;
> >> import java.io.InputStream;
> >> import java.io.OutputStream;
> >>
> >> import org.apache.sshd.server.CommandFactory;
> >> import org.apache.sshd.server.CommandFactory.ExitCallback;
> >> import org.slf4j.Logger;
> >> import org.slf4j.LoggerFactory;
> >>
> >>
> >> public class SftpCommand implements CommandFactory.Command, Runnable {
> >>    private final Logger log =
> LoggerFactory.getLogger(SftpCommand.class);
> >>    private OutputStream err;
> >>    private ExitCallback callBack;
> >>    private InputStream in;
> >>    private OutputStream out;
> >>    private IOException error;
> >>
> >>    public SftpCommand(String[] args) {
> >>        log.info("sftp args: "+args);
> >>    }
> >>
> >>    public void setErrorStream(OutputStream err) {
> >>
> >>    }
> >>
> >>    public void setExitCallback(ExitCallback callback) {
> >>
> >>    }
> >>
> >>    public void setInputStream(InputStream in) {
> >>
> >>    }
> >>
> >>    public void setOutputStream(OutputStream out) {
> >>
> >>    }
> >>
> >>    public void start() throws IOException {
> >>       if (error != null) {
> >>            throw error;
> >>        }
> >>        new Thread(this).start();
> >>    }
> >>
> >>    public void run() {
> >>        callBack.onExit(0);
> >>    }
> >> }
> >>
> >
> >
> >
> > --
> > Cheers,
> > Guillaume Nodet
> > ------------------------
> > Blog: http://gnodet.blogspot.com/
> > ------------------------
> > Open Source SOA
> > http://fusesource.com
> >
>
>
>
> --
> Cheers,
> Guillaume Nodet
> ------------------------
> Blog: http://gnodet.blogspot.com/
> ------------------------
> Open Source SOA
> http://fusesource.com
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message