]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
vfs: Pass the RESOLVE_NO_XDEV from upper layers to openat2() syscall
authorSamuel Cabrero <scabrero@samba.org>
Fri, 14 Feb 2025 16:14:59 +0000 (17:14 +0100)
committerSamuel Cabrero <scabrero@samba.org>
Tue, 18 Nov 2025 08:03:32 +0000 (08:03 +0000)
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15805

Signed-off-by: Samuel Cabrero <scabrero@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
source3/modules/vfs_default.c

index 670c35c94cfbc7972fbcd70e3dd6d392bb4aec88..266fa87b3eddb1d513b8f596a3fbf65e85fde4e8 100644 (file)
@@ -628,7 +628,9 @@ static int vfswrap_openat(vfs_handle_struct *handle,
        SMB_ASSERT((dirfd != -1) || (smb_fname->base_name[0] == '/'));
 
        if (how->resolve & ~(VFS_OPEN_HOW_RESOLVE_NO_SYMLINKS |
-                            VFS_OPEN_HOW_WITH_BACKUP_INTENT)) {
+                            VFS_OPEN_HOW_WITH_BACKUP_INTENT |
+                            VFS_OPEN_HOW_RESOLVE_NO_XDEV))
+       {
                errno = ENOSYS;
                result = -1;
                goto out;
@@ -661,12 +663,20 @@ static int vfswrap_openat(vfs_handle_struct *handle,
        }
 #endif
 
-       if (how->resolve & VFS_OPEN_HOW_RESOLVE_NO_SYMLINKS) {
+       if (how->resolve & VFS_OPEN_HOW_RESOLVE_NO_SYMLINKS ||
+           how->resolve & VFS_OPEN_HOW_RESOLVE_NO_XDEV)
+       {
                struct open_how linux_how = {
                        .flags = flags,
                        .mode = mode,
-                       .resolve = RESOLVE_NO_SYMLINKS,
+                       .resolve = 0,
                };
+               if (how->resolve & VFS_OPEN_HOW_RESOLVE_NO_SYMLINKS) {
+                       linux_how.resolve |= RESOLVE_NO_SYMLINKS;
+               }
+               if (how->resolve & VFS_OPEN_HOW_RESOLVE_NO_XDEV) {
+                       linux_how.resolve |= RESOLVE_NO_XDEV;
+               }
 
                result = openat2(dirfd,
                                 smb_fname->base_name,
@@ -679,10 +689,13 @@ static int vfswrap_openat(vfs_handle_struct *handle,
                                 * openat2(), so indicate to
                                 * the callers that
                                 * VFS_OPEN_HOW_RESOLVE_NO_SYMLINKS
+                                * or VFS_OPEN_HOW_RESOLVE_NO_XDEV
                                 * would just be a waste of time.
                                 */
                                fsp->conn->open_how_resolve &=
                                        ~VFS_OPEN_HOW_RESOLVE_NO_SYMLINKS;
+                               fsp->conn->open_how_resolve &=
+                                       ~VFS_OPEN_HOW_RESOLVE_NO_XDEV;
                        }
                        goto out;
                }