4

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.

Justin Goeres
  • 63
  • 2
  • 4
  • 1
    Can you try to add the `linux` mount option? Otherwise there is the option to use `mfsymlinks` as client mount option, which will not implement a posix symlink but will create a file in the filesystem which describes the link and looks like a symlink to linux hosts that mounted with `mfsymlinks`, on Windows you will see a useless file =0). – Thomas Jul 22 '19 at 18:45
  • Did you ever figure this out? I'm seeing the same behavior from a Windows 10 client – Michael Sep 14 '22 at 23:07

1 Answers1

0

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.

Reid
  • 282
  • 3
  • 14
RalfFriedl
  • 3,008
  • 4
  • 12
  • 17
  • 2
    Are you sure about that? I changed the smb.conf the way you suggested, restarted samba on the server, and unmounted/remounted the share on the client, and I still get the same behavior as before (symlinks look like regular files). – Justin Goeres Jul 21 '19 at 00:15