x0b / rcx

Rclone for Android
https://x0b.github.io
GNU General Public License v3.0
1.69k stars 149 forks source link

SFTP (root) - All actions fail #167

Open 43qcc2cn opened 3 years ago

43qcc2cn commented 3 years ago

What version of RCX are you using (About -> App version)?

1.12.2 (from F-Droid)

What is your Android version, phone model and manufacturer?

Android 10 (Stock), Moto G8 Plus Android 10 (LineageOS), Samsung Galaxy Tab S2

Which steps are required to reproduce this issue?

  1. Open a remote (OpenSSH server running on Fedora 34)
  2. Select "root"
  3. Select "Download" on a file
  4. Download fails
  1. Open a remote (OpenSSH server running on Fedora 34)
  2. Select "root"
  3. Select "Rename" on a file
  4. Rename fails 
  1. Open a remote (OpenSSH server running on Fedora 34)
  2. Select "root"
  3. Select "Upload" on a folder
  4. Uploads states it has worked, but the file has not been uploaded

What is your configuration (rclone.conf)?

[server]
type = sftp
host = {Host}
user = {User}
port = 22
pass = {Encrypted Password}
md5sum_command = md5sum
sha1sum_command = sha1sum

Does the same issue also occur when using the same configuration on a PC or in Termux?

No. All other SFTP clients authenticating as the same user, including rclone on Linux, work OK.

Also, if I choose "home" instead of "root", everything is OK.

What are the contents of Android/data/io.github.x0b.rcx/files/logs/log.txt?

Android/data/io.github.x0b.rcx/files/ is empty after enabling logging.

x0b commented 3 years ago

Your access to home but not to root indicates that this is a permissions issue. If you want to write to the root directory via SFTP, your permissions need to be setup in a way that allows this.

The home (~) vs root (/) refers to the starting directory as documented on rclone.org. In rclone syntax, this is the difference between rclone copy file server:file (home) and rclone copy file server:/file (root).

43qcc2cn commented 3 years ago

Thanks for the response.

All actions fail when using root, this includes downloading a file (which I assume only requires read access).

All other ssh / sftp clients work OK when authenticating using the same credentials. This includes rclone on the same client device installed in termux.

What's also odd is that access to a file under home works OK, but access to exactly the same file via root fails.

I've just tested the same thing connecting to an installation of LibreELEC and authenticating as root. The same thing happens, all access to home is OK, all access to the same files via root fail.

x0b commented 3 years ago

Sorry, I could have explained this more clearly. The point I'm trying to make is that the rclone authors have made this intentional and documented behaviour.

Note: despite my role as maintainer of RCX, I'm not that knowledgeable about the inner workings of each remote. If you have more questions about this, the people over at https://forum.rclone.org/ are probably better equipped to help you.

43qcc2cn commented 3 years ago

Yeah. I am aware of how the fully qualified, and relative, directories are constructed.

Just in case I haven't been making myself clear.

Let's say I have the following file on the remote: /home/user/file.txt

The following all work in termux: scp user@remote:file.txt . scp user@remote:/home/user/file.txt . rclone copy remote:file.txt . rclone copy remote:/home/user/file.txt .

The following works in RCX:

  1. Open a remote
  2. Select "home"
  3. Select "Download" on file.txt

The following fails in RCX:

  1. Open a remote
  2. Select "root"
  3. Navigate to home - user
  4. Select "Download" on file.txt

I've enabled debug logging on the ssh server and compared the output when using RCX with home (works) and then root (fails), and the output is identical.

I also ran logcat on the client and compared the output when using RCX with home (works) and then root (fails), and I couldn't see any difference.

All very odd.

I will raise this in the forums as suggested, I'm just wary that the only client that exhibits the problem is RCX.

Thanks anyway.

x0b commented 3 years ago

I mean, there certainly is the possibility of an an error in RCX. While very rare, we have already discovered bugs in the compiler toolchain or go itself in the past. It is also possible that RCX is somehow messing up the local path or the local path is not writeable.

FYI: To my knowledge, SCP is not supported in rclone/RCX.

I'm sending you to the forum because I could not find any issues in my testing against a dockerized sftp server. Tag me in the forum thread @x0b to keep me in the loop.

Another thing that you could test is rclone in Termux. You can install rclone there with pkg install rclone. Then, export your config file from RCX and import it into Termux. There test the two scenarios and report back:

  1. rclone -vvv --log-file=rclone-home.log copyto server:file.txt ./file-home
  2. rclone -vvv --log-file=rclone-root.log copyto server:/home/user/file.txt ./file-root

Check which files where copied successfully and also send in the two log files.

43qcc2cn commented 3 years ago

Thanks. Just to confirm, it is scp and rclone that are already working successfully in Termux on the same devices that I'm now testing RCX.

I'll test against the same dockerized sftp server and if that also fails I'll raise it in the rclone forum (will tag you in).

43qcc2cn commented 3 years ago

I tested the dockerized sftp server but it doesn't really replicate my SSH server configuration. eg. it uses chroot for all users.

I've posted in the Rclone forum as requested: https://forum.rclone.org/t/rcx-sftp-root-all-actions-fail/25846/2

x0b commented 3 years ago

That points to an issue in either rclone or go. I've replied on the forum.

43qcc2cn commented 3 years ago

Log files as requested.

rclone-home.log rclone-root.log