vfs_gpfs: Use O_PATH for opening dirfd for stat with CAP_DAC_OVERRIDE
authorChristof Schmitt <cs@samba.org>
Thu, 26 Oct 2023 21:37:15 +0000 (14:37 -0700)
committerRalph Boehme <slow@samba.org>
Wed, 8 Nov 2023 17:40:37 +0000 (17:40 +0000)
Use O_PATH when available; this avoids the need for READ/LIST access on
that directory. Keep using O_RDONLY if the system does not have O_PATH.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15507

Signed-off-by: Christof Schmitt <cs@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
source3/modules/vfs_gpfs.c

index 1c11809fb1b2fb9b4f4c6668340694811b8b3edd..3d3d10905b484d3f01a3169462d1b7d1c90c9878 100644 (file)
@@ -1597,6 +1597,11 @@ static int stat_with_capability(struct vfs_handle_struct *handle,
        struct smb_filename *dir_name = NULL;
        struct smb_filename *rel_name = NULL;
        int ret = -1;
+#ifdef O_PATH
+       int open_flags = O_PATH;
+#else
+       int open_flags = O_RDONLY;
+#endif
 
        status = SMB_VFS_PARENT_PATHNAME(handle->conn,
                                         talloc_tos(),
@@ -1608,7 +1613,7 @@ static int stat_with_capability(struct vfs_handle_struct *handle,
                return -1;
        }
 
-       fd = open(dir_name->base_name, O_RDONLY, 0);
+       fd = open(dir_name->base_name, open_flags, 0);
        if (fd == -1) {
                TALLOC_FREE(dir_name);
                return -1;