SMBSync2 icon indicating copy to clipboard operation
SMBSync2 copied to clipboard

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

Open gv74 opened this issue 3 years ago • 11 comments

  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 avatar Jun 17 '21 05:06 gv74

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

gv74 avatar Jun 17 '21 06:06 gv74

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 avatar Jun 17 '21 06:06 gv74

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 avatar Jun 17 '21 07:06 gv74

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

gv74 avatar Jun 17 '21 07:06 gv74

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.

Sentaroh avatar Jun 17 '21 09:06 Sentaroh

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.

gv74 avatar Jun 17 '21 09:06 gv74

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.

Sentaroh avatar Jun 17 '21 09:06 Sentaroh

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 avatar Jun 17 '21 10:06 gv74

$ rpm -q samba
samba-4.13.3-3.el8.x86_64
$ cat /etc/redhat-release 
CentOS Linux release 8.4.2105

gv74 avatar Jun 17 '21 10:06 gv74

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.

Sentaroh avatar Jun 17 '21 14:06 Sentaroh

OK. Thank you.

gv74 avatar Jun 17 '21 14:06 gv74