diff options
author | Jeremy Allison <jra@samba.org> | 2017-06-01 11:45:25 -0700 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2017-06-18 02:49:25 +0200 |
commit | 0da76414fdc6a0aacea6282a76b384a702615408 (patch) | |
tree | e762b30e8ffbe21577be8f6d65dd2f0480787d82 | |
parent | 0037815453fa6141d3c0325c3ab197326324ab53 (diff) | |
download | samba-0da76414fdc6a0aacea6282a76b384a702615408.tar.gz |
s3: VFS: Change SMB_VFS_GET_QUOTA to use const struct smb_filename * instead of const char *.
We need to migrate all pathname based VFS calls to use a struct
to finish modernising the VFS with extra timestamp and flags parameters.
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Richard Sharpe <realrichardsharpe@gmail.com>
-rw-r--r-- | examples/VFS/skel_opaque.c | 8 | ||||
-rw-r--r-- | examples/VFS/skel_transparent.c | 10 | ||||
-rw-r--r-- | source3/include/vfs.h | 18 | ||||
-rw-r--r-- | source3/include/vfs_macros.h | 8 | ||||
-rw-r--r-- | source3/modules/vfs_cap.c | 23 | ||||
-rw-r--r-- | source3/modules/vfs_ceph.c | 6 | ||||
-rw-r--r-- | source3/modules/vfs_default.c | 10 | ||||
-rw-r--r-- | source3/modules/vfs_default_quota.c | 17 | ||||
-rw-r--r-- | source3/modules/vfs_fake_dfq.c | 20 | ||||
-rw-r--r-- | source3/modules/vfs_full_audit.c | 11 | ||||
-rw-r--r-- | source3/modules/vfs_glusterfs.c | 7 | ||||
-rw-r--r-- | source3/modules/vfs_gpfs.c | 11 | ||||
-rw-r--r-- | source3/modules/vfs_shadow_copy2.c | 31 | ||||
-rw-r--r-- | source3/modules/vfs_snapper.c | 46 | ||||
-rw-r--r-- | source3/modules/vfs_time_audit.c | 12 | ||||
-rw-r--r-- | source3/smbd/ntquotas.c | 20 | ||||
-rw-r--r-- | source3/smbd/quotas.c | 10 | ||||
-rw-r--r-- | source3/smbd/vfs.c | 10 |
18 files changed, 187 insertions, 91 deletions
diff --git a/examples/VFS/skel_opaque.c b/examples/VFS/skel_opaque.c index 40951db35e3..7dd258f1528 100644 --- a/examples/VFS/skel_opaque.c +++ b/examples/VFS/skel_opaque.c @@ -56,9 +56,11 @@ static uint64_t skel_disk_free(vfs_handle_struct *handle, return 0; } -static int skel_get_quota(vfs_handle_struct *handle, const char *path, - enum SMB_QUOTA_TYPE qtype, unid_t id, - SMB_DISK_QUOTA *dq) +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) { errno = ENOSYS; return -1; diff --git a/examples/VFS/skel_transparent.c b/examples/VFS/skel_transparent.c index 83c0c2ae4d9..5e66be49d42 100644 --- a/examples/VFS/skel_transparent.c +++ b/examples/VFS/skel_transparent.c @@ -57,11 +57,13 @@ static uint64_t skel_disk_free(vfs_handle_struct *handle, return SMB_VFS_NEXT_DISK_FREE(handle, smb_fname, bsize, dfree, dsize); } -static int skel_get_quota(vfs_handle_struct *handle, const char *path, - enum SMB_QUOTA_TYPE qtype, unid_t id, - SMB_DISK_QUOTA *dq) +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) { - return SMB_VFS_NEXT_GET_QUOTA(handle, path, qtype, id, dq); + return SMB_VFS_NEXT_GET_QUOTA(handle, smb_fname, 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 4a7179a094b..a0eca7730f9 100644 --- a/source3/include/vfs.h +++ b/source3/include/vfs.h @@ -218,6 +218,8 @@ to const struct smb_filename * */ /* Version 37 - Change disk_free from const char * to const struct smb_filename * */ +/* Version 37 - Change get_quota from const char * + to const struct smb_filename * */ #define SMB_VFS_INTERFACE_VERSION 37 @@ -607,9 +609,11 @@ struct vfs_fn_pointers { uint64_t *bsize, uint64_t *dfree, uint64_t *dsize); - int (*get_quota_fn)(struct vfs_handle_struct *handle, const char *path, - enum SMB_QUOTA_TYPE qtype, unid_t id, - SMB_DISK_QUOTA *qt); + 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); 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 (*statvfs_fn)(struct vfs_handle_struct *handle, const char *path, struct vfs_statvfs_struct *statbuf); @@ -1065,9 +1069,11 @@ uint64_t smb_vfs_call_disk_free(struct vfs_handle_struct *handle, uint64_t *bsize, uint64_t *dfree, uint64_t *dsize); -int smb_vfs_call_get_quota(struct vfs_handle_struct *handle, const char *path, - enum SMB_QUOTA_TYPE qtype, unid_t id, - SMB_DISK_QUOTA *qt); +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); int smb_vfs_call_set_quota(struct vfs_handle_struct *handle, enum SMB_QUOTA_TYPE qtype, unid_t id, SMB_DISK_QUOTA *qt); diff --git a/source3/include/vfs_macros.h b/source3/include/vfs_macros.h index cd34ec981c1..d49d340b002 100644 --- a/source3/include/vfs_macros.h +++ b/source3/include/vfs_macros.h @@ -44,10 +44,10 @@ #define SMB_VFS_NEXT_DISK_FREE(handle, smb_fname, bsize, dfree ,dsize)\ smb_vfs_call_disk_free((handle)->next, (smb_fname), (bsize), (dfree), (dsize)) -#define SMB_VFS_GET_QUOTA(conn, path, qtype, id, qt) \ - smb_vfs_call_get_quota((conn)->vfs_handles, (path), (qtype), (id), (qt)) -#define SMB_VFS_NEXT_GET_QUOTA(handle, path, qtype, id, qt) \ - smb_vfs_call_get_quota((handle)->next, (path), (qtype), (id), (qt)) +#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_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 cf3bb94498c..cfb02cbdf62 100644 --- a/source3/modules/vfs_cap.c +++ b/source3/modules/vfs_cap.c @@ -56,17 +56,30 @@ static uint64_t cap_disk_free(vfs_handle_struct *handle, bsize, dfree, dsize); } -static int cap_get_quota(vfs_handle_struct *handle, const char *path, - enum SMB_QUOTA_TYPE qtype, unid_t id, - SMB_DISK_QUOTA *dq) +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) { - char *cappath = capencode(talloc_tos(), path); + char *cappath = capencode(talloc_tos(), smb_fname->base_name); + struct smb_filename *cap_smb_fname = NULL; if (!cappath) { errno = ENOMEM; return -1; } - return SMB_VFS_NEXT_GET_QUOTA(handle, cappath, qtype, id, dq); + cap_smb_fname = synthetic_smb_fname(talloc_tos(), + cappath, + NULL, + NULL, + smb_fname->flags); + if (cap_smb_fname == NULL) { + TALLOC_FREE(cappath); + errno = ENOMEM; + return -1; + } + return SMB_VFS_NEXT_GET_QUOTA(handle, cap_smb_fname, qtype, id, dq); } static DIR *cap_opendir(vfs_handle_struct *handle, diff --git a/source3/modules/vfs_ceph.c b/source3/modules/vfs_ceph.c index 1244468abed..5f7440473df 100644 --- a/source3/modules/vfs_ceph.c +++ b/source3/modules/vfs_ceph.c @@ -201,8 +201,10 @@ static uint64_t cephwrap_disk_free(struct vfs_handle_struct *handle, } static int cephwrap_get_quota(struct vfs_handle_struct *handle, - const char *path, enum SMB_QUOTA_TYPE qtype, - unid_t id, SMB_DISK_QUOTA *qt) + const struct smb_filename *smb_fname, + enum SMB_QUOTA_TYPE qtype, + unid_t id, + SMB_DISK_QUOTA *qt) { /* libceph: Ceph does not implement this */ #if 0 diff --git a/source3/modules/vfs_default.c b/source3/modules/vfs_default.c index 1c267287cff..664da956c7c 100644 --- a/source3/modules/vfs_default.c +++ b/source3/modules/vfs_default.c @@ -69,15 +69,17 @@ static uint64_t vfswrap_disk_free(vfs_handle_struct *handle, return *dfree / 2; } -static int vfswrap_get_quota(struct vfs_handle_struct *handle, const char *path, - enum SMB_QUOTA_TYPE qtype, unid_t id, - SMB_DISK_QUOTA *qt) +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) { #ifdef HAVE_SYS_QUOTAS int result; START_PROFILE(syscall_get_quota); - result = sys_get_quota(path, qtype, id, qt); + result = sys_get_quota(smb_fname->base_name, qtype, id, qt); END_PROFILE(syscall_get_quota); return result; #else diff --git a/source3/modules/vfs_default_quota.c b/source3/modules/vfs_default_quota.c index 6f1d2a7f619..c27681af00f 100644 --- a/source3/modules/vfs_default_quota.c +++ b/source3/modules/vfs_default_quota.c @@ -92,13 +92,16 @@ #define DEFAULT_QUOTA_GID_NOLIMIT(handle) \ 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 char *path, - enum SMB_QUOTA_TYPE qtype, unid_t id, - SMB_DISK_QUOTA *dq) +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) { int ret = -1; - if ((ret = SMB_VFS_NEXT_GET_QUOTA(handle, path, qtype, id, dq)) != 0) { + if ((ret = SMB_VFS_NEXT_GET_QUOTA(handle, smb_fname, + qtype, id, dq)) != 0) { return ret; } @@ -124,8 +127,8 @@ static int default_quota_get_quota(vfs_handle_struct *handle, const char *path, unid_t qid; uint32_t qflags = dq->qflags; qid.uid = DEFAULT_QUOTA_UID(handle); - SMB_VFS_NEXT_GET_QUOTA( - handle, path, SMB_USER_QUOTA_TYPE, qid, dq); + SMB_VFS_NEXT_GET_QUOTA(handle, smb_fname, + SMB_USER_QUOTA_TYPE, qid, dq); dq->qflags = qflags; } break; @@ -135,7 +138,7 @@ static int default_quota_get_quota(vfs_handle_struct *handle, const char *path, unid_t qid; uint32_t qflags = dq->qflags; qid.gid = DEFAULT_QUOTA_GID(handle); - SMB_VFS_NEXT_GET_QUOTA(handle, path, + SMB_VFS_NEXT_GET_QUOTA(handle, smb_fname, SMB_GROUP_QUOTA_TYPE, qid, dq); dq->qflags = qflags; diff --git a/source3/modules/vfs_fake_dfq.c b/source3/modules/vfs_fake_dfq.c index 5e8879fe1cc..971db68bc55 100644 --- a/source3/modules/vfs_fake_dfq.c +++ b/source3/modules/vfs_fake_dfq.c @@ -27,9 +27,11 @@ #undef DBGC_CLASS #define DBGC_CLASS DBGC_VFS -static int dfq_get_quota(struct vfs_handle_struct *handle, const char *path, - enum SMB_QUOTA_TYPE qtype, unid_t id, - SMB_DISK_QUOTA *qt); +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); static uint64_t dfq_load_param(int snum, const char *path, const char *section, const char *param, uint64_t def_val) @@ -88,9 +90,11 @@ static uint64_t dfq_disk_free(vfs_handle_struct *handle, return free_1k; } -static int dfq_get_quota(struct vfs_handle_struct *handle, const char *path, - enum SMB_QUOTA_TYPE qtype, unid_t id, - SMB_DISK_QUOTA *qt) +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) { int rc = 0; int save_errno; @@ -99,7 +103,7 @@ static int dfq_get_quota(struct vfs_handle_struct *handle, const char *path, uint64_t bsize = 0; char *rpath = NULL; - rpath = SMB_VFS_NEXT_REALPATH(handle, path); + rpath = SMB_VFS_NEXT_REALPATH(handle, smb_fname->base_name); if (rpath == NULL) { goto dflt; } @@ -160,7 +164,7 @@ static int dfq_get_quota(struct vfs_handle_struct *handle, const char *path, goto out; dflt: - rc = SMB_VFS_NEXT_GET_QUOTA(handle, path, qtype, id, qt); + rc = SMB_VFS_NEXT_GET_QUOTA(handle, smb_fname, qtype, id, qt); out: save_errno = errno; diff --git a/source3/modules/vfs_full_audit.c b/source3/modules/vfs_full_audit.c index 916825767bf..01cea1aaee4 100644 --- a/source3/modules/vfs_full_audit.c +++ b/source3/modules/vfs_full_audit.c @@ -693,14 +693,17 @@ 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 char *path, enum SMB_QUOTA_TYPE qtype, - unid_t id, SMB_DISK_QUOTA *qt) + const struct smb_filename *smb_fname, + enum SMB_QUOTA_TYPE qtype, + unid_t id, + SMB_DISK_QUOTA *qt) { int result; - result = SMB_VFS_NEXT_GET_QUOTA(handle, path, qtype, id, qt); + result = SMB_VFS_NEXT_GET_QUOTA(handle, smb_fname, qtype, id, qt); - do_log(SMB_VFS_OP_GET_QUOTA, (result >= 0), handle, "%s", path); + do_log(SMB_VFS_OP_GET_QUOTA, (result >= 0), handle, "%s", + smb_fname->base_name); return result; } diff --git a/source3/modules/vfs_glusterfs.c b/source3/modules/vfs_glusterfs.c index cabb86120d9..3d28381eaf4 100644 --- a/source3/modules/vfs_glusterfs.c +++ b/source3/modules/vfs_glusterfs.c @@ -402,9 +402,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 char *path, - enum SMB_QUOTA_TYPE qtype, unid_t id, - SMB_DISK_QUOTA *qt) + const struct smb_filename *smb_fname, + 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 9898d443915..a552cdda4d9 100644 --- a/source3/modules/vfs_gpfs.c +++ b/source3/modules/vfs_gpfs.c @@ -2217,9 +2217,11 @@ static uint64_t vfs_gpfs_disk_free(vfs_handle_struct *handle, return *dfree / 2; } -static int vfs_gpfs_get_quota(vfs_handle_struct *handle, const char *path, - enum SMB_QUOTA_TYPE qtype, unid_t id, - SMB_DISK_QUOTA *dq) +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) { switch(qtype) { /* @@ -2237,7 +2239,8 @@ static int vfs_gpfs_get_quota(vfs_handle_struct *handle, const char *path, errno = ENOSYS; return -1; default: - return SMB_VFS_NEXT_GET_QUOTA(handle, path, qtype, id, dq); + return SMB_VFS_NEXT_GET_QUOTA(handle, smb_fname, + qtype, id, dq); } } diff --git a/source3/modules/vfs_shadow_copy2.c b/source3/modules/vfs_shadow_copy2.c index e1f30398c1d..faacc459146 100644 --- a/source3/modules/vfs_shadow_copy2.c +++ b/source3/modules/vfs_shadow_copy2.c @@ -2792,22 +2792,28 @@ static uint64_t shadow_copy2_disk_free(vfs_handle_struct *handle, return ret; } -static int shadow_copy2_get_quota(vfs_handle_struct *handle, const char *path, - enum SMB_QUOTA_TYPE qtype, unid_t id, - SMB_DISK_QUOTA *dq) +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) { time_t timestamp = 0; char *stripped = NULL; int ret; int saved_errno = 0; char *conv; + struct smb_filename *conv_smb_fname = NULL; - if (!shadow_copy2_strip_snapshot(talloc_tos(), handle, path, ×tamp, - &stripped)) { + if (!shadow_copy2_strip_snapshot(talloc_tos(), + handle, + smb_fname->base_name, + ×tamp, + &stripped)) { return -1; } if (timestamp == 0) { - return SMB_VFS_NEXT_GET_QUOTA(handle, path, qtype, id, dq); + return SMB_VFS_NEXT_GET_QUOTA(handle, smb_fname, qtype, id, dq); } conv = shadow_copy2_convert(talloc_tos(), handle, stripped, timestamp); @@ -2815,13 +2821,22 @@ static int shadow_copy2_get_quota(vfs_handle_struct *handle, const char *path, if (conv == NULL) { return -1; } - - ret = SMB_VFS_NEXT_GET_QUOTA(handle, conv, qtype, id, dq); + conv_smb_fname = synthetic_smb_fname(talloc_tos(), + conv, + NULL, + NULL, + smb_fname->flags); + if (conv_smb_fname == NULL) { + TALLOC_FREE(conv); + return -1; + } + ret = SMB_VFS_NEXT_GET_QUOTA(handle, conv_smb_fname, qtype, id, dq); if (ret == -1) { saved_errno = errno; } TALLOC_FREE(conv); + TALLOC_FREE(conv_smb_fname); if (saved_errno != 0) { errno = saved_errno; } diff --git a/source3/modules/vfs_snapper.c b/source3/modules/vfs_snapper.c index 774f7ee3c69..41800bf7a3a 100644 --- a/source3/modules/vfs_snapper.c +++ b/source3/modules/vfs_snapper.c @@ -3032,22 +3032,25 @@ static uint64_t snapper_gmt_disk_free(vfs_handle_struct *handle, return ret; } -static int snapper_gmt_get_quota(vfs_handle_struct *handle, const char *path, - enum SMB_QUOTA_TYPE qtype, unid_t id, - SMB_DISK_QUOTA *dq) +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) { - time_t timestamp; - char *stripped; + time_t timestamp = 0; + char *stripped = NULL; int ret; - int saved_errno; - char *conv; + int saved_errno = 0; + char *conv = NULL; + struct smb_filename *conv_smb_fname = NULL; - if (!snapper_gmt_strip_snapshot(talloc_tos(), handle, path, ×tamp, - &stripped)) { + if (!snapper_gmt_strip_snapshot(talloc_tos(), handle, + smb_fname->base_name, ×tamp, &stripped)) { return -1; } if (timestamp == 0) { - return SMB_VFS_NEXT_GET_QUOTA(handle, path, qtype, id, dq); + return SMB_VFS_NEXT_GET_QUOTA(handle, smb_fname, qtype, id, dq); } conv = snapper_gmt_convert(talloc_tos(), handle, stripped, timestamp); @@ -3055,13 +3058,26 @@ static int snapper_gmt_get_quota(vfs_handle_struct *handle, const char *path, if (conv == NULL) { return -1; } - - ret = SMB_VFS_NEXT_GET_QUOTA(handle, conv, qtype, id, dq); - - saved_errno = errno; + conv_smb_fname = synthetic_smb_fname(talloc_tos(), + conv, + NULL, + NULL, + smb_fname->flags); TALLOC_FREE(conv); - errno = saved_errno; + if (conv_smb_fname == NULL) { + errno = ENOMEM; + return -1; + } + ret = SMB_VFS_NEXT_GET_QUOTA(handle, conv_smb_fname, qtype, id, dq); + + if (ret == -1) { + saved_errno = errno; + } + TALLOC_FREE(conv_smb_fname); + if (saved_errno != 0) { + errno = saved_errno; + } return ret; } diff --git a/source3/modules/vfs_time_audit.c b/source3/modules/vfs_time_audit.c index 092474fd0d8..ebfcb8df655 100644 --- a/source3/modules/vfs_time_audit.c +++ b/source3/modules/vfs_time_audit.c @@ -182,20 +182,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 char *path, enum SMB_QUOTA_TYPE qtype, - unid_t id, SMB_DISK_QUOTA *qt) + const struct smb_filename *smb_fname, + 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, path, qtype, id, qt); + result = SMB_VFS_NEXT_GET_QUOTA(handle, smb_fname, qtype, id, qt); clock_gettime_mono(&ts2); timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9; if (timediff > audit_timeout) { - smb_time_audit_log("get_quota", timediff); + smb_time_audit_log_fname("get_quota", + timediff, + smb_fname->base_name); } return result; } diff --git a/source3/smbd/ntquotas.c b/source3/smbd/ntquotas.c index 8a44f7c674a..7e2c0363696 100644 --- a/source3/smbd/ntquotas.c +++ b/source3/smbd/ntquotas.c @@ -74,6 +74,8 @@ NTSTATUS vfs_get_ntquota(files_struct *fsp, enum SMB_QUOTA_TYPE qtype, int ret; SMB_DISK_QUOTA D; unid_t id; + struct smb_filename *smb_fname_cwd = NULL; + int saved_errno = 0; ZERO_STRUCT(D); @@ -91,7 +93,23 @@ NTSTATUS vfs_get_ntquota(files_struct *fsp, enum SMB_QUOTA_TYPE qtype, return NT_STATUS_NO_SUCH_USER; } - ret = SMB_VFS_GET_QUOTA(fsp->conn, ".", qtype, id, &D); + smb_fname_cwd = synthetic_smb_fname(talloc_tos(), + ".", + NULL, + NULL, + 0); + if (smb_fname_cwd == NULL) { + return NT_STATUS_NO_MEMORY; + } + + ret = SMB_VFS_GET_QUOTA(fsp->conn, smb_fname_cwd, qtype, id, &D); + if (ret == -1) { + saved_errno = errno; + } + TALLOC_FREE(smb_fname_cwd); + if (saved_errno != 0) { + errno = saved_errno; + } if (psid) qt->sid = *psid; diff --git a/source3/smbd/quotas.c b/source3/smbd/quotas.c index 2db18cdb21c..2f18e368b17 100644 --- a/source3/smbd/quotas.c +++ b/source3/smbd/quotas.c @@ -494,7 +494,7 @@ bool disk_quotas(connection_struct *conn, struct smb_filename *fname, */ ZERO_STRUCT(D); id.uid = -1; - r = SMB_VFS_GET_QUOTA(conn, fname->base_name, SMB_USER_FS_QUOTA_TYPE, + r = SMB_VFS_GET_QUOTA(conn, fname, SMB_USER_FS_QUOTA_TYPE, id, &D); if (r == -1 && errno != ENOSYS) { goto try_group_quota; @@ -516,13 +516,13 @@ bool disk_quotas(connection_struct *conn, struct smb_filename *fname, id.uid = fname->st.st_ex_uid; become_root(); - r = SMB_VFS_GET_QUOTA(conn, fname->base_name, + r = SMB_VFS_GET_QUOTA(conn, fname, SMB_USER_QUOTA_TYPE, id, &D); save_errno = errno; unbecome_root(); errno = save_errno; } else { - r = SMB_VFS_GET_QUOTA(conn, fname->base_name, + r = SMB_VFS_GET_QUOTA(conn, fname, SMB_USER_QUOTA_TYPE, id, &D); } @@ -560,7 +560,7 @@ try_group_quota: */ ZERO_STRUCT(D); id.gid = -1; - r = SMB_VFS_GET_QUOTA(conn, fname->base_name, SMB_GROUP_FS_QUOTA_TYPE, + r = SMB_VFS_GET_QUOTA(conn, fname, SMB_GROUP_FS_QUOTA_TYPE, id, &D); if (r == -1 && errno != ENOSYS) { return false; @@ -572,7 +572,7 @@ try_group_quota: id.gid = getegid(); ZERO_STRUCT(D); - r = SMB_VFS_GET_QUOTA(conn, fname->base_name, SMB_GROUP_QUOTA_TYPE, id, + r = SMB_VFS_GET_QUOTA(conn, fname, SMB_GROUP_QUOTA_TYPE, id, &D); if (r == -1) { diff --git a/source3/smbd/vfs.c b/source3/smbd/vfs.c index f91e9e33a02..7177f882a0c 100644 --- a/source3/smbd/vfs.c +++ b/source3/smbd/vfs.c @@ -1478,12 +1478,14 @@ uint64_t smb_vfs_call_disk_free(struct vfs_handle_struct *handle, bsize, dfree, dsize); } -int smb_vfs_call_get_quota(struct vfs_handle_struct *handle, const char *path, - enum SMB_QUOTA_TYPE qtype, unid_t id, - SMB_DISK_QUOTA *qt) +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) { VFS_FIND(get_quota); - return handle->fns->get_quota_fn(handle, path, qtype, id, qt); + return handle->fns->get_quota_fn(handle, smb_fname, qtype, id, qt); } int smb_vfs_call_set_quota(struct vfs_handle_struct *handle, |