Sentaroh / SMBSync2

This application performs file synchronization between an Android device and a PC/NAS via wireless LAN using SMB v1/v2/v3 protocol.
MIT License
256 stars 48 forks source link

Delete for files and directories on smb share does not work anymore #244

Open gv74 opened 3 years ago

gv74 commented 3 years ago
  1. Set "Confirm before overwrite/delete".
  2. Start synchronization of local android directory (containing files and directories) with remote smb share.
  3. Remove a directory containing files inside local android directory.
  4. Start again synchronization of local android directory (containing files and directories) with remote smb share.
  5. When asked "Confirm delete directory smb://x.y.z.1/..../ press Yes
  6. Check Messages tab and notice [File deleted] for all files/directories that where supposed to be deleted.
  7. Check smb share and notice that nothing was deleted.

Tested with SMBSync2 2.52 and 2.54. Files and directories on remote smb share can be removed using other tools.

gv74 commented 3 years ago

Sorry, false alarm. It's a samba issue.

gv74 commented 3 years ago

On further investigation, most likely is problem in SMBSync2. As long the user that logon to smb share is the user that own the files on smb share (SAMBA share), delete works fine. But if I tell SAMBA to change the owner/group of files (force user = xxx and force group = xxx) delete does not work anymore. Works OK with windows, works with total commander for android.

gv74 commented 3 years ago

This is part from SMBSybc2 log:

D I 2021/06/17 10:00:55.079 SyncThread       deleteSmbItem entered, del=smb://x.x.x.x/dummy-share/dummy-dir/dummy/
M E 2021/06/17 10:00:55.132 SyncThread       [dummy-dir]: local ==> SMB: SMB delete error, Access is denied.
 smb://x.x.x.x/dummy-share/dummy-dir/dummy/
M E 2021/06/17 10:00:55.133 SyncThread       [dummy-dir]: local ==> SMB: putErrorMessageJcifs From=/storage/0927-726B/dummy-dir/dummy, To=smb://x.x.x.x/dummy-share/dummy-dir/dummy.
M E 2021/06/17 10:00:55.133 SyncThread       [dummy-dir]: local ==> SMB: Access is denied..
M E 2021/06/17 10:00:55.134 SyncThread       [dummy-dir]: local ==> SMB: NT Status=0xc0000022.
M E 2021/06/17 10:00:55.134 SyncThread       [dummy-dir]: local ==> SMB:..
M E 2021/06/17 10:00:55.135 SyncThread       [dummy-dir]: local ==> SMB: com.sentaroh.jcifs.JcifsFile.delete(JcifsFile.java:204)
com.sentaroh.android.SMBSync2.SyncThread.deleteSmbFile(SyncThread.java:1915)
com.sentaroh.android.SMBSync2.SyncThread.deleteSmbItem(SyncThread.java:1877)
com.sentaroh.android.SMBSync2.SyncThreadSyncFile.syncDeleteInternalToSmb(SyncThreadSyncFile.java:523)
com.sentaroh.android.SMBSync2.SyncThreadSyncFile.syncDeleteInternalToSmb(SyncThreadSyncFile.java:538)
com.sentaroh.android.SMBSync2.SyncThreadSyncFile.syncMirrorExternalToSmb(SyncThreadSyncFile.java:1941)
com.sentaroh.android.SMBSync2.SyncThread.performSync(SyncThread.java:1430)
com.sentaroh.android.SMBSync2.SyncThread.run(SyncThread.java:326).

dummy directory can be deleted from Windows using the same user and password. Same for Total Commander for Android.

gv74 commented 3 years ago

If only force group = xxx is used, delete also works.

Sentaroh commented 3 years ago

Hi,

It looks like an error because the group to which the account used by SMBSync2 belongs has not been assigned delete permission. Review the access authority assignment.

Best regards.

gv74 commented 3 years ago

Hi.

Like I said, I can delete the very same files from windows using the same user and password. There is nothing wrong with access rights on the SMB share.

Regards.

Sentaroh commented 3 years ago

Hi,

No error occurred when "force group = users" was specified.

image

[share] comment = Samba share path = /share create mode = 0777 directory mode = 0777 browseable = yes read only = no guest ok = no force group = users

Best regards.

gv74 commented 3 years ago

Try this config:


[android-backup]
        path = /opt/android-backup
        browseable = yes
        writable = yes
        printable = no
        public = no
        guest only = no
        guest ok = no
        ;create mask = 0660
        ;directory mask = 0770
        force user = user1
        force group = user1
        valid users = android-backup

You authenticate as android-backup and files are owned by user1.

Thank you.

gv74 commented 3 years ago
$ rpm -q samba
samba-4.13.3-3.el8.x86_64
$ cat /etc/redhat-release 
CentOS Linux release 8.4.2105
Sentaroh commented 3 years ago

Hi,

I tested it with your settings, but no error occurred.

-Ubuntu 18.04.5 LTS -Samba 4.7.6

image

service smbd stop sudo adduser user1 sudo adduser android-backup sudo pdbedit -a user1 sudo pdbedit -a android-backup sudo mkdir /opt/android-backup sudo chown user1 /opt/android-backup sudo chgrp user1 /opt/android-backup service smbd start

-Copy to SAMBA image

-Delete from SAMBA image

Best regards.

gv74 commented 3 years ago

OK. Thank you.