From: Ralph Boehme Date: Thu, 6 Jun 2024 13:38:16 +0000 (+0200) Subject: smbd: consolidate fs capabilities code in vfswrap_fs_capabilities() X-Git-Tag: samba-4.21.5~16 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=37a74eb39a94aa54ec6d2262b1a7ca8016c5a2a2;p=thirdparty%2Fsamba.git smbd: consolidate fs capabilities code in vfswrap_fs_capabilities() This ensures the values we return via SMB_FS_ATTRIBUTE_INFORMATION is the same we use internally via conn->fs_capabilities. This deliberately preserves existing behaviour as much as possible and leaves possible improvements as a future excercize. Particularily FILE_VOLUME_QUOTAS is already set insided SMB_VFS_STATVFS() depending on backend filesystem flags which is probably the correct way to do it instead of just setting the capability when Samba was built with quota support. BUG: https://bugzilla.samba.org/show_bug.cgi?id=15822 Signed-off-by: Ralph Boehme Reviewed-by: David Disseldorp (cherry picked from commit deeca8ff176e7e9082cc0fcf48d7f981de2523c5) --- diff --git a/source3/modules/vfs_ceph.c b/source3/modules/vfs_ceph.c index fd450af16c2..20e1c204f18 100644 --- a/source3/modules/vfs_ceph.c +++ b/source3/modules/vfs_ceph.c @@ -377,8 +377,9 @@ static uint32_t cephwrap_fs_capabilities( struct vfs_handle_struct *handle, enum timestamp_set_resolution *p_ts_res) { - uint32_t caps = FILE_CASE_SENSITIVE_SEARCH | FILE_CASE_PRESERVED_NAMES; + uint32_t caps; + caps = SMB_VFS_NEXT_FS_CAPABILITIES(handle, p_ts_res); *p_ts_res = TIMESTAMP_SET_NT_OR_BETTER; return caps; diff --git a/source3/modules/vfs_default.c b/source3/modules/vfs_default.c index e0ebc7bd1a2..752906ba29a 100644 --- a/source3/modules/vfs_default.c +++ b/source3/modules/vfs_default.c @@ -177,6 +177,16 @@ static uint32_t vfswrap_fs_capabilities(struct vfs_handle_struct *handle, caps = statbuf.FsCapabilities; } +#if defined(HAVE_SYS_QUOTAS) + caps |= FILE_VOLUME_QUOTAS; +#endif + + if (lp_nt_acl_support(SNUM(conn))) { + caps |= FILE_PERSISTENT_ACLS; + } + + caps |= lp_parm_int(SNUM(conn), "share", "fake_fscaps", 0); + *p_ts_res = TIMESTAMP_SET_SECONDS; /* Work out what timestamp resolution we can diff --git a/source3/modules/vfs_glusterfs.c b/source3/modules/vfs_glusterfs.c index 00b4cdd4698..5729766a8d7 100644 --- a/source3/modules/vfs_glusterfs.c +++ b/source3/modules/vfs_glusterfs.c @@ -594,7 +594,9 @@ static int vfs_gluster_statvfs(struct vfs_handle_struct *handle, static uint32_t vfs_gluster_fs_capabilities(struct vfs_handle_struct *handle, enum timestamp_set_resolution *p_ts_res) { - uint32_t caps = FILE_CASE_SENSITIVE_SEARCH | FILE_CASE_PRESERVED_NAMES; + uint32_t caps; + + caps = SMB_VFS_NEXT_FS_CAPABILITIES(handle, p_ts_res); #ifdef HAVE_GFAPI_VER_6 caps |= FILE_SUPPORTS_SPARSE_FILES; diff --git a/source3/smbd/smb2_trans2.c b/source3/smbd/smb2_trans2.c index b57cb295a7c..2a253d65361 100644 --- a/source3/smbd/smb2_trans2.c +++ b/source3/smbd/smb2_trans2.c @@ -2041,7 +2041,6 @@ NTSTATUS smbd_do_qfsinfo(struct smbXsrv_connection *xconn, const char *fstype = lp_fstype(SNUM(conn)); const char *filename = NULL; const uint64_t bytes_per_sector = 512; - uint32_t additional_flags = 0; struct smb_filename smb_fname; SMB_STRUCT_STAT st; NTSTATUS status = NT_STATUS_OK; @@ -2172,24 +2171,9 @@ cBytesSector=%u, cUnitTotal=%u, cUnitAvail=%d\n", (unsigned int)st.st_ex_dev, (u case SMB_QUERY_FS_ATTRIBUTE_INFO: case SMB_FS_ATTRIBUTE_INFORMATION: - additional_flags = 0; -#if defined(HAVE_SYS_QUOTAS) - additional_flags |= FILE_VOLUME_QUOTAS; -#endif - - if(lp_nt_acl_support(SNUM(conn))) { - additional_flags |= FILE_PERSISTENT_ACLS; - } - - /* Capabilities are filled in at connection time through STATVFS call */ - additional_flags |= conn->fs_capabilities; - additional_flags |= lp_parm_int(conn->params->service, - "share", "fake_fscaps", - 0); - SIVAL(pdata,0,FILE_CASE_PRESERVED_NAMES|FILE_CASE_SENSITIVE_SEARCH| FILE_SUPPORTS_OBJECT_IDS|FILE_UNICODE_ON_DISK| - additional_flags); /* FS ATTRIBUTES */ + conn->fs_capabilities); /* FS ATTRIBUTES */ SIVAL(pdata,4,255); /* Max filename component length */ /* NOTE! the fstype must *not* be null terminated or win98 won't recognise it