gnome-shell-extension-gsconnect icon indicating copy to clipboard operation
gnome-shell-extension-gsconnect copied to clipboard

Correct SFTP path is not used for some devices

Open mspatil32 opened this issue 2 years ago • 59 comments

Describe the bug

Hi,

I think the app in phone got updated recently, and I'm getting the below error when trying to access the mounted drive in linux.

Please provide solutions.

image

Steps to reproduce

No response

Expected behavior

No response

GSConnect version

55

Installed from

GNOME Extensions website

GNOME Shell version

No response

Linux distribution/release

No response

Paired device(s)

No response

KDE Connect app version

No response

Plugin(s)

No response

Support log

No response

Screenshots

No response

Notes

No response

mspatil32 avatar Apr 25 '23 13:04 mspatil32

You don't have permissions to access / of your phone.

Press Ctrl+L and append to the address /storage/emulated/0 to access Android Internal storage. It should be the default.

f-fouad avatar Apr 25 '23 14:04 f-fouad

Hi @f-fouad ,

Thanks for your reply.

Please tell me where should I add the address "/storage/emulated/0".

This issue came up after the "kdeconnect" app got updated yesterday in android. As a work around, I installed the older version of the app (from Jan 2023), and it is working fine.

mspatil32 avatar Apr 25 '23 16:04 mspatil32

I'm seeing the same problem after upgrading kdeconnect on my phone.

@mspatil32 When you're on the Nautlius page giving you the error, pressing Ctrl+L opens the address bar at the top. Append "/storage..." to the address.

seanms avatar Apr 27 '23 15:04 seanms

@seanms Oh okay, understood now. Does this help? Is the entire phone's filesystem accessible by this method? Previously, the Downloads folders in the internal storage was not accessible.

mspatil32 avatar Apr 27 '23 15:04 mspatil32

Yes, this appears to work around the problem. I'm able to read and write the phone's file system.

seanms avatar Apr 27 '23 15:04 seanms

Hi @seanms Thanks a lot. Will try it. Currently, I installed the older version of the app (Jan 2023), and it doesn't give this problem, and I can access some of the folders in the phone (not the main internal storage and the Downloads folder).

mspatil32 avatar Apr 27 '23 15:04 mspatil32

I'm seeing the same with recent versions and appending /storage/emulated/0 helps indeed. @andyholmes would it be possible to optionally add this path via settings automatically?

alexanderadam avatar May 01 '23 18:05 alexanderadam

No, it's the responsibility of the remote device to report the correct path. This doesn't relate to any settings in GSConnect.

andyholmes avatar May 01 '23 18:05 andyholmes

I see. So the KDEConnect client is publishing the remote paths to GSConnect then and currently it is reporting sftp://192.123.123.132:61454/ instead of sftp://192.123.123.132:61454/storage/emulated/0 and hence it is an upstream issue where the KDEConnect client should publish the first valid path instead of the root path.

Do I understand this correctly @andyholmes?

Does anyone know whether there is an upstream ticket for this then?

alexanderadam avatar May 01 '23 18:05 alexanderadam

Correct, the remote device must communicate the path. I haven't seen such a bug report yet, nope :/

andyholmes avatar May 01 '23 18:05 andyholmes

Hi Will there be an update to kde connect app to solve this issue?

mspatil32 avatar May 02 '23 01:05 mspatil32

You will have to open an upstream bug at https://bugs.kde.org

andyholmes avatar May 02 '23 15:05 andyholmes

Sure. Thanks @andyholmes .

mspatil32 avatar May 02 '23 15:05 mspatil32

Not sure whether it's related but I asked over here. :man_shrugging:

alexanderadam avatar May 02 '23 18:05 alexanderadam

@andyholmes would it be possible just to add a configurable default path in the settings until the issue is fixed in upstream? :pleading_face:

alexanderadam avatar May 29 '23 10:05 alexanderadam

No, because it's not a setting. It would be like adding a setting for payload transfer ports, when those should clearly be set internally by the device.

This setting is exposed on the device with the SSH server, because that device has access and control over the server. The remote device can't choose what the correct path is, it can only be told what it is.

andyholmes avatar May 29 '23 20:05 andyholmes

Hi Here are the results of some experiments I have done :

First Configuration :

  • Smartphone : Samsung A52S, Android 12, KDE Connect V1.24.5,
  • PC : Ubuntu 20.04.6, Gnome V3.36.9, GSConnect V53 loaded from https://extensions.gnome.org/ Result : unable to access phone file system (no permission to access "/") from PC. Appending "/storage/emulated/0" to the address in Nautilus with the "Ctrl-L" keys combination gives access to the phone file system.

Second configuration :

  • Smartphone : same as above,
  • PC : same hardware as above, Ubuntu 22.04.2, Gnome V42.2, GSConnect V50 installed from Ubuntu software repository or loaded from https://extensions.gnome.org/ (V53 not available for this version of Gnome). Result : the Phone connects to the PC but it’s impossible to mount it for accessing its file system – no error reported. Other functions seem to work.

Third configuration :

  • Smartphone : same as above,
  • PC : live session Kubuntu 22.04.2 on the same PC hardware, KDE Connect (default installation) Result : access to phone file system without any problem.

Log extract (slightly modified):

GSConnect: 53 (user) GJS: 16405 Session: x11 OS: Ubuntu 20.04.6 LTS

...

mai 29 18:37:46 org.gnome.Shell.Extensions.GSConnect[24701]: [/service/plugins/sftp.js:_listDirectories/iter</<:160]: SM-A528B: Access denied _listDirectories/iter</<@/home/xxxx/.local/share/gnome-shell/extensions/[email protected]/service/plugins/sftp.js:160:38

ajpy5215 avatar May 30 '23 19:05 ajpy5215

So if KDE Connect works it is likely another issue?

alexanderadam avatar May 30 '23 20:05 alexanderadam

@ajpy5215 Thanks for the logs!

The function appears to be a part of a refactoring in #831 which addressed #478. So in fact GSConnect generally ignores the path sent by the Android device and tries to list the directories itself.

This could be fixed by either reverting that patch, or possibly falling back to the advertised paths if the listing fails. Patches for either would be okay by me.

andyholmes avatar May 30 '23 21:05 andyholmes

So /storage/emulated/0 is the main storage. How is the path to the external storage then? It seems that /storage/emulated/1 doesn't work.

alexanderadam avatar Jun 05 '23 15:06 alexanderadam

I my case I get access to the external Sdcard by appending "storage/635F-151F" to "sftp://192.168.1.24:1739/". Unfortunately the value "635F-151F" is specific to my Android/sdcard combination and will be different in other setups so cannot use that value on your side. I obtained the required value while experimenting with Kubuntu/KDEConnect. I’m not aware of other methods to get that value. Note : appending " sdcard" gives the same result as appending "storage/emulated/0".

ajpy5215 avatar Jun 05 '23 18:06 ajpy5215

I see, thank you!

alexanderadam avatar Jun 05 '23 19:06 alexanderadam

Same issue here with ubuntu 23.04. Is there a way to work around this issue? I've tried to bookmark the sftp url on the working /sdcard sub-path but obviously the address and port combination keeps changing, so it won't work for very long. Any other way to create an alias( or something) automatically or from a scripts? (I don't know gvfs very much, whether it has some cmd line tool to list mount points or not, besides the nautilus interface). My problem is that I will likely forget to add /sdcard as the good path (and the emulated thing even more).

neural75 avatar Aug 22 '23 22:08 neural75

Same issue here with ubuntu 23.04. Is there a way to work around this issue? I've tried to bookmark the sftp url on the working /sdcard sub-path but obviously the address and port combination keeps changing, so it won't work for very long.

I quote myself, I think I've found a simple work-around to share: the mount point is available here: /run/user/1000/gsconnect/by-name/<device name>/sdcard device name is "Mi 9T Pro" in my case, so I bookmarked that path under Nautilus as "Mi 9T Pro sdcard". The path /run/user/1000/gsconnect/by-name/Mi 9T Pro/sdcard seems to be constant and working even when the sftp:// url switches port number.

neural75 avatar Aug 22 '23 23:08 neural75

hi @andyholmes , I have been messing with source code for a few days. I have an idea for the workaround.

When mounting storage I tried to create a bookmark with the device name which contains soft links representing internal storage and SD card. It seems like resolving network locations takes time leading me to experience a significant speed drop. I dropped this idea.

i saw some Stackoverflow code(can't find the link rn). What it did was, give the location of the nautilus uri of all instances every time it changed. i plan to use that program to monitor D-bus signal and monitor if I open some dummy folders representing the phone's internal storage and sd card. I have the high-level image of how i wil do it.

at the end, it is just a workaround. if such pr i can be accepted, i will try to integrate it into the code. Otherwise, i will write all logic in Python and run a service as I'm comfortable in it as compared to JavaScript.

fjueic avatar Nov 13 '23 17:11 fjueic

I'm not sure I understand your proposed solution? Nautilus really doesn't know anything about the remote storage, that either has to be sent by kdeconnect-android or queried with GVfs.

andyholmes avatar Nov 13 '23 17:11 andyholmes

with gvfs we can only mount the location provided by whatever is servering sftp. shortcut are out of option as i mentioned above.

i still cant really find the Stackoverflow link but i have the code

dbus-monitor "
type='signal',
interface='org.freedesktop.DBus.Properties',
path='/org/freedesktop/FileManager1',
member='PropertiesChanged'" |   awk -F '"' '
$2 ~ "^/org/gnome/Nautilus/window/[[:digit:]]+$" {
    window = $2
    sub(".*/", "", window)
    tab = 0
    next
}
window && /string / {
    print window"."++tab": "$2
    next
}
tab {window = 0}'

this will monitor d bus signal PropertiesChanged for file manager and dive output like this image i planned on creating a dummy directory like "device name" inside this "Internal Storage" and "sd card" and whenever i open these, just launch a new instance of nautilus with mapped uri.

fjueic avatar Nov 13 '23 17:11 fjueic

Ah, yeah that seems out-of-scope for GSConnect. It might make sense as a Nautilus plugin though.

Probably kdeconnect-android should just serve the path to the SD Card if this is an issue though.

andyholmes avatar Nov 13 '23 17:11 andyholmes

i was checking data shared by kde-connect and it turns out it servers paths for internal storage and sd card. issue lies in with gvfs we can only mount the location provided by whatever is servering sftp.

fjueic avatar Nov 13 '23 18:11 fjueic

kde plasma implements sompthing like kdeconnect:///device-name with internal storage and sd card. And these just redirects to to mapped uri like /storage/emulated/0 and /stoarge/emulated/sdcardvalue. i dont really know anything about custom uri. but i got a workaround(lol)

fjueic avatar Nov 13 '23 18:11 fjueic