trinity-devel@lists.pearsoncomputing.net

Message: previous - next
Month: April 2012

sftp_kio - fix ssh port number read

From: "David C. Rankin" <drankinatty@...>
Date: Tue, 24 Apr 2012 11:47:52 -0500
Tim, All,

  I've started a new thread to specifically look at the problem with sftp_kio
not obtaining the port number to open the connection for sftp without the user
manually providing it in the url. (eg: sftp://myhost:nonStdPort). This is part
of bug http://bugs.pearsoncomputing.net/show_bug.cgi?id=897

  Tim's commit of GIT hash e72f492 fixed the ability of sftp to connect to
remote hosts, but if the remote host ssh runs on a port other than 22, the
connection fails due to sftp no longer getting the correct host/port pair from
either the system-wide config /etc/ssh/ssh_config or the user's ~/.ssh/config.

  This worked correctly before the sftp bug was introduced and it continues to
work for fish://, but I cannot find where the config files are read. It appears
to be something read during ssh startup from the system-wide or user .ssh/config
file. That is hinted to in the fish/README file:

  NOTE: From version 1.1.3 on, compression is no longer turned on auto-
  matically. You have to specify it via ~/.ssh/config or wherever
  your local ssh client reads its settings. The same goes for all other
  connection parameters. OpenSSH for example has a powerful configuration
  file syntax which lets you configure access differently for each host,
  something I do not intend to duplicate. Read the ssh_config(5) man page
  for details.

  The variable in sftp associated with the port is 'mPort', but I cannot tell
where this could be set (yes, I know, just grep it, but somehow I'm getting lost
in whether this is piped or cached and read somewhere rather than just declared
and assigned) It appears to begin in ksshprocess.cpp with:

bool KSshProcess::setOptions(const SshOptList& opts) {
    kdDebug(KSSHPROC) << "KSshProcess::setOptions()" << endl;
    mArgs.clear();
    SshOptListConstIterator it;
    TQString cmd, subsystem;
    mPassword = mUsername = mHost = TQString::null;
    TQCString tmp;
    for(it = opts.begin(); it != opts.end(); ++it) {
        switch( (*it).opt ) {
<snip>
        case SSH_PORT:
            mArgs.append("-p");
            tmp.setNum((*it).num);
            mArgs.append(tmp);
            mPort = (*it).num;
            break;
<snip>

  Also, both sftp:// and fish:// make use of an AuthInfo struct that references
a port, but I cannot figure out how to tell what this contains:

kio_sftp.cpp:    // Setup AuthInfo for use with password caching and the
kio_sftp.cpp:    AuthInfo info;
kio_sftp.cpp:    info.url.setPort(mPort);

fish/fish.h:  /** AuthInfo object used for logging in */
fish/fish.h:  KIO::AuthInfo connectionAuth;

  It is frustrating because it still works fine in fish, so we should just be
able to look there and find it, but it is apparently not that easy either...

  Now regardless of how you look at it, the port information must be read from
either /etc/ssh/ssh_config or ~/.ssh/config before the ssh connection is opened
because that is the only place this information exists and it is imperative that
you have that connection before attempting to open a connection -- or the
connection will simply be refused and fail. So this is taking place in fish
somewhere and it was taking place in sftp somewhere as well -- the questions is
where??

  What say the experts?? I've grepped and looked until I'm blue in the face and
I've exhausted what I can do.


-- 
David C. Rankin, J.D.,P.E.