From: Volker Lendecke Date: Wed, 28 Jan 2026 14:57:37 +0000 (+0100) Subject: vfs: Change SMB_VFS_GET_QUOTA to take a fsp instead of a name X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=34d3b324f37c023c0b8c87f7a1f4feb18941e005;p=thirdparty%2Fsamba.git vfs: Change SMB_VFS_GET_QUOTA to take a fsp instead of a name Signed-off-by: Volker Lendecke Reviewed-by: Anoop C S --- diff --git a/examples/VFS/skel_opaque.c b/examples/VFS/skel_opaque.c index 891f28427d6..ea54fd79bd1 100644 --- a/examples/VFS/skel_opaque.c +++ b/examples/VFS/skel_opaque.c @@ -58,10 +58,10 @@ static uint64_t skel_disk_free(vfs_handle_struct *handle, } static int skel_get_quota(vfs_handle_struct *handle, - const struct smb_filename *smb_fname, - enum SMB_QUOTA_TYPE qtype, - unid_t id, - SMB_DISK_QUOTA *dq) + struct files_struct *fsp, + enum SMB_QUOTA_TYPE qtype, + unid_t id, + SMB_DISK_QUOTA *dq) { errno = ENOSYS; return -1; diff --git a/examples/VFS/skel_transparent.c b/examples/VFS/skel_transparent.c index 091c7388860..da3897d0e9e 100644 --- a/examples/VFS/skel_transparent.c +++ b/examples/VFS/skel_transparent.c @@ -58,12 +58,12 @@ static uint64_t skel_disk_free(vfs_handle_struct *handle, } static int skel_get_quota(vfs_handle_struct *handle, - const struct smb_filename *smb_fname, - enum SMB_QUOTA_TYPE qtype, - unid_t id, - SMB_DISK_QUOTA *dq) + struct files_struct *fsp, + enum SMB_QUOTA_TYPE qtype, + unid_t id, + SMB_DISK_QUOTA *dq) { - return SMB_VFS_NEXT_GET_QUOTA(handle, smb_fname, qtype, id, dq); + return SMB_VFS_NEXT_GET_QUOTA(handle, fsp, qtype, id, dq); } static int skel_set_quota(vfs_handle_struct *handle, enum SMB_QUOTA_TYPE qtype, diff --git a/source3/include/vfs.h b/source3/include/vfs.h index 9d8e1af6575..c17e41fa0ee 100644 --- a/source3/include/vfs.h +++ b/source3/include/vfs.h @@ -401,6 +401,7 @@ * Version 53 - Change DISK_FREE to take a fsp instead of a name * Version 53 - Add fstatvfs * Version 53 - Remove statvfs + * Version 53 - Change GET_QUOTA to take a fsp instead of a name */ #define SMB_VFS_INTERFACE_VERSION 53 @@ -992,10 +993,10 @@ struct vfs_fn_pointers { uint64_t *dfree, uint64_t *dsize); int (*get_quota_fn)(struct vfs_handle_struct *handle, - const struct smb_filename *smb_fname, - enum SMB_QUOTA_TYPE qtype, - unid_t id, - SMB_DISK_QUOTA *qt); + struct files_struct *fsp, + enum SMB_QUOTA_TYPE qtype, + unid_t id, + SMB_DISK_QUOTA *qt); int (*set_quota_fn)(struct vfs_handle_struct *handle, enum SMB_QUOTA_TYPE qtype, unid_t id, SMB_DISK_QUOTA *qt); int (*get_shadow_copy_data_fn)(struct vfs_handle_struct *handle, struct files_struct *fsp, struct shadow_copy_data *shadow_copy_data, bool labels); int (*fstatvfs_fn)(struct vfs_handle_struct *handle, @@ -1447,10 +1448,10 @@ uint64_t smb_vfs_call_disk_free(struct vfs_handle_struct *handle, uint64_t *dfree, uint64_t *dsize); int smb_vfs_call_get_quota(struct vfs_handle_struct *handle, - const struct smb_filename *smb_filename, - enum SMB_QUOTA_TYPE qtype, - unid_t id, - SMB_DISK_QUOTA *qt); + struct files_struct *fsp, + enum SMB_QUOTA_TYPE qtype, + unid_t id, + SMB_DISK_QUOTA *qt); int smb_vfs_call_set_quota(struct vfs_handle_struct *handle, enum SMB_QUOTA_TYPE qtype, unid_t id, SMB_DISK_QUOTA *qt); @@ -1880,10 +1881,10 @@ uint64_t vfs_not_implemented_disk_free(vfs_handle_struct *handle, uint64_t *dfree, uint64_t *dsize); int vfs_not_implemented_get_quota(vfs_handle_struct *handle, - const struct smb_filename *smb_fname, - enum SMB_QUOTA_TYPE qtype, - unid_t id, - SMB_DISK_QUOTA *dq); + struct files_struct *fsp, + enum SMB_QUOTA_TYPE qtype, + unid_t id, + SMB_DISK_QUOTA *dq); int vfs_not_implemented_set_quota(vfs_handle_struct *handle, enum SMB_QUOTA_TYPE qtype, unid_t id, SMB_DISK_QUOTA *dq); diff --git a/source3/include/vfs_macros.h b/source3/include/vfs_macros.h index f6c14338ad5..5d41b16033e 100644 --- a/source3/include/vfs_macros.h +++ b/source3/include/vfs_macros.h @@ -46,10 +46,11 @@ smb_vfs_call_disk_free( \ (handle)->next, (fsp), (bsize), (dfree), (dsize)) -#define SMB_VFS_GET_QUOTA(conn, smb_fname, qtype, id, qt) \ - smb_vfs_call_get_quota((conn)->vfs_handles, (smb_fname), (qtype), (id), (qt)) -#define SMB_VFS_NEXT_GET_QUOTA(handle, smb_fname, qtype, id, qt) \ - smb_vfs_call_get_quota((handle)->next, (smb_fname), (qtype), (id), (qt)) +#define SMB_VFS_GET_QUOTA(fsp, qtype, id, qt) \ + smb_vfs_call_get_quota( \ + (fsp)->conn->vfs_handles, (fsp), (qtype), (id), (qt)) +#define SMB_VFS_NEXT_GET_QUOTA(handle, fsp, qtype, id, qt) \ + smb_vfs_call_get_quota((handle)->next, (fsp), (qtype), (id), (qt)) #define SMB_VFS_SET_QUOTA(conn, qtype, id, qt) \ smb_vfs_call_set_quota((conn)->vfs_handles, (qtype), (id), (qt)) diff --git a/source3/modules/vfs_cap.c b/source3/modules/vfs_cap.c index 9957998d2d9..b6e9b748bd8 100644 --- a/source3/modules/vfs_cap.c +++ b/source3/modules/vfs_cap.c @@ -66,30 +66,42 @@ static uint64_t cap_disk_free(vfs_handle_struct *handle, } static int cap_get_quota(vfs_handle_struct *handle, - const struct smb_filename *smb_fname, - enum SMB_QUOTA_TYPE qtype, - unid_t id, - SMB_DISK_QUOTA *dq) + struct files_struct *fsp, + enum SMB_QUOTA_TYPE qtype, + unid_t id, + SMB_DISK_QUOTA *dq) { + struct smb_filename *smb_fname = fsp->fsp_name; char *cappath = capencode(talloc_tos(), smb_fname->base_name); struct smb_filename *cap_smb_fname = NULL; + NTSTATUS status; + int ret; if (!cappath) { errno = ENOMEM; return -1; } - cap_smb_fname = synthetic_smb_fname(talloc_tos(), - cappath, - NULL, - NULL, - smb_fname->twrp, - smb_fname->flags); - if (cap_smb_fname == NULL) { - TALLOC_FREE(cappath); - errno = ENOMEM; + status = synthetic_pathref(talloc_tos(), + fsp->conn->cwd_fsp, + cappath, + NULL, + NULL, + smb_fname->twrp, + smb_fname->flags, + &cap_smb_fname); + TALLOC_FREE(cappath); + if (!NT_STATUS_IS_OK(status)) { + errno = map_errno_from_nt_status(status); return -1; } - return SMB_VFS_NEXT_GET_QUOTA(handle, cap_smb_fname, qtype, id, dq); + ret = SMB_VFS_NEXT_GET_QUOTA( + handle, cap_smb_fname->fsp, qtype, id, dq); + { + int err = errno; + TALLOC_FREE(cap_smb_fname); + errno = err; + } + return ret; } static struct dirent * diff --git a/source3/modules/vfs_ceph_snapshots.c b/source3/modules/vfs_ceph_snapshots.c index 7fa03ceb5fc..cf2dfdc2d5d 100644 --- a/source3/modules/vfs_ceph_snapshots.c +++ b/source3/modules/vfs_ceph_snapshots.c @@ -1402,16 +1402,18 @@ static uint64_t ceph_snap_gmt_disk_free(vfs_handle_struct *handle, } static int ceph_snap_gmt_get_quota(vfs_handle_struct *handle, - const struct smb_filename *csmb_fname, - enum SMB_QUOTA_TYPE qtype, - unid_t id, - SMB_DISK_QUOTA *dq) + struct files_struct *fsp, + enum SMB_QUOTA_TYPE qtype, + unid_t id, + SMB_DISK_QUOTA *dq) { + struct smb_filename *csmb_fname = fsp->fsp_name; time_t timestamp = 0; char stripped[PATH_MAX + 1]; char conv[PATH_MAX + 1]; int ret; struct smb_filename *new_fname; + NTSTATUS status; int saved_errno; ret = ceph_snap_gmt_strip_snapshot(handle, @@ -1422,7 +1424,7 @@ static int ceph_snap_gmt_get_quota(vfs_handle_struct *handle, return -1; } if (timestamp == 0) { - return SMB_VFS_NEXT_GET_QUOTA(handle, csmb_fname, qtype, id, dq); + return SMB_VFS_NEXT_GET_QUOTA(handle, fsp, qtype, id, dq); } ret = ceph_snap_gmt_convert(handle, stripped, timestamp, conv, sizeof(conv)); @@ -1430,14 +1432,21 @@ static int ceph_snap_gmt_get_quota(vfs_handle_struct *handle, errno = -ret; return -1; } - new_fname = cp_smb_filename(talloc_tos(), csmb_fname); - if (new_fname == NULL) { - errno = ENOMEM; + + status = synthetic_pathref(talloc_tos(), + fsp->conn->cwd_fsp, + conv, + csmb_fname->stream_name, + NULL, + csmb_fname->twrp, + csmb_fname->flags, + &new_fname); + if (!NT_STATUS_IS_OK(status)) { + errno = map_errno_from_nt_status(status); return -1; } - new_fname->base_name = conv; - ret = SMB_VFS_NEXT_GET_QUOTA(handle, new_fname, qtype, id, dq); + ret = SMB_VFS_NEXT_GET_QUOTA(handle, new_fname->fsp, qtype, id, dq); saved_errno = errno; TALLOC_FREE(new_fname); errno = saved_errno; diff --git a/source3/modules/vfs_default.c b/source3/modules/vfs_default.c index 5fcddbdc474..da41eefaa5d 100644 --- a/source3/modules/vfs_default.c +++ b/source3/modules/vfs_default.c @@ -120,12 +120,13 @@ static uint64_t vfswrap_disk_free(vfs_handle_struct *handle, } static int vfswrap_get_quota(struct vfs_handle_struct *handle, - const struct smb_filename *smb_fname, - enum SMB_QUOTA_TYPE qtype, - unid_t id, - SMB_DISK_QUOTA *qt) + struct files_struct *fsp, + enum SMB_QUOTA_TYPE qtype, + unid_t id, + SMB_DISK_QUOTA *qt) { #ifdef HAVE_SYS_QUOTAS + struct smb_filename *smb_fname = fsp->fsp_name; int result; START_PROFILE_X(SNUM(handle->conn), syscall_get_quota); diff --git a/source3/modules/vfs_default_quota.c b/source3/modules/vfs_default_quota.c index 2365f9d196b..612a65f28b4 100644 --- a/source3/modules/vfs_default_quota.c +++ b/source3/modules/vfs_default_quota.c @@ -93,15 +93,14 @@ lp_parm_bool(SNUM((handle)->conn),DEFAULT_QUOTA_NAME,"gid nolimit",DEFAULT_QUOTA_GID_NOLIMIT_DEFAULT) static int default_quota_get_quota(vfs_handle_struct *handle, - const struct smb_filename *smb_fname, - enum SMB_QUOTA_TYPE qtype, - unid_t id, - SMB_DISK_QUOTA *dq) + struct files_struct *fsp, + enum SMB_QUOTA_TYPE qtype, + unid_t id, + SMB_DISK_QUOTA *dq) { int ret = -1; - if ((ret = SMB_VFS_NEXT_GET_QUOTA(handle, smb_fname, - qtype, id, dq)) != 0) { + if ((ret = SMB_VFS_NEXT_GET_QUOTA(handle, fsp, qtype, id, dq)) != 0) { return ret; } @@ -127,8 +126,11 @@ static int default_quota_get_quota(vfs_handle_struct *handle, unid_t qid; uint32_t qflags = dq->qflags; qid.uid = DEFAULT_QUOTA_UID(handle); - SMB_VFS_NEXT_GET_QUOTA(handle, smb_fname, - SMB_USER_QUOTA_TYPE, qid, dq); + SMB_VFS_NEXT_GET_QUOTA(handle, + fsp, + SMB_USER_QUOTA_TYPE, + qid, + dq); dq->qflags = qflags; } break; @@ -138,9 +140,11 @@ static int default_quota_get_quota(vfs_handle_struct *handle, unid_t qid; uint32_t qflags = dq->qflags; qid.gid = DEFAULT_QUOTA_GID(handle); - SMB_VFS_NEXT_GET_QUOTA(handle, smb_fname, + SMB_VFS_NEXT_GET_QUOTA(handle, + fsp, SMB_GROUP_QUOTA_TYPE, - qid, dq); + qid, + dq); dq->qflags = qflags; } break; diff --git a/source3/modules/vfs_fake_dfq.c b/source3/modules/vfs_fake_dfq.c index 92b0e6e3be7..84aace8b92f 100644 --- a/source3/modules/vfs_fake_dfq.c +++ b/source3/modules/vfs_fake_dfq.c @@ -28,10 +28,10 @@ #define DBGC_CLASS DBGC_VFS static int dfq_get_quota(struct vfs_handle_struct *handle, - const struct smb_filename *smb_fname, - enum SMB_QUOTA_TYPE qtype, - unid_t id, - SMB_DISK_QUOTA *qt); + struct files_struct *fsp, + enum SMB_QUOTA_TYPE qtype, + unid_t id, + SMB_DISK_QUOTA *qt); static uint64_t dfq_load_param(int snum, const char *path, const char *section, const char *param, uint64_t def_val) @@ -95,11 +95,12 @@ static uint64_t dfq_disk_free(vfs_handle_struct *handle, } static int dfq_get_quota(struct vfs_handle_struct *handle, - const struct smb_filename *smb_fname, - enum SMB_QUOTA_TYPE qtype, - unid_t id, - SMB_DISK_QUOTA *qt) + struct files_struct *fsp, + enum SMB_QUOTA_TYPE qtype, + unid_t id, + SMB_DISK_QUOTA *qt) { + struct smb_filename *smb_fname = fsp->fsp_name; int rc = 0; int save_errno; char *section = NULL; @@ -178,7 +179,7 @@ static int dfq_get_quota(struct vfs_handle_struct *handle, goto out; dflt: - rc = SMB_VFS_NEXT_GET_QUOTA(handle, smb_fname, qtype, id, qt); + rc = SMB_VFS_NEXT_GET_QUOTA(handle, fsp, qtype, id, qt); out: save_errno = errno; diff --git a/source3/modules/vfs_full_audit.c b/source3/modules/vfs_full_audit.c index 1cb66b03dc0..1c46d32dec5 100644 --- a/source3/modules/vfs_full_audit.c +++ b/source3/modules/vfs_full_audit.c @@ -834,20 +834,20 @@ static uint64_t smb_full_audit_disk_free(vfs_handle_struct *handle, } static int smb_full_audit_get_quota(struct vfs_handle_struct *handle, - const struct smb_filename *smb_fname, - enum SMB_QUOTA_TYPE qtype, - unid_t id, - SMB_DISK_QUOTA *qt) + struct files_struct *fsp, + enum SMB_QUOTA_TYPE qtype, + unid_t id, + SMB_DISK_QUOTA *qt) { int result; - result = SMB_VFS_NEXT_GET_QUOTA(handle, smb_fname, qtype, id, qt); + result = SMB_VFS_NEXT_GET_QUOTA(handle, fsp, qtype, id, qt); do_log(SMB_VFS_OP_GET_QUOTA, errmsg_unix(result), handle, "%s", - smb_fname_str_do_log(handle->conn, smb_fname)); + smb_fname_str_do_log(handle->conn, fsp->fsp_name)); return result; } diff --git a/source3/modules/vfs_glusterfs.c b/source3/modules/vfs_glusterfs.c index 765baf6dd49..1adf62e9ff1 100644 --- a/source3/modules/vfs_glusterfs.c +++ b/source3/modules/vfs_glusterfs.c @@ -546,10 +546,10 @@ static uint64_t vfs_gluster_disk_free(struct vfs_handle_struct *handle, } static int vfs_gluster_get_quota(struct vfs_handle_struct *handle, - const struct smb_filename *smb_fname, - enum SMB_QUOTA_TYPE qtype, - unid_t id, - SMB_DISK_QUOTA *qt) + struct files_struct *fsp, + enum SMB_QUOTA_TYPE qtype, + unid_t id, + SMB_DISK_QUOTA *qt) { errno = ENOSYS; return -1; diff --git a/source3/modules/vfs_gpfs.c b/source3/modules/vfs_gpfs.c index 9b92eb97446..75c87ef159b 100644 --- a/source3/modules/vfs_gpfs.c +++ b/source3/modules/vfs_gpfs.c @@ -2391,10 +2391,10 @@ static uint64_t vfs_gpfs_disk_free(vfs_handle_struct *handle, } static int vfs_gpfs_get_quota(vfs_handle_struct *handle, - const struct smb_filename *smb_fname, - enum SMB_QUOTA_TYPE qtype, - unid_t id, - SMB_DISK_QUOTA *dq) + struct files_struct *fsp, + enum SMB_QUOTA_TYPE qtype, + unid_t id, + SMB_DISK_QUOTA *dq) { switch(qtype) { /* @@ -2412,8 +2412,8 @@ static int vfs_gpfs_get_quota(vfs_handle_struct *handle, errno = ENOSYS; return -1; default: - return SMB_VFS_NEXT_GET_QUOTA(handle, smb_fname, - qtype, id, dq); + return SMB_VFS_NEXT_GET_QUOTA( + handle, fsp, qtype, id, dq); } } diff --git a/source3/modules/vfs_not_implemented.c b/source3/modules/vfs_not_implemented.c index a60b262941c..33d610d3d49 100644 --- a/source3/modules/vfs_not_implemented.c +++ b/source3/modules/vfs_not_implemented.c @@ -55,10 +55,10 @@ uint64_t vfs_not_implemented_disk_free(vfs_handle_struct *handle, _PUBLIC_ int vfs_not_implemented_get_quota(vfs_handle_struct *handle, - const struct smb_filename *smb_fname, - enum SMB_QUOTA_TYPE qtype, - unid_t id, - SMB_DISK_QUOTA *dq) + struct files_struct *fsp, + enum SMB_QUOTA_TYPE qtype, + unid_t id, + SMB_DISK_QUOTA *dq) { errno = ENOSYS; return -1; diff --git a/source3/modules/vfs_shadow_copy2.c b/source3/modules/vfs_shadow_copy2.c index 5a386f98191..2c1d3072d49 100644 --- a/source3/modules/vfs_shadow_copy2.c +++ b/source3/modules/vfs_shadow_copy2.c @@ -2678,17 +2678,19 @@ static uint64_t shadow_copy2_disk_free(vfs_handle_struct *handle, } static int shadow_copy2_get_quota(vfs_handle_struct *handle, - const struct smb_filename *smb_fname, - enum SMB_QUOTA_TYPE qtype, - unid_t id, - SMB_DISK_QUOTA *dq) + struct files_struct *fsp, + enum SMB_QUOTA_TYPE qtype, + unid_t id, + SMB_DISK_QUOTA *dq) { + struct smb_filename *smb_fname = fsp->fsp_name; time_t timestamp = 0; char *stripped = NULL; int ret; int saved_errno = 0; char *conv; struct smb_filename *conv_smb_fname = NULL; + NTSTATUS status; if (!shadow_copy2_strip_snapshot(talloc_tos(), handle, @@ -2698,25 +2700,31 @@ static int shadow_copy2_get_quota(vfs_handle_struct *handle, return -1; } if (timestamp == 0) { - return SMB_VFS_NEXT_GET_QUOTA(handle, smb_fname, qtype, id, dq); + return SMB_VFS_NEXT_GET_QUOTA(handle, fsp, qtype, id, dq); } conv = shadow_copy2_convert(talloc_tos(), handle, stripped, timestamp); TALLOC_FREE(stripped); if (conv == NULL) { + errno = ENOMEM; return -1; } - conv_smb_fname = synthetic_smb_fname(talloc_tos(), - conv, - NULL, - NULL, - 0, - smb_fname->flags); - if (conv_smb_fname == NULL) { + + status = synthetic_pathref(talloc_tos(), + fsp->conn->cwd_fsp, + conv, + NULL, + NULL, + 0, + smb_fname->flags, + &conv_smb_fname); + if (!NT_STATUS_IS_OK(status)) { TALLOC_FREE(conv); + errno = map_errno_from_nt_status(status); return -1; } - ret = SMB_VFS_NEXT_GET_QUOTA(handle, conv_smb_fname, qtype, id, dq); + ret = SMB_VFS_NEXT_GET_QUOTA( + handle, conv_smb_fname->fsp, qtype, id, dq); if (ret == -1) { saved_errno = errno; diff --git a/source3/modules/vfs_snapper.c b/source3/modules/vfs_snapper.c index f66659f5795..3c4f19abcd7 100644 --- a/source3/modules/vfs_snapper.c +++ b/source3/modules/vfs_snapper.c @@ -2529,24 +2529,26 @@ static uint64_t snapper_gmt_disk_free(vfs_handle_struct *handle, } static int snapper_gmt_get_quota(vfs_handle_struct *handle, - const struct smb_filename *smb_fname, - enum SMB_QUOTA_TYPE qtype, - unid_t id, - SMB_DISK_QUOTA *dq) + struct files_struct *fsp, + enum SMB_QUOTA_TYPE qtype, + unid_t id, + SMB_DISK_QUOTA *dq) { + struct smb_filename *smb_fname = fsp->fsp_name; time_t timestamp = 0; char *stripped = NULL; int ret; int saved_errno = 0; char *conv = NULL; struct smb_filename *conv_smb_fname = NULL; + NTSTATUS status; if (!snapper_gmt_strip_snapshot(talloc_tos(), handle, smb_fname, ×tamp, &stripped)) { return -1; } if (timestamp == 0) { - return SMB_VFS_NEXT_GET_QUOTA(handle, smb_fname, qtype, id, dq); + return SMB_VFS_NEXT_GET_QUOTA(handle, fsp, qtype, id, dq); } conv = snapper_gmt_convert(talloc_tos(), handle, stripped, timestamp); @@ -2554,19 +2556,23 @@ static int snapper_gmt_get_quota(vfs_handle_struct *handle, if (conv == NULL) { return -1; } - conv_smb_fname = synthetic_smb_fname(talloc_tos(), - conv, - NULL, - NULL, - 0, - smb_fname->flags); + + status = synthetic_pathref(talloc_tos(), + fsp->conn->cwd_fsp, + conv, + NULL, + NULL, + 0, + smb_fname->flags, + &conv_smb_fname); TALLOC_FREE(conv); - if (conv_smb_fname == NULL) { - errno = ENOMEM; + if (!NT_STATUS_IS_OK(status)) { + errno = map_errno_from_nt_status(status); return -1; } - ret = SMB_VFS_NEXT_GET_QUOTA(handle, conv_smb_fname, qtype, id, dq); + ret = SMB_VFS_NEXT_GET_QUOTA( + handle, conv_smb_fname->fsp, qtype, id, dq); if (ret == -1) { saved_errno = errno; diff --git a/source3/modules/vfs_time_audit.c b/source3/modules/vfs_time_audit.c index ae01a02e108..73594c4bebf 100644 --- a/source3/modules/vfs_time_audit.c +++ b/source3/modules/vfs_time_audit.c @@ -199,24 +199,24 @@ static uint64_t smb_time_audit_disk_free(vfs_handle_struct *handle, } static int smb_time_audit_get_quota(struct vfs_handle_struct *handle, - const struct smb_filename *smb_fname, - enum SMB_QUOTA_TYPE qtype, - unid_t id, - SMB_DISK_QUOTA *qt) + struct files_struct *fsp, + enum SMB_QUOTA_TYPE qtype, + unid_t id, + SMB_DISK_QUOTA *qt) { int result; struct timespec ts1,ts2; double timediff; clock_gettime_mono(&ts1); - result = SMB_VFS_NEXT_GET_QUOTA(handle, smb_fname, qtype, id, qt); + result = SMB_VFS_NEXT_GET_QUOTA(handle, fsp, qtype, id, qt); clock_gettime_mono(&ts2); timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9; if (timediff > audit_timeout) { smb_time_audit_log_fname("get_quota", - timediff, - smb_fname->base_name); + timediff, + fsp->fsp_name->base_name); } return result; } diff --git a/source3/smbd/ntquotas.c b/source3/smbd/ntquotas.c index affd7d58f81..0b8675d0ec5 100644 --- a/source3/smbd/ntquotas.c +++ b/source3/smbd/ntquotas.c @@ -66,6 +66,7 @@ NTSTATUS vfs_get_ntquota(files_struct *fsp, enum SMB_QUOTA_TYPE qtype, unid_t id; struct smb_filename *smb_fname_cwd = NULL; int saved_errno = 0; + NTSTATUS status; ZERO_STRUCT(D); @@ -84,12 +85,18 @@ NTSTATUS vfs_get_ntquota(files_struct *fsp, enum SMB_QUOTA_TYPE qtype, return NT_STATUS_NO_SUCH_USER; } - smb_fname_cwd = cp_smb_basename(talloc_tos(), "."); - if (smb_fname_cwd == NULL) { - return NT_STATUS_NO_MEMORY; + /* + * SMB_VFS_GET_QUOTA needs a "real" fsp, not a fake file one. + */ + status = openat_pathref_fsp_dot(talloc_tos(), + fsp->conn->cwd_fsp, + 0, + &smb_fname_cwd); + if (!NT_STATUS_IS_OK(status)) { + return status; } - ret = SMB_VFS_GET_QUOTA(fsp->conn, smb_fname_cwd, qtype, id, &D); + ret = SMB_VFS_GET_QUOTA(smb_fname_cwd->fsp, qtype, id, &D); if (ret == -1) { saved_errno = errno; } diff --git a/source3/smbd/quotas.c b/source3/smbd/quotas.c index e73e2982c1c..e9f11cfb9b7 100644 --- a/source3/smbd/quotas.c +++ b/source3/smbd/quotas.c @@ -383,8 +383,7 @@ bool disk_quotas(connection_struct *conn, */ ZERO_STRUCT(D); id.uid = -1; - r = SMB_VFS_GET_QUOTA(conn, fname, SMB_USER_FS_QUOTA_TYPE, - id, &D); + r = SMB_VFS_GET_QUOTA(fsp, SMB_USER_FS_QUOTA_TYPE, id, &D); if (r == -1 && errno != ENOSYS) { goto try_group_quota; } @@ -405,14 +404,12 @@ bool disk_quotas(connection_struct *conn, id.uid = fname->st.st_ex_uid; become_root(); - r = SMB_VFS_GET_QUOTA(conn, fname, - SMB_USER_QUOTA_TYPE, id, &D); + r = SMB_VFS_GET_QUOTA(fsp, SMB_USER_QUOTA_TYPE, id, &D); save_errno = errno; unbecome_root(); errno = save_errno; } else { - r = SMB_VFS_GET_QUOTA(conn, fname, - SMB_USER_QUOTA_TYPE, id, &D); + r = SMB_VFS_GET_QUOTA(fsp, SMB_USER_QUOTA_TYPE, id, &D); } if (r == -1) { @@ -449,8 +446,7 @@ try_group_quota: */ ZERO_STRUCT(D); id.gid = -1; - r = SMB_VFS_GET_QUOTA(conn, fname, SMB_GROUP_FS_QUOTA_TYPE, - id, &D); + r = SMB_VFS_GET_QUOTA(fsp, SMB_GROUP_FS_QUOTA_TYPE, id, &D); if (r == -1 && errno != ENOSYS) { return false; } @@ -470,13 +466,11 @@ try_group_quota: fname->st.st_ex_mode & S_ISGID) { id.gid = fname->st.st_ex_gid; become_root(); - r = SMB_VFS_GET_QUOTA(conn, fname, SMB_GROUP_QUOTA_TYPE, id, - &D); + r = SMB_VFS_GET_QUOTA(fsp, SMB_GROUP_QUOTA_TYPE, id, &D); unbecome_root(); } else { id.gid = getegid(); - r = SMB_VFS_GET_QUOTA(conn, fname, SMB_GROUP_QUOTA_TYPE, id, - &D); + r = SMB_VFS_GET_QUOTA(fsp, SMB_GROUP_QUOTA_TYPE, id, &D); } if (r == -1) { diff --git a/source3/smbd/vfs.c b/source3/smbd/vfs.c index 07997472c98..f6a36eab2d8 100644 --- a/source3/smbd/vfs.c +++ b/source3/smbd/vfs.c @@ -1452,13 +1452,13 @@ uint64_t smb_vfs_call_disk_free(struct vfs_handle_struct *handle, } int smb_vfs_call_get_quota(struct vfs_handle_struct *handle, - const struct smb_filename *smb_fname, - enum SMB_QUOTA_TYPE qtype, - unid_t id, - SMB_DISK_QUOTA *qt) + struct files_struct *fsp, + enum SMB_QUOTA_TYPE qtype, + unid_t id, + SMB_DISK_QUOTA *qt) { VFS_FIND(get_quota); - return handle->fns->get_quota_fn(handle, smb_fname, qtype, id, qt); + return handle->fns->get_quota_fn(handle, fsp, qtype, id, qt); } int smb_vfs_call_set_quota(struct vfs_handle_struct *handle,