Samba – Symlinks look like regular files on samba shares

cifsfile-sharingsambasmb-confsymlink

Symlinks on my samba share aren't behaving the way I want them to – specifically, the links look like duplicate regular files to the client machine. This used to work (i.e. symlinks on the server looked like symlinks on the client), but at some point it stopped. So I assume it's related to the samba version somehow, but I've never found a combination that works.

Is it even possible to have symlinks work "like symlinks" on samba clients? If so, how?

Here's my setup.

Server: Synology NAS serving up a share via samba

------server smb.conf-------
[global]
unix extensions=no
follow symlinks=yes
wide links=yes
allow insecure wide links=yes

Client: Ubuntu 16.04 machine, mounting the share with the following command

sudo mount -t cifs -o vers=3.0 -o user=<myuser> //server/sharename /mnt/mountpoint

With the share mounted, here's what I do next:

On the server

$ echo "HELLO WORLD" > file-created-on-server.txt
$ ln -s file-created-on-server.txt symlink-created-on-server.txt
$ ls -iog
75852 -rwxrwxrwx+ 1 12 Jul 19 20:16 file-created-on-server.txt
75859 lrwxrwxrwx+ 1 25 Jul 19 20:53 symlink-created-on-server.txt -> file-created-on-server.txt

So obviously that's a symlink.
However, if I then do…

On the client

$ ls -iog
total 8
75852 -rwxr-xr-x 1 12 Jul 19 21:16 file-created-on-server.txt
75852 -rwxr-xr-x 1 12 Jul 19 21:16 symlink-created-on-server.txt

I expected symlink-created-on-server.txt to look like a symlink. But it doesn't. It looks like a duplicate of the original file – they even have the same inode number on the client, but not the server.

What is going on here? Is there a way to make symlinks just look like symlinks? I've read things about security issues with samba and symlinks, and I imagine that might be the reason the behavior changed, but I've never found a clear explanation – and in this case I don't care about the security implications.

Best Answer

You have

unix extensions=no
follow symlinks=yes

That means that

  1. The server won't report links
  2. The server will follow the symlink.

The second option alone is probably enough to treat the symlink like a regular link, in other words as two names that refer to the same file.