QxtSshClient stucks if the SSH host does not require authentication

Issue #55 new
Tzu-ping Chung created an issue

I'm having some problems trying out QxtSshClient from tip. If the SSH server I'm connecting to doesn't require authentication, I get a "cannot open channel before connected()" warning this when I try to open a channel. Digging into qxtsshclient.cpp revealed this (in QxtSshClientPrivate::d_readyRead):

void QxtSshClientPrivate::d_readyRead(){
// ... skipped
    }else if(d_state==3){
        //3) try auth type "none" and get a list of other methods
        //   in the likely case that the server doesnt like "none"

        QByteArray username=d_userName.toLocal8Bit();
        char * alist=libssh2_userauth_list(d_session, username.data(),username.length());
        if(alist==NULL){
            if(libssh2_userauth_authenticated(d_session)){
                //null auth ok
                emit p->connected();
                d_state=5;
                return;
            }else 
// ... skipped

Unless I miss something, I think this means that if the SSH does not require authentication, we get a d_state of 2 when connected() is sent. Even if we connect with Qt::QueuedConenction, all we get is 5. Since we can't open any channels to the connection, we are stuck without any way to get into d_readyRead again.

I tried a naïve fix of simply changing

//null auth ok
emit p->connected();
d_state=5;
return;

to

//null auth ok
d_state=6;
emit p->connected();
return;

an the connection works. Not sure if it is the correct way though.

Comments (1)

  1. Log in to comment