Menu

#1816 SFTP fails with non-UNIX-like servers

open
nobody
FTP (16)
5
2015-04-10
2015-04-10
dbanet
No

jEdit 5.1, FTP 1.1.

I'm running an SFTP server that represents an old good DOS-like file structure, i.e. the one with drive letters. So it works pretty much like DOS.

An example of how does it work in console:

# sftp user@example.com
user@example.com's password:
sftp> pwd
Remote working directory: Z:/
sftp> cd test
sftp> pwd
Remote working directory: Z:/test
sftp> cd C:
sftp> pwd
Remote working directory: C:/
sftp>

This server doesn't have one / root containing all these drive letters, so cd'ing to / will just give you the root of the current drive. Trying to cd to a non-existing drive will cause a "Couldn't stat remote file: Failure".

The (S)FTP plugin fails to work with it.

Attempting to connect causes java.lang.IllegalArgumentException: Invalid connection port: '' at ftp.FtpAddress.<init> etc.

I've investigated this error a bit and found that the ftp.FtpAddress class, which, it seems, should parse an ftp/sftp URI, gets an URI string like the following: sftp://user:password@example.com:22Z:/user/home/dir. So this could be fixed with a simple check if the initial working directory (path) begins with /, and if it doesn't, just prepend / to it.

I have worked that around by entering example.com:22/ into the "Remote host" field upon connection instead of the direct example.com.

It has managed to connect, but the current URI was sftp://user@example.com:22/:22/~/, and the file list was blank. It appears that the plugin is written in assumption that you can cd to ~ on every server. That is not true. By the way, note the double :22/:22. I don't know where did it came from.

Then I've erased the last :22/~/ in the "Path" field, so that the final URI was sftp://user@example.com:22/, and pressed enter.

Yahoo! It displayed the remote contents and I was able to work with it further with no apparent problem, besides the fact that I'm unable to switch to another drive.

But then I've discovered another trouble. If I login with a user whose default working directory is not the root of the drive, and it is forbidden to cd to /, then the plugin renders itself completely useless. I was unable to make it display the remote content no matter what I do.

I think some parts of the plugin should be fixed with the assumption that the root directory doesn't always start with a /, and can actually start with any character.

Also it would be good to have the plugin scan for [A: ... Z:] roots, displaying all them under the virtual / root directory, or whatever, just like jEdit on Windows represents the drive letters under the common "roots:" root directory.

By the way, all the above also belongs to the plain FTP, not SFTP only, as I also have (and use) an FTP server which behaves the very same.

Thank you. Hope to see it fixed.

Discussion


Log in to post a comment.