zhanghai / MaterialFiles

Material Design file manager for Android
https://play.google.com/store/apps/details?id=me.zhanghai.android.files
GNU General Public License v3.0
5.62k stars 382 forks source link

Error accessing SFTP #1045

Open hjosemaria opened 9 months ago

hjosemaria commented 9 months ago

Trying to access a local ssh server (termux) I get an error: java8.nio.file.AccessDeniedException: /: net.schmizz.sshj.sftp.SFTPException: Permission denied While this might seem as a permission denied case, termux ssh logs show: 10-18 20:52:02.496 23094 23094 I sshd : Accepted password for (redacted username) from 127.0.0.1 port 43686 ssh2 With not prior, nor further errors or somehow negative messages. Using Solid Explorer, I can access with no problems, same case from my laptop through ssh. Great app, btw. It was long due to have something like this project at hand.

zhanghai commented 9 months ago

Is the error shown upon adding the SFTP server, or later using it?

And do you have access to logcat on your device? It would be helpful to know the stacktrace for this exception, since that may contain more information.

hjosemaria commented 9 months ago

Hi, sorry for the delay.

Is the error shown upon adding the SFTP server, or later using it?

It happens whenever trying to connect to the local termux ssh instance. This are the relevant logcat messages: 10-24 10:20:24.752 14836 14836 W sshd : type=1400 audit(0.0:40553): avc: granted { execute } for name="sshd" dev="dm-41" ino=225838 scontext=u:r:untrusted_app_27:s0:c169,c257,c512,c768 tcontext=u:object_r:app_data_file:s0:c169,c257,c512,c768 tclass=file app=com.termux.api 10-24 10:20:24.752 14836 14836 W sshd : type=1400 audit(0.0:40554): avc: granted { execute } for name="sshd" dev="dm-41" ino=225838 scontext=u:r:untrusted_app_27:s0:c169,c257,c512,c768 tcontext=u:object_r:app_data_file:s0:c169,c257,c512,c768 tclass=file app=com.termux.api 10-24 10:20:24.752 14836 14836 W sshd : type=1400 audit(0.0:40555): avc: granted { execute_no_trans } for path="/data/data/com.termux/files/usr/bin/sshd" dev="dm-41" ino=225838 scontext=u:r:untrusted_app_27:s0:c169,c257,c512,c768 tcontext=u:object_r:app_data_file:s0:c169,c257,c512,c768 tclass=file app=com.termux.api 10-24 10:20:24.752 14836 14836 W sshd : type=1400 audit(0.0:40556): avc: granted { execute } for path="/data/data/com.termux/files/usr/bin/sshd" dev="dm-41" ino=225838 scontext=u:r:untrusted_app_27:s0:c169,c257,c512,c768 tcontext=u:object_r:app_data_file:s0:c169,c257,c512,c768 tclass=file app=com.termux.api 10-24 10:20:24.756 14836 14836 W sshd : type=1400 audit(0.0:40557): avc: denied { search } for name="tests" dev="dm-41" ino=107 scontext=u:r:untrusted_app_27:s0:c169,c257,c512,c768 tcontext=u:object_r:shell_test_data_file:s0 tclass=dir permissive=0 app=com.termux.api 10-24 10:20:24.938 14836 14836 I sshd : Accepted password for (redacted username) from 127.0.0.1 port 47162 ssh2

With Solid Explorer the log is: 10-24 10:40:53.352 22459 22459 W sshd : type=1400 audit(0.0:41019): avc: granted { execute } for name="sshd" dev="dm-41" ino=225838 scontext=u:r:untrusted_app_27:s0:c169,c257,c512,c768 tcontext=u:object_r:app_data_file:s0:c169,c257,c512,c768 tclass=file app=com.termux.api 10-24 10:40:53.352 22459 22459 W sshd : type=1400 audit(0.0:41020): avc: granted { execute } for name="sshd" dev="dm-41" ino=225838 scontext=u:r:untrusted_app_27:s0:c169,c257,c512,c768 tcontext=u:object_r:app_data_file:s0:c169,c257,c512,c768 tclass=file app=com.termux.api 10-24 10:40:53.352 22459 22459 W sshd : type=1400 audit(0.0:41021): avc: granted { execute_no_trans } for path="/data/data/com.termux/files/usr/bin/sshd" dev="dm-41" ino=225838 scontext=u:r:untrusted_app_27:s0:c169,c257,c512,c768 tcontext=u:object_r:app_data_file:s0:c169,c257,c512,c768 tclass=file app=com.termux.api 10-24 10:40:53.352 22459 22459 W sshd : type=1400 audit(0.0:41022): avc: granted { execute } for path="/data/data/com.termux/files/usr/bin/sshd" dev="dm-41" ino=225838 scontext=u:r:untrusted_app_27:s0:c169,c257,c512,c768 tcontext=u:object_r:app_data_file:s0:c169,c257,c512,c768 tclass=file app=com.termux.api 10-24 10:40:53.356 22459 22459 W sshd : type=1400 audit(0.0:41023): avc: denied { search } for name="tests" dev="dm-41" ino=107 scontext=u:r:untrusted_app_27:s0:c169,c257,c512,c768 tcontext=u:object_r:shell_test_data_file:s0 tclass=dir permissive=0 app=com.termux.api 10-24 10:40:53.497 22459 22459 I sshd : Accepted password for (redacted username) from 127.0.0.1 port 49192 ssh2 10-24 10:41:00.035 22459 22459 I sshd : Received disconnect from 127.0.0.1 port 49192:11: Closed due to user request. 10-24 10:41:00.035 22459 22459 I sshd : Disconnected from user (redacted username) 127.0.0.1 port 49192

zhanghai commented 9 months ago

Those are the logs for sshd, but I was asking about the logcat output of MaterialFiles, specifically the stacktrace of AccessDeniedException and anything around it.

hjosemaria commented 9 months ago

Sorry, I'm kinda new to this. I hope this is what I had to do:

10-24 15:31:28.164 1107 2416 I ActivityTaskManager: START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=me.zhanghai.android.files/.filelist.FileListActivity bnds=[18,1137][227,1461]} from uid 10269 10-24 15:31:28.188 1107 4870 D CoreBackPreview: Window{bb2d68d u0 Splash Screen me.zhanghai.android.files}: Setting back callback OnBackInvokedCallbackInfo{mCallback=android.window.IOnBackInvokedCallback$Stub$Proxy@480e853, mPriority=0} 10-24 15:31:28.191 1107 1493 I ActivityManager: Start proc 12319:me.zhanghai.android.files/u0a464 for next-top-activity {me.zhanghai.android.files/me.zhanghai.android.files.filelist.FileListActivity} 10-24 15:31:28.215 3705 3705 D GameMode: onStartedActivityChange: componnent: ComponentInfo{me.zhanghai.android.files/me.zhanghai.android.files.filelist.FileListActivity} entered launcher screen? true 10-24 15:31:28.219 5140 5253 W DynamicVolume: DynamicVolumeService: onForegroundActivitiesChanged, record latest volume: AppStartVolume(packageUid=10464, packageName=me.zhanghai.android.files, timeInMillis=1698172288218, date=Tue Oct 24 15:31:28 GMT-03:00 2023, startVolume=0, deviceType=2) 10-24 15:31:28.221 12319 12319 D nativeloader: Configuring classloader-namespace for other apk /data/app/~~YFDrCUe8CxMa12O0X3Ypdw==/me.zhanghai.android.files-Ka2hZ0zP4KCIUFqPA3eTzA==/base.apk. target_sdk_version=34, uses_libraries=, library_path=/data/app/~~YFDrCUe8CxMa12O0X3Ypdw==/me.zhanghai.android.files-Ka2hZ0zP4KCIUFqPA3eTzA==/lib/arm64:/data/app/~~YFDrCUe8CxMa12O0X3Ypdw==/me.zhanghai.android.files-Ka2hZ0zP4KCIUFqPA3eTzA==/base.apk!/lib/arm64-v8a, permitted_path=/data:/mnt/expand:/data/user/0/me.zhanghai.android.files 10-24 15:31:28.226 12319 12319 V GraphicsEnvironment: ANGLE Developer option for 'me.zhanghai.android.files' set to: 'default' 10-24 15:31:28.226 12319 12319 V GraphicsEnvironment: ANGLE GameManagerService for me.zhanghai.android.files: false 10-24 15:31:28.317 1107 2642 D CoreBackPreview: Window{e35daec u0 me.zhanghai.android.files/me.zhanghai.android.files.filelist.FileListActivity}: Setting back callback OnBackInvokedCallbackInfo{mCallback=android.window.IOnBackInvokedCallback$Stub$Proxy@efcd94a, mPriority=0} 10-24 15:31:28.362 1107 1448 I LaunchCheckinHandler: MotoDisplayed me.zhanghai.android.files/.filelist.FileListActivity,cp,ca,186 10-24 15:31:28.367 1107 1440 I ActivityTaskManager: Displayed me.zhanghai.android.files/.filelist.FileListActivity: +198ms 10-24 15:31:28.415 3600 3600 I GoogleInputMethodService: GoogleInputMethodService.onStartInput():1883 onStartInput(EditorInfo{EditorInfo{packageName=me.zhanghai.android.files, inputType=0, inputTypeString=NULL, enableLearning=false, autoCorrection=false, autoComplete=false, imeOptions=0, privateImeOptions=null, actionName=UNSPECIFIED, actionLabel=null, initialSelStart=-1, initialSelEnd=-1, initialCapsMode=0, label=null, fieldId=-1, fieldName=null, extras=null, hintText=null, hintLocales=[]}}, false) 10-24 15:31:28.729 1107 4870 D CoreBackPreview: Window{bb2d68d u0 Splash Screen me.zhanghai.android.files EXITING}: Setting back callback null 10-24 15:31:28.731 1107 2642 W InputManager-JNI: Input channel object 'bb2d68d Splash Screen me.zhanghai.android.files (client)' was disposed without first being removed with the input manager! 10-24 15:31:32.708 12319 12319 W System.err: Caused by: me.zhanghai.android.files.provider.sftp.client.ClientException: net.schmizz.sshj.sftp.SFTPException: Permission denied 10-24 15:31:34.020 12319 12421 D ProfileInstaller: Skipping profile installation for me.zhanghai.android.files 10-24 15:31:41.779 12319 12319 W System.err: Caused by: me.zhanghai.android.files.provider.sftp.client.ClientException: net.schmizz.sshj.sftp.SFTPException: Permission denied 10-24 15:31:49.383 1107 2945 I InputDispatcher: Channel [Gesture Monitor] swipe-up (server) is stealing touch from [e35daec me.zhanghai.android.files/me.zhanghai.android.files.filelist.FileListActivity (server), [Gesture Monitor] three-finger (server), [Gesture Monitor] edge-swipe (server), [Gesture Monitor] onehanded-touch (server)] 10-24 15:31:51.231 3705 3705 D GameMode: onStartedActivityChange: componnent: ComponentInfo{me.zhanghai.android.files/me.zhanghai.android.files.filelist.FileListActivity} entered launcher screen? false 10-24 15:31:51.308 1107 1447 I ActivityManager: Killing 12319:me.zhanghai.android.files/u0a464 (adj 700, setSvc -10000): remove task 10-24 15:31:51.352 1107 2805 I ActivityManager: appDiedLocked: app=ProcessRecord{d2587b7 12319:me.zhanghai.android.files/u0a464} thread=android.os.BinderProxy@7e05ece fromBinderDied=true isKilledByAm=true reason=null 10-24 15:31:51.353 1107 5488 I WindowManager: WIN DEATH: Window{e35daec u0 me.zhanghai.android.files/me.zhanghai.android.files.filelist.FileListActivity} 10-24 15:31:51.353 1107 5488 W InputManager-JNI: Input channel object 'e35daec me.zhanghai.android.files/me.zhanghai.android.files.filelist.FileListActivity (client)' was disposed without first being removed with the input manager! 10-24 15:31:51.356 1107 2805 D RestartModeController: markWaitRestartAppIsSuicided null processName=me.zhanghai.android.files 10-24 15:31:51.387 1107 1464 W UsageStatsService: Unexpected activity event reported! (me.zhanghai.android.files/me.zhanghai.android.files.filelist.FileListActivity event : 23 instanceId : 238233169) What i did to get the log is to open the app, select the SFTP share from the menu, and then getting the error message. And then pull down on the screen to refresh, thus making another connection attempt. And finally closing the app.