By default, Bugzilla does not search the list of RESOLVED bugs.
You can force it to do so by putting the upper-case word ALL in front of your search query, e.g.: ALL tdelibs
We recommend searching for bugs this way, as you may discover that your bug has already been resolved and fixed in a later release.
Bug 897 - sftp kioslave fails to parse urls in konqueror address bar
Summary: sftp kioslave fails to parse urls in konqueror address bar
Status: RESOLVED FIXED
Alias: None
Product: TDE
Classification: Unclassified
Component: tdebase (show other bugs)
Version: 3.5.13 [Trinity]
Hardware: i386 Other
: P5 blocker
Assignee: Timothy Pearson
URL:
Depends on:
Blocks:
 
Reported: 2012-03-05 22:24 CST by David C. Rankin
Modified: 2012-10-19 15:51 CDT (History)
4 users (show)

See Also:
Compiler Version:
TDE Version String:
Application Version:
Application Name:


Attachments
Final patch applied by Tim fixing sftp_kio.cpp (540 bytes, patch)
2012-04-25 11:05 CDT, David C. Rankin
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description David C. Rankin 2012-03-05 22:24:18 CST
sftp kioslave should accept sftp addresses in the konqueror filemanager address bar in the following form:

sftp://user@host.domain.tld:port/dir1/dir2

  This problem begin approximately September 2010 with openssh >= 5.6 IIRC. Currently attempts to use sftp in konqueror in TDE, results in the error:

Unknown error
 Error encountered while talking to ssh.

  In the past, simple forms on port 22 would continue to work. Currently, I can't get any sftp form to work. 

  However, I can open konqueror and use:

sftp -Pport user@host.domain.tld

and connect fine. This leads me to believe that sftp is working, but the problem is with the address parsing of the entry in the konqueror address bar.

  However, I can still use fish:// in the konqueror address bar without any problems in TDE GIT.

  This issue also seems to be connected to the entries in /etc/hosts and whether the generic entry is used:

127.0.0.1 localhost.localdomain localhost

or whether and actual entry is used.

127.0.0.1 somerealhost.somerealdomain localhost somrealhost

  This behavior needs fixing as well. (it will probably sort itself out when the kioslave is fixed)

  Also, I haven't found any logs that would be of any use. Wireshark captures are useless due to encryption, so it will take somebody who knows how to look at the interprocess communications to find out exactly where sftp is failing.

  If you can think of any tests to run, let me know and I'm happy to run them.

  The plan as of 3/11 was a complete rewrite of the kioslave for sftp. I don't know what was done from that point forward.
Comment 1 Nikolaus Klepp 2012-03-10 14:21:10 CST
sftp://localhost/ worked on TDE 3.5.12, but is broken on my TDE 3.5.13 on wheezy.
Comment 2 David Hare 2012-03-10 19:41:00 CST
Squeeze with 3.5.13 on more than one machine. SFTP works fine here in konqueror over LAN using sftp://username@url:port_number (url is, e.g., 192.168.0.5)

In /etc/hosts:

127.0.0.1 localhost
127.0.0.1 my_hostname

On a fresh Squeeze install it was necessary to do, before incoming connections were accepted: 

ssh-keygen -t dsa -f /etc/ssh/ssh_host_dsa_key
ssh-keygen -t rsa -f /etc/ssh/ssh_host_dsa_key
/etc/init.d/ssh restart

Keys were generated  without passphrase.
Comment 3 Nikolaus Klepp 2012-03-11 09:30:24 CDT
Not on my debian wheezy. 

I started wireshark to monitor lo, then I started "konqeror sftp://127.0.0.1/". wireshark did not pick any packages. I ran that test several times with different target hosts. It's always the same result: the sftp kioslave does not send any packages.
Comment 4 David C. Rankin 2012-04-20 20:02:01 CDT
This is still broken in current R14. I have captured a log that might help with debug:

http://www.3111skyline.com/dl/dt/tde/err/sftp-kio/sftp-output.txt
Comment 5 David C. Rankin 2012-04-21 08:21:11 CDT
This is still broken in current R14. I have captured a log that might help with debug:

http://www.3111skyline.com/dl/dt/tde/err/sftp-kio/sftp-output.txt
Comment 6 Timothy Pearson 2012-04-23 02:42:47 CDT
This bug should be fixed in GIT hash e72f492.

Please test and report back with your results!
Comment 7 David C. Rankin 2012-04-24 09:51:07 CDT
Tim,

  Here is the latest information on isolating the reason the port information is not returned to the kioslave when talking to ssh (requiring manual entry of non-standard port in 'sftp://myhost:nonStdPort'. This is a quick recap to document the issue. The problem appears to be in kio_sftp.cpp:

    if( port > 0 )
        mPort = port;
    else {
        struct servent *pse;
        if( (pse = getservbyname("ssh", "tcp") ) == NULL )
            mPort = 22;
        else
            mPort = ntohs(pse->s_port);
    }

  Lukas Fisher (the author) originally implemented getservbyname to obtain the port in Feb. 2002 (see CHANGELOG):

2-19-2002
  - get() now emits mimetype, fixes problem with konqi not downloading file for viewing in kpart.
  - get port number using getservbyname instead of hard coding it.

  Apparently the change in ssh output that deleted a line of output has broken this part of the code. I think by simply fixing how getservbyname reads the output and telling it to read line '5' instead of line '6' now would probably fix this problem. I think this also explains why the problem you found with select() getting stuck occurs. Here are examples of the ssh output between openssh 5.0 and openssh 5.9. Note that line '5' from the 5.0 output has been deleted from ssh output in 5.9. So if the getservbyname is looking for IP and port in line '6' of the output, it will never find it because that information was already read and discarded in line '5':

===== OpenSSH_5.0p1 =====

08:10 nemesis:~> ssh -v -p 6662 archangel.3111skyline.com
OpenSSH_5.0p1, OpenSSL 0.9.8g 19 Oct 2007
debug1: Reading configuration data /home/david/.ssh/config
debug1: Applying options for archangel.3111skyline.com
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug1: Connecting to archangel.3111skyline.com [192.168.6.14] port 6662.
debug1: Connection established.
<snip>

===== OpenSSH_5.9p1 =====

21:02 archangel:/dat_e> ssh -v nirvana
OpenSSH_5.9p1, OpenSSL 1.0.1 14 Mar 2012
debug1: Reading configuration data /home/david/.ssh/config
debug1: /home/david/.ssh/config line 26: Applying options for nirvana
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Connecting to nirvana [192.168.6.17] port 6660.
debug1: Connection established.
<snip>

  So rather than nuking the code with getservbyname, I think fixing it will solve the problem as it was originally implemented by Fisher to do exactly what we need it to do now.
Comment 8 David C. Rankin 2012-04-24 09:56:57 CDT
Tim,

  Scrap that. The getservbyname is just a lookup for the port from /etc/services. It will never get the port information from ~/.ssh/config that is needed. That must be done in some other part of the kioslave.
Comment 9 David C. Rankin 2012-04-24 13:48:59 CDT
  We have been thinking about this thing 'bass-ackwards'. All sftp has to do is read what 'ssh' spits out upon connection. You don't care about reading any config files prior to calling 'ssh', 'ssh' takes care of that for you automagically!

  Think about it:

13:43 providence:~/tde/tmp/patch/tdebase/kioslave/sftp> ssh -v phoenix
OpenSSH_5.9p1, OpenSSL 1.0.1a 19 Apr 2012
debug1: Reading configuration data /home/david/.ssh/config
debug1: /home/david/.ssh/config line 36: Applying options for phoenix
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 20: Applying options for *
debug1: Connecting to phoenix [192.168.7.15] port 6630.
debug1: Connection established.

  When ssh is called, it reads BOTH /etc/ssh/ssh_config and ~/.ssh/config and acts accordingly. This means the only reason sftp://hostname fails when ssh is on a non-standard port is that the sftp:// code is NOT interpreting the ssh response correctly and is erroneously closing a perfectly good connection that ssh has established. Basically -- the sftp code just gets stuck waiting on some response that has changed in the new openssh -- doesn't know what to do with the response it gets -- and just sits there until it times out with an error.

  You will have to be the wizard that figures out where this happens, but is suspect it is in ksshprocess with the version tables that are set up at the top of the file :)
Comment 10 David C. Rankin 2012-04-24 14:27:48 CDT
I think the issue will be in ksshprocess.h

class KSshProcess {
...
    enum SshError {
    ...
      There will be no error that is recognized
    ...
    /**
     * Get the ssh version.
     *
     * @return  The ssh version or -1 if KSshProcess does not recognize
     *          the ssh version. The returned value corresponds to the
     *          member of the SshVersion enum.
     */
    SshVersion version();
    ...
      Possible error here, but it does connect on std port 22
      so the issue must be in reading the return string on non-standard
      port only.
    ...
    /**
     * Whether a ssh connection has been  established with a
     * remote host.  A establish connection means ssh has successfully
     * authenticated with the remote host and user data can be transfered
     * between the local and remote host.  This cannot return
     * true unless the most recent call to KSshProccess::connect() returned true.
     *
     * @return True if a ssh connection has been established with a remote
     *         host. False otherwise.
     */
    bool connected() { return mConnected; }
    ...
      This looks like a likely spot where sftp is getting hung up. It
      just doesn't know it is connected for some reason.
    ...
    /**
     * Whether a ssh process is currently running.  This  only indicates
     * if a ssh process has been started and is still running.  It does not
     * tell if authentication has been successful.  This may return true
     * even if the most recent call to KSshProcess::connect() returned false.
     *
     * @return True if a ssh process started by this instance of KSshProcess
     *         is running. False otherwise.
     */
    bool running() { return mRunning; }
    ...
      Like bool connected() above, this may be where sftp is just
      confused based on the ssh response.
    ...
    bool connect();
    ...
      Same potential confusion here
    ...

  I don't know if this will help, but I thought it might at least give you a starting place to look at. We're counting on the White Wizard...
Comment 11 David C. Rankin 2012-04-24 15:04:41 CDT
kio_sftp.cpp beginning line 607:

    // Start the ssh connection process.
    //

    int err;           // error code from KSshProcess
    TQString msg;       // msg for dialog box
    TQString caption;   // dialog box caption
    bool firstTime = true;
    bool dlgResult;

I think it skips this entire while loop because it is connected...

    while( !(mConnected = ssh.connect()) ) {
        err = ssh.error();
        kdDebug(KIO_SFTP_DB) << "openConnection(): "
            "Got " << err << " from KSshProcess::connect()" << endl;

        switch(err) {
... stuff
        default:
            infoMessage(i18n("Connection failed."));
            caption = i18n("Unexpected SFTP error: %1").arg(err);
            msg = ssh.errorMsg();
            messageBox(Information, msg, caption);
            closeConnection();
            error(ERR_UNKNOWN, msg);
            return;
        }

Then gets stuck waiting for 's >> type;' or something like that.. Because if it was executing the while loop you should at least get the default: dialog -- but that doesn't happen. IIRC, it just sits there until a timeout occurs when the remote host is on a non-standard ssh port.
Comment 12 David C. Rankin 2012-04-25 11:05:41 CDT
Created attachment 558 [details]
Final patch applied by Tim fixing sftp_kio.cpp

This patch was uploaded to preserve its availability to other projects that use the kde3 kioslave/sftp code. It has already been applied in Trinity.