thebaselab / codeapp

Building a full-fledged code editor for iPad
https://code.thebaselab.com
MIT License
2.95k stars 202 forks source link

SSH connection opens root filesystem instead of directory set on remote machine #930

Closed thekeith closed 1 year ago

thekeith commented 1 year ago

Whenever an SSH connection is opened it defaults the file browser to the root directory of the filesystem for some reason. Any attempt to change this on the server side is ineffective.

bummoblizard commented 1 year ago

What should be the expected behaviour? How did you configure the default directory on your server?

thekeith commented 1 year ago
bummoblizard commented 1 year ago

This is indeed a bug. Code App is ignoring the remote working directory.

https://github.com/thebaselab/codeapp/blob/b5508054a8f2b70a93997bbc6a3afc71b7c39fb9/CodeApp/Managers/FileSystem/SFTP/SFTPFileSystemProvider.swift#L104-L105 Fix: In SFTPFileSystemProvider.swift, we should call libssh2'slibssh2_sftp_realpath with . as the argument to obtain the working directory and assign it to self.homePath.

bummoblizard commented 1 year ago

The changes I made in NMSSH: https://github.com/thebaselab/NMSSH/commit/2d800fca5d2da49baff1cbc061b275e33df70731

bummoblizard commented 1 year ago

This should work universally on different platforms as it is how the FreeBSD sftp command pwd works: https://github.com/freebsd/freebsd-src/blob/6b635c74fd4135eaae68970bfc5aad9ae905fec7/crypto/openssh/sftp.c#L2237

thekeith commented 1 year ago

Did the changes make it to 1.4.7 or is it still to be released?

bummoblizard commented 1 year ago

Did the changes make it to 1.4.7 or is it still to be released?

It should be available on TestFlight later today.

thekeith commented 1 year ago

Resolved in latest build. Thanks!

bummoblizard commented 1 year ago

Because of #943, resolving home path is now an configurable option and is off by default.