I have a problem where deleting a folder symlink on a mounted Samba share also deletes the target folder's contents when accessed from my Macbook. This is actually a problem I have had for many years, and remains despite using different machines and operating systems versions.
Here is the sequence of events:
- touch foo/bar/1.txt
- Create a symlink to a folder on an Ubuntu machine, i.e. ln -s foo/bar bar2
- Mount the Samba share containing the bar 2 symlink on a Mac
- Delete the bar2 symlink via the Mac.
- The symlink bar2 will be deleted, but the file foo/bar/1.txt will also be gone. Any files or folders in foo/bar will be gone.
At the moment, I am running El Capitan, Ubuntu 16.04 with Samba 4.3.11.
I have the following options in my smb.conf which are the only thing that come to mind as possible involved:
allow insecure wide links = yes
unix extensions = no
Best Answer
Since windows file sharing and hence the original samba had no concept of symlinks it would normally delete all of the folder tree through a symlink. However you might try changing to
unix extensions = yes
as your OSX may understand this too.From the page https://www.samba.org/samba/docs/man/manpages/smb.conf.5.html#UNIXEXTENSIONS
You may want to investigate the insecure wide links option more as you may want to turn that off to achieve the results you are after.
The above may still not work as you desire due to the way that many systems implement deleting a folder structure. Normally the sequence proceeds as
This is how the content of the target is deleted along with the symlink, but not the actual target folder.
Similarly when it is instructed to delete a symlinked file only the symlink is deleted. The issue with the symlinked folder structure is that the samba client sends the delete command to all of the content before instructing the server to delete the symlink to the folder.