wa2c / cifs-documents-provider

CIFS Documents Provider
MIT License
263 stars 23 forks source link

Connection failed when creating new share #8

Open KingDuckZ opened 2 years ago

KingDuckZ commented 2 years ago

I want to connect to the samba share hosted on my GL.Inet MT1300 router. In cifs documents provider I do this:

  1. click on the add button
  2. select the appropriate item in the list with ip 192.168.8.1
  3. choose IP address in the popup
  4. click the folder icon or the check connection button and I just get a "connection failed" message
  5. check "anonymous"
  6. point 4 again

Of course I tried entering the router login instead of choosing anonymous, and I tried setting the folder manually to "/" and to "GL-Samba", all combinations always result in the same error message. I can't see any details about the reason of the failure. I tried on two different phones.

Note that if I use the Ghost Commander app with the Samba plugin on the same phones, I can just browse to 192.168.8.1 normally without any login and without any issues. Mounting from linux also works fine with this command: mount -t cifs //192.168.8.1/GL-Samba /mnt/samba -o defaults,guest,iocharset=utf8,rw,vers=1.0,uid=nobody,gid=nobody,file_mode=0770,dir_mode=0770,exec,nounix

YanceyChiew commented 2 years ago

mount -t cifs //192.168.8.1/GL-Samba /mnt/samba -o defaults,guest,iocharset=utf8,rw,vers=1.0,uid=nobody,gid=nobody,file_mode=0770,dir_mode=0770,exec,nounix

Maybe this is the problem. This application uses the jcifs-ng library, which removes support for smb1.0.

wa2c commented 2 years ago

@YanceyChiew Thanks for your help.

@KingDuckZ CIFS Documents Provider is not supported SMB 1.0 protocol because of it is deprecated now. Please refer to the followings.

Does your router support SMB 2.0 or later?

KingDuckZ commented 2 years ago

I don't know to be honest... the command above is what I came up with after a lot of trial and error What I know is that this MT1300 router is a recent model from december 2020. It runs a modified version of openwrt and the samba package is reported in the web ui as "samba36-server 3.6.25-15". The smb.conf from the router is:

[global]
        netbios name = GL-MT1300 
        display charset = UTF-8
        interfaces = lo br-lan 
        server string = GL-MT1300-228
        unix charset = UTF-8
        workgroup = WORKGROUP
        browseable = yes
        deadtime = 30
        domain master = yes
        encrypt passwords = true
        enable core files = no
        guest account = nobody
        guest ok = yes
        invalid users = root
        local master = yes
        load printers = no
        map to guest = Bad User
        max protocol = SMB2
        min receivefile size = 16384
        null passwords = yes
        obey pam restrictions = yes
        os level = 20
        passdb backend = smbpasswd
        preferred master = yes
        printable = no
        security = share
        smb encrypt = disabled
        smb passwd file = /etc/samba/smbpasswd
        socket options = TCP_NODELAY IPTOS_LOWDELAY
        syslog = 2
        use sendfile = yes
        writeable = yes

[homes]
        comment     = Home Directories
        browsable   = no
        read only   = no
        create mode = 0750

[GL-Samba]
        path = /mnt
        read only = no
        guest ok = yes

If there's anything I can change in the configuration let me know and I will try. If the version mismatch is the problem though, I think it would still be nice if cifs document provider could warn the user instead of giving a generic failure error.

Edit: to be clear, this is all the default stuff from the router, I didn't do any manual customisation.

wa2c commented 2 years ago

@KingDuckZ As far as I can see, the settings seem to support SMB2. ( max protocol = SMB2 )

I made an new apk file. Please try this apk if you can. https://www.wa2c.com/android/apk/work/CIFSDocumentsProvider-1.3.1-test.apk

The changes in this APK are as follows: (Branch: https://github.com/wa2c/cifs-documents-provider/tree/fix/issue_8 )

If you can not connect by this apk, please tell me the error message.

KingDuckZ commented 2 years ago

Thanks for your help @wa2c! I tried the test apk, unfortunately it still fails :( the error I get now is: Failed to connect: 0.0.0.0<00>/192.168.8.1

wa2c commented 2 years ago

This error is typically displayed when the Android device cannot find the host. I'll do some research.

wa2c commented 2 years ago

In my investigation, the same message was shown in the case of SMB1 server. (It checked by Windows XP.) Your router may be running on SMB1....

wa2c commented 2 years ago

@KingDuckZ I found following document. Pleade try "Method 1: Samba 2.0 (SMB2.0) Support:" section.

https://docs.gl-inet.com/en/3/tutorials/file_sharing/

wa2c commented 2 years ago

@KingDuckZ I released 1.4.0 beta test version on Google Play. I think this version solves the problem. Can you try this and see if it has been fixed?

wa2c commented 2 years ago

@KingDuckZ I released 1.4.0 new beta test version on Google Play.