nova-video-player / aos-AVP

NOVA opeN sOurce Video plAyer: main repository to build them all
Apache License 2.0
3.38k stars 201 forks source link

Samba V1 broken in beta #228

Closed emarch06 closed 4 years ago

emarch06 commented 4 years ago

Hi,

since beta 1.0-20191106.0854, I can't access to my samba share anymore. The share is on a freebox server (mini), which is based on smb V1 I think.

When I go to network shares in Nova, then open the share, I've got this error:

11-07 21:09:54.188 2999 4753 I ActivityManager: START u0 {cmp=org.courville.nova/com.archos.mediacenter.video.leanback.network.smb.SmbListingActivity (has extras)} from uid 10076 on display 0 11-07 21:09:54.377 30198 30208 I art : Background sticky concurrent mark sweep GC freed 57875(2MB) AllocSpace objects, 0(0B) LOS objects, 16% free, 14MB/17MB, paused 3.524ms total 110.517ms 11-07 21:09:54.445 30198 30198 D ListingFragment: onCreate null 11-07 21:09:54.543 30198 30198 D ListingFragment: onCreateView SmbListingFragment{319314a (a06a3ea4-f704-46ce-8a5e-8fc5e06157ec) id=0x7f0a014f fragment_0} null 11-07 21:09:54.659 30198 30198 D ListingFragment: startListing smb://srv/Freebox/ 11-07 21:09:54.663 30198 418 D JcifListingEngine: listFiles for:smb://srv/Freebox/ 11-07 21:09:54.767 2999 3040 I ActivityManager: Displayed org.courville.nova/com.archos.mediacenter.video.leanback.network.smb.SmbListingActivity: +521ms 11-07 21:09:54.800 2999 2999 V NotificationService: pkg=com.canal.android.canal canInterrupt=false intercept=true 11-07 21:09:54.901 30198 418 E JcifListingEngine: JcifListingThread: SmbException 11-07 21:09:54.901 30198 418 E JcifListingEngine: jcifs.smb.SmbException: Invalid operation for IPC service: Trans2FindFirst2[command=SMB_COM_TRANSACTION2,received=false,errorCode=0,flags=0x0018,flags2=0x0000,signSeq=0,tid=1,pid=19784,uid=0,mid=0,wordCount=0,byteCount=0,totalParameterCount=0,totalDataCount=0,maxParameterCount=10,maxDataCount=65535,maxSetupCount=0,flags=0x00,timeout=0,parameterCount=0,parameterOffset=0,parameterDisplacement=0,dataCount=0,dataOffset=0,dataDisplacement=0,setupCount=1,pad=0,pad1=0,searchAttributes=0x16,searchCount=200,flags=0x00,informationLevel=0x104,searchStorageType=0,filename=] 11-07 21:09:54.901 30198 418 E JcifListingEngine: at jcifs.smb.SmbTreeImpl.checkRequest(SourceFile:519) 11-07 21:09:54.901 30198 418 E JcifListingEngine: at jcifs.smb.SmbTreeImpl.send(SourceFile:449) 11-07 21:09:54.901 30198 418 E JcifListingEngine: at jcifs.smb.SmbTreeConnection.send0(SourceFile:404) 11-07 21:09:54.901 30198 418 E JcifListingEngine: at jcifs.smb.SmbTreeConnection.send(SourceFile:318) 11-07 21:09:54.901 30198 418 E JcifListingEngine: at jcifs.smb.SmbTreeConnection.send(SourceFile:298) 11-07 21:09:54.901 30198 418 E JcifListingEngine: at jcifs.smb.SmbTreeHandleImpl.send(SourceFile:130) 11-07 21:09:54.901 30198 418 E JcifListingEngine: at jcifs.smb.DirFileEntryEnumIterator1.open(SourceFile:67) 11-07 21:09:54.901 30198 418 E JcifListingEngine: at jcifs.smb.DirFileEntryEnumIteratorBase.(SourceFile:67) 11-07 21:09:54.901 30198 418 E JcifListingEngine: at jcifs.smb.DirFileEntryEnumIterator1.(SourceFile:46) 11-07 21:09:54.901 30198 418 E JcifListingEngine: at jcifs.smb.SmbEnumerationUtil.doEnum(SourceFile:225) 11-07 21:09:54.901 30198 418 E JcifListingEngine: at jcifs.smb.SmbEnumerationUtil.listFiles(SourceFile:279) 11-07 21:09:54.901 30198 418 E JcifListingEngine: at jcifs.smb.SmbFile.listFiles(SourceFile:1273) 11-07 21:09:54.901 30198 418 E JcifListingEngine: at com.archos.filecorelibrary.jcifs.JcifListingEngine$JcifListingThread.run(SourceFile:122)

On the changelog, it is said that you're working on it, I assume it explains the issue.

courville commented 4 years ago

Thanks for the feedback. Indeed we switched to jcifs-ng to get SMBv2/3 and I tested SMBv1 compatibility on Synology but not on the freebox. Would you be able to do some wireshark/tcpdump captures and run a simple java program on a PC/mac/linux host to debug the issue and provide feedback to jcifs-ng main developer? Cf. https://gist.github.com/courville/a0e6fe1ce2f31c9adc52191216eed3e0

emarch06 commented 4 years ago

Hi, I think I can do this; I also have a network analyzer able to do a man in the middle sniff on a network link. If you prefer I could do a pcap using this appliance and running nova instead of the test app. What do you prefer?

courville commented 4 years ago

Hi, I think I can do this; I also have a network analyzer able to do a man in the middle sniff on a network link. If you prefer I could do a pcap using this appliance and running nova instead of the test app. What do you prefer?

Excellent! I have always interacted with jcifs-ng main developer using the simple smbcli.java test program (self sufficient) which is representative of how nova behaves (e.g. https://github.com/AgNO3/jcifs-ng/issues/149). mbechler only works on pcap and both wireshark or tcpdump is ok and can be run on same host running the smbcli.java (he replies only on Saturday and Sunday). If you need help please let me know (you can also reachout on irc freenode #novavideoplayer to courville). Thank you for your help to assist in debugging the issue.

emarch06 commented 4 years ago

Issue reproduced with the test app. Ticket entered on jcifs-ng : https://github.com/AgNO3/jcifs-ng/issues/193 Waiting for feedback...

courville commented 4 years ago

Issue reproduced with the test app. Ticket entered on jcifs-ng : AgNO3/jcifs-ng#193 Waiting for feedback...

Thank you!

emarch06 commented 4 years ago

Hi, the jcifs developer has answered, indeed I can see in the pcap that the SW is trying to list the IPC$ share that leads to a failure. So maybe we could add a check for this special share before doing listFiles(); (and not call this method line 137 if the smbFile is named IPC$?

courville commented 4 years ago

Hi, the jcifs developer has answered, indeed I can see in the pcap that the SW is trying to list the IPC$ share that leads to a failure. So maybe we could add a check for this special share before doing listFiles(); (and not call this method line 137 if the smbFile is named IPC$?

unfortunately I guess that the error is in jcifs-ng since we are not calling listFiles on IPC share. Let's investigate further and reply to mbechler

courville commented 4 years ago

Quick question for the stacktrace obtained on https://github.com/AgNO3/jcifs-ng/issues/193 could you please detail the command you used with smbcli?

courville commented 4 years ago

Looking at the various traces, could you please confirm that your are in the following situation: top level (root) non password protected (you can list the shares) and some shares are password protected? If yes, perhaps there is an explanation in jcifs-ng codepath. I will test tonight with my synology. A possible fix would be (if possible on freebox) to have even root password protected.

emarch06 commented 4 years ago

Hi,

I confirm I'm browsing the root level of the share. There's only one share on the server There's no password on the share. I enabled SMB V1 support on windows 10 with optionalfeatures command

I run the sample app this way java -cp .;jcifs-ng-jcifs-ng-2.1.3/target/jcifs-ng-2.1.3.jar;bcprov-jdk15on-1.61.jar;apache-log4j-1.2.17/log4j-1.2.17.jar;apache-maven-3.6.2/lib/slf4j-api-1.7.25.jar smbcli 1 smb://serveur/freebox/

I also tried with smbcli 2 to enable SMBV2, same issue

I added some logging on the code. Here's the new file smbcli.java.txt

The new output is 2019-11-13 22:14:57 INFO smbcli:136 - smbFile is a share 2019-11-13 22:14:57 INFO smbcli:141 - Current smbFile name = freebox/ 2019-11-13 22:14:57 WARN smbcli:147 - Caught a SmbException on listFiles jcifs.smb.SmbException: Invalid operation for IPC service: Trans2FindFirst2[command=SMB_COM_TRANSACTION2,received=false,errorCode=0,flags=0x0018,flags2=0x0000,signSeq=0,tid=1,pid=45465,uid=0,mid=0,wordCount=0,byteCount=0,totalParameterCount=0,totalDataCount=0,maxParameterCount=10,maxDataCount=65535,maxSetupCount=0,flags=0x00,timeout=0,parameterCount=0,parameterOffset=0,parameterDisplacement=0,dataCount=0,dataOffset=0,dataDisplacement=0,setupCount=1,pad=0,pad1=0,searchAttributes=0x16,searchCount=200,flags=0x00,informationLevel=0x104,searchStorageType=0,filename=] at jcifs.smb.SmbTreeImpl.checkRequest(SmbTreeImpl.java:519) at jcifs.smb.SmbTreeImpl.send(SmbTreeImpl.java:449) at jcifs.smb.SmbTreeConnection.send0(SmbTreeConnection.java:404) at jcifs.smb.SmbTreeConnection.send(SmbTreeConnection.java:318) at jcifs.smb.SmbTreeConnection.send(SmbTreeConnection.java:298) at jcifs.smb.SmbTreeHandleImpl.send(SmbTreeHandleImpl.java:130) at jcifs.smb.DirFileEntryEnumIterator1.open(DirFileEntryEnumIterator1.java:67) at jcifs.smb.DirFileEntryEnumIteratorBase.(DirFileEntryEnumIteratorBase.java:67) at jcifs.smb.DirFileEntryEnumIterator1.(DirFileEntryEnumIterator1.java:46) at jcifs.smb.SmbEnumerationUtil.doEnum(SmbEnumerationUtil.java:225) at jcifs.smb.SmbEnumerationUtil.listFiles(SmbEnumerationUtil.java:279) at jcifs.smb.SmbFile.listFiles(SmbFile.java:1199) at smbcli.main(smbcli.java:143) 2019-11-13 22:14:57 INFO smbcli:170 - smbFilesArray is null

courville commented 4 years ago

OK rolling back to old jcifs only SMBv1 in beta/release. Will treat this jcifs-ng in separate apks.

emarch06 commented 4 years ago

Hi @courville,

I made a build of the sample app with the jcifsng master branch. I confirm the issue is fixed :).

Can you build me a nova apk with this version to make a try?

Thanks

courville commented 4 years ago

Can you build me a nova apk with this version to make a try?

I noticed the patch too. Please try this experimental build: https://drive.google.com/open?id=1raY9oSBPrG3I5VprowVYuLs7ueBhg6N0

emarch06 commented 4 years ago

Good news, it works now :) You can merge the patch in the beta again.

May I ask you to have a look at the issue https://github.com/nova-video-player/aos-AVP/issues/148 ? It's really annoying ;-)

courville commented 4 years ago

Official release is available here: https://www.reddit.com/r/NovaVideoPlayer/comments/e4n3eh/v56_smbv2_experimental_release/