2

When creating a symbolic link on a samba share from one point to another point (on the same drive), the file holding the symbolic link gets messed up on other clients but not the original client.

For example, on the client making the link, the symbolic links works perfectly and is recognized by the original OS, even after remounting:

lrwxrwxrwx 1 g g       38 Mar 17 11:15 npm2 -> ../lib/node_modules/npm/bin/npm-cli.js

But, on the server or other clients, the link is a file with contents like this:

XSym
0038
36c91a46c3a5a86837deff259c6d0874
../lib/node_modules/npm/bin/npm-cli.js

... with permissions:

-rwxrw-r-- 1 z z     1067 Mar 17 11:15 npm2

So... basically... this is some kind of mounting error, or something, but is there any way I can use chmod to "meep" it into the original intended symbolic link? It would help a lot.

1 Answer 1

1

No, you cannot use chmod to change the file's fundamental type. But it's a file not because of any bugs – it's a file because the Samba server created it as a file, and that itself might simply be because the client actually asked it to create a file with those specific contents.

Regular SMB does not know anything about symlinks, and the most common SMB server (Windows) did not support symlinks for a long time either. As a result, various SMB clients invented ways to store symlinks as weirdly-shaped regular files.

The specific format you have is called Minshall+French symlinks, used by macOS and the Linux "cifs" kernel module – if the share is mounted with the mfsymlinks option, Linux recognizes the "XSym" marker and pretends that it's a symlink to client-side applications. So if one client uses this, all other clients must use the same option too.

Unfortunately, if you want to have real symlinks on the server, you will need to use SMBv1 (aka "NT1") and make sure the server and client both support "CIFS Unix Extensions". And note that this is not planned to work with the upcoming SMBv3 POSIX Extensions – the Samba developers have explicitly stated that they don't want the ability to create server-side symlinks to exist anymore (due to major security issues), and that when Samba gets support for POSIX features in SMBv3 it will continue to create those "special files".


As a different answer to the original question, it may be technically possible to use "debugfs" type tools to change a file into a symlink and back, but it heavily depends on the internals of that specific filesystem. (Some of them might store symlinks exactly like regular files, only differing in type bits... but others like NTFS might have an entirely incompatible format.)

But this is usually done only when repairing a heavily corrupted filesystem, not as part of normal operation. And of course it won't do anything good if the original "pseudo-symlink" file contains data in the MF format, since that's not the same format as your filesystem would internally use.

1
  • Thanks, I used vers=1.0 as a parameter the client mounting options, to get back original symlinks Commented Mar 17, 2020 at 15:53

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .