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.86k stars 397 forks source link

[Feature Request] Support SMB `server signing` & `server smb encrypt` #486

Open mingcenwei opened 3 years ago

mingcenwei commented 3 years ago

Materials Files version: 1.2.0 (22) from F-Droid Samba server version: Version 4.14.2 on Arch Linux (5.11.10-arch1-1)

Currently, if either SMB server signing (server signing = mandatory in smb.conf) or SMB server encryption (server smb encrypt = required) is enforced, this app will throw errors as in the following image.

1617266549346

zhanghai commented 3 years ago

https://github.com/hierynomus/smbj/issues/617 might be related.

zhanghai commented 3 years ago

Actually SMBJ seems to be using BCSecurityProvider on Android by default (source). If you have adb, could you try to find the stacktrace in adb logcat?

mingcenwei commented 3 years ago

This is the relevant stacktrace

# logcat -b all -s System.err
--------- beginning of crash
--------- beginning of radio
--------- beginning of system
--------- beginning of events
--------- beginning of main
04-03 03:16:15.552 30523 30561 W System.err: java8.nio.file.FileSystemException: /: / does not have a share path
04-03 03:16:15.552 30523 30561 W System.err:    at f.a.a.a.b.i.f$a.<init>(:1)
04-03 03:16:15.553 30523 30561 W System.err:    at me.zhanghai.android.files.provider.smb.SmbPath.M(:3)
04-03 03:16:15.553 30523 30561 W System.err:    at f.a.a.a.b.d.a.s(Unknown Source:13)
04-03 03:16:15.553 30523 30561 W System.err:    at f.a.a.a.b.d.m0.<init>(Unknown Source:42)
04-03 03:16:15.553 30523 30561 W System.err:    at f.a.a.a.b.i.c.a(Unknown Source:18)
04-03 03:16:15.553 30523 30561 W System.err:    at f.a.a.d.n.n3(Unknown Source:11)
04-03 03:16:15.553 30523 30561 W System.err:    at f.a.a.a.k.f0$a.run(:4)
04-03 03:16:15.553 30523 30561 W System.err:    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
04-03 03:16:15.553 30523 30561 W System.err:    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
04-03 03:16:15.553 30523 30561 W System.err:    at java.lang.Thread.run(Thread.java:923)
04-03 03:16:15.553 30523 30561 W System.err: Caused by: me.zhanghai.android.files.provider.smb.client.ClientException: / does not have a share path
04-03 03:16:15.553 30523 30561 W System.err:    at f.a.a.a.b.i.g.c.k(:7)
04-03 03:16:15.553 30523 30561 W System.err:    at f.a.a.a.b.i.f$a.<init>(Unknown Source:58)
04-03 03:16:15.553 30523 30561 W System.err:    ... 9 more
04-03 03:16:15.568 30523 30523 W System.err: java8.nio.file.FileSystemException: /: java.net.ConnectException: failed to connect to /192.168.1.11 (port 445) from /192.168.1.3 (port 47230) after 5000ms: isConnected failed: ECONNREFUSED (Connection refused)
04-03 03:16:15.568 30523 30523 W System.err:    at f.a.a.a.b.i.c.s(:1)
04-03 03:16:15.568 30523 30523 W System.err:    at s.a.c.l.e(:2)
04-03 03:16:15.568 30523 30523 W System.err:    at f.a.a.d.n.i3(Unknown Source:5)
04-03 03:16:15.568 30523 30523 W System.err:    at f.a.a.a.k.v$b.call(:3)
04-03 03:16:15.568 30523 30523 W System.err:    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
04-03 03:16:15.568 30523 30523 W System.err:    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
04-03 03:16:15.568 30523 30523 W System.err:    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
04-03 03:16:15.568 30523 30523 W System.err:    at java.lang.Thread.run(Thread.java:923)
04-03 03:16:15.568 30523 30523 W System.err: Caused by: me.zhanghai.android.files.provider.smb.client.ClientException: java.net.ConnectException: failed to connect to /192.168.1.11 (port 445) from /192.168.1.3 (port 47230) after 5000ms: isConnected failed: ECONNREFUSED (Connection refused)
04-03 03:16:15.568 30523 30523 W System.err:    at f.a.a.a.b.i.g.c.i(:12)
04-03 03:16:15.568 30523 30523 W System.err:    at f.a.a.a.b.i.g.c.l(Unknown Source:9)
04-03 03:16:15.568 30523 30523 W System.err:    at f.a.a.a.b.i.c.s(Unknown Source:27)
04-03 03:16:15.568 30523 30523 W System.err:    ... 7 more
04-03 03:16:15.568 30523 30523 W System.err: Caused by: java.net.ConnectException: failed to connect to /192.168.1.11 (port 445) from /192.168.1.3 (port 47230) after 5000ms: isConnected failed: ECONNREFUSED (Connection refused)
04-03 03:16:15.568 30523 30523 W System.err:    at libcore.io.IoBridge.isConnected(IoBridge.java:287)
04-03 03:16:15.568 30523 30523 W System.err:    at libcore.io.IoBridge.connectErrno(IoBridge.java:192)
04-03 03:16:15.568 30523 30523 W System.err:    at libcore.io.IoBridge.connect(IoBridge.java:134)
04-03 03:16:15.568 30523 30523 W System.err:    at java.net.PlainSocketImpl.socketConnect(PlainSocketImpl.java:142)
04-03 03:16:15.568 30523 30523 W System.err:    at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:390)
04-03 03:16:15.568 30523 30523 W System.err:    at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:230)
04-03 03:16:15.568 30523 30523 W System.err:    at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:212)
04-03 03:16:15.569 30523 30523 W System.err:    at java.net.Socket.connect(Socket.java:621)
04-03 03:16:15.569 30523 30523 W System.err:    at o.g.i.c.h.a.a(Unknown Source:21)
04-03 03:16:15.569 30523 30523 W System.err:    at o.g.i.c.h.a.createSocket(Unknown Source:6)
04-03 03:16:15.569 30523 30523 W System.err:    at o.g.l.g.a.e(:1)
04-03 03:16:15.569 30523 30523 W System.err:    at o.g.l.c.b(:2)
04-03 03:16:15.569 30523 30523 W System.err:    at f.a.a.a.b.i.g.c.i(:11)
04-03 03:16:15.569 30523 30523 W System.err:    ... 9 more
04-03 03:16:15.569 30523 30523 W System.err: Caused by: android.system.ErrnoException: isConnected failed: ECONNREFUSED (Connection refused)
04-03 03:16:15.569 30523 30523 W System.err:    at libcore.io.IoBridge.isConnected(IoBridge.java:274)
04-03 03:16:15.569 30523 30523 W System.err:    ... 21 more
zhanghai commented 3 years ago

java.net.ConnectException: failed to connect to /192.168.1.11 (port 445) from /192.168.1.3 (port 47230) after 5000ms: isConnected failed: ECONNREFUSED (Connection refused)

It seems the SMB server outright refused the connection - can the SMB server be connected through other clients on your phone?

mingcenwei commented 3 years ago

The SMB client in the iOS Files app on my iPad can connect to the SMB server. Also, Material Files can connect to the SMB server if server signing = mandatory is changed to server signing = default (or removed) and server smb encrypt = required is changed to server smb encrypt = desired (or removed) in the server's configuration.

JJGadgets commented 2 years ago

On the latest Material Files release on F-Droid, I am having this exact error code and message. I also do not wish to change my signing and encryption settings, is there any progress on this issue?

SebiderSushi commented 1 year ago

Tested on one device running LineageOS 15.1 and on two different devices running LineageOS 18.1 with Material Files version 1.5.2 (31).

I can successfully connect to the same share using Android Samba Client version 1.1 (111) and from a Windows 10 device.

The Cipher is null in every case. Could this be an issue with the ROMs i'm using? On 2 different device models?

03-25 04:37:56.729 24234 24258 I z4.e    : Initialized PacketEncryptor with Cipher << null >>
03-25 04:37:56.730 24234 24258 I z4.a    : Successfully connected to: 10.1.1.39
03-25 04:37:56.774 24234 24258 I z4.a    : Closed connection to 10.1.1.39
03-25 04:37:56.774 24234 24281 I i5.a    : Thread[Packet Reader for 10.1.1.39,5,main] stopped.
03-25 04:37:56.777 24234 24234 W System.err: java8.nio.file.AccessDeniedException: /shared: com.hierynomus.mssmb2.SMBApiException: STATUS_ACCESS_DENIED (0xc0000022): Authentication failed for 'shared' using x4.f@32973c7
03-25 04:37:56.777 24234 24234 W System.err:    at pa.b.s(:1)
03-25 04:37:56.777 24234 24234 W System.err:    at u6.k.e(:2)
03-25 04:37:56.777 24234 24234 W System.err:    at d.b.v0(Unknown Source:5)
03-25 04:37:56.777 24234 24234 W System.err:    at q9.c0.call(:1)
03-25 04:37:56.777 24234 24234 W System.err:    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
03-25 04:37:56.777 24234 24234 W System.err:    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
03-25 04:37:56.777 24234 24234 W System.err:    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
03-25 04:37:56.777 24234 24234 W System.err:    at java.lang.Thread.run(Thread.java:764)
03-25 04:37:56.778 24234 24234 W System.err: Caused by: me.zhanghai.android.files.provider.smb.client.ClientException: com.hierynomus.mssmb2.SMBApiException: STATUS_ACCESS_DENIED (0xc0000022): Authentication failed for 'shared' using x4.f@32973c7
03-25 04:37:56.778 24234 24234 W System.err:    at qa.d.i(:13)
03-25 04:37:56.778 24234 24234 W System.err:    at qa.d.l(Unknown Source:4)
03-25 04:37:56.778 24234 24234 W System.err:    at pa.b.s(Unknown Source:27)
03-25 04:37:56.778 24234 24234 W System.err:    ... 7 more
03-25 04:37:56.778 24234 24234 W System.err: Caused by: com.hierynomus.mssmb2.SMBApiException: STATUS_ACCESS_DENIED (0xc0000022): Authentication failed for 'shared' using x4.f@32973c7
03-25 04:37:56.778 24234 24234 W System.err:    at z4.i.e(:129)
03-25 04:37:56.778 24234 24234 W System.err:    at z4.i.e(:44)
03-25 04:37:56.778 24234 24234 W System.err:    at z4.a.b0(:5)
03-25 04:37:56.778 24234 24234 W System.err:    ... 10 more