vfs_gpfs: Use O_PATH for opening dirfd for stat with CAP_DAC_OVERRIDE
[samba.git] / source3 / modules / vfs_gpfs.c
index 93748eab54c01a86428e46b1ff94142c36f930b8..f8ccbca103823c69fb82e4bd2bc3c745ed79882c 100644 (file)
@@ -1603,6 +1603,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(),
@@ -1614,7 +1619,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;