]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
smbd: Prepare fdos_mode() for handling symlinks in smb2
authorVolker Lendecke <vl@samba.org>
Tue, 19 Nov 2024 14:35:58 +0000 (15:35 +0100)
committerRalph Boehme <slow@samba.org>
Fri, 22 Nov 2024 09:50:37 +0000 (09:50 +0000)
We should show all special files as NORMAL|REPARSE_POINT, except
symlinks for SMB1 Posix Extensions. IFREG and IFDIR are handled via
our xattr mechanisms.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
source3/smbd/dosmode.c

index f39f8a7d15bf0372bc4e2a1ffa1ebd00144c54b3..0de348883e493c689af43b7ca280590881f58ec6 100644 (file)
@@ -721,16 +721,28 @@ uint32_t fdos_mode(struct files_struct *fsp)
        }
 
        switch (fsp->fsp_name->st.st_ex_mode & S_IFMT) {
-       case S_IFLNK:
-               return FILE_ATTRIBUTE_NORMAL;
+       case S_IFREG:
+       case S_IFDIR:
                break;
-       case S_IFIFO:
-       case S_IFSOCK:
-       case S_IFBLK:
-       case S_IFCHR:
-               return FILE_ATTRIBUTE_NORMAL | FILE_ATTRIBUTE_REPARSE_POINT;
+       case S_IFLNK:
+               if (fsp->fsp_flags.posix_open &&
+                   !conn_using_smb2(fsp->conn->sconn)) {
+                       /*
+                        * SMB1 posix doesn't like the reparse point flag
+                        */
+                       result = FILE_ATTRIBUTE_NORMAL;
+               } else {
+                       /*
+                        * Everybody else wants to see symlinks as
+                        * reparse points
+                        */
+                       result = FILE_ATTRIBUTE_NORMAL |
+                                FILE_ATTRIBUTE_REPARSE_POINT;
+               }
+
                break;
        default:
+               return FILE_ATTRIBUTE_NORMAL|FILE_ATTRIBUTE_REPARSE_POINT;
                break;
        }