From fcf6527202be9b1a913ebb93ef3ed1d01a0c26fa Mon Sep 17 00:00:00 2001 From: Uri Simchoni Date: Tue, 29 Mar 2016 23:30:23 +0300 Subject: [PATCH] nt-quotas: vfs_get_ntquota() return NTSTATUS Signed-off-by: Uri Simchoni Reviewed-by: Jeremy Allison --- source3/smbd/ntquotas.c | 19 ++++++++++++------- source3/smbd/nttrans.c | 4 +++- source3/smbd/proto.h | 3 ++- source3/smbd/trans2.c | 6 ++++-- 4 files changed, 21 insertions(+), 11 deletions(-) diff --git a/source3/smbd/ntquotas.c b/source3/smbd/ntquotas.c index aa2ec3b76a53..a36196b817bb 100644 --- a/source3/smbd/ntquotas.c +++ b/source3/smbd/ntquotas.c @@ -76,7 +76,8 @@ static uint64_t limit_blk2inodes(uint64_t in) return ret; } -int vfs_get_ntquota(files_struct *fsp, enum SMB_QUOTA_TYPE qtype, struct dom_sid *psid, SMB_NTQUOTA_STRUCT *qt) +NTSTATUS vfs_get_ntquota(files_struct *fsp, enum SMB_QUOTA_TYPE qtype, + struct dom_sid *psid, SMB_NTQUOTA_STRUCT *qt) { int ret; SMB_DISK_QUOTA D; @@ -84,8 +85,9 @@ int vfs_get_ntquota(files_struct *fsp, enum SMB_QUOTA_TYPE qtype, struct dom_sid ZERO_STRUCT(D); - if (!fsp||!fsp->conn||!qt) - return (-1); + if (!fsp || !fsp->conn || !qt) { + return NT_STATUS_INTERNAL_ERROR; + } ZERO_STRUCT(*qt); @@ -94,6 +96,7 @@ int vfs_get_ntquota(files_struct *fsp, enum SMB_QUOTA_TYPE qtype, struct dom_sid if (psid && !sid_to_uid(psid, &id.uid)) { DEBUG(0,("sid_to_uid: failed, SID[%s]\n", sid_string_dbg(psid))); + return NT_STATUS_NO_SUCH_USER; } ret = SMB_VFS_GET_QUOTA(fsp->conn, ".", qtype, id, &D); @@ -102,7 +105,7 @@ int vfs_get_ntquota(files_struct *fsp, enum SMB_QUOTA_TYPE qtype, struct dom_sid qt->sid = *psid; if (ret!=0) { - return ret; + return map_nt_error_from_unix(errno); } qt->usedspace = (uint64_t)D.curblocks*D.bsize; @@ -110,8 +113,7 @@ int vfs_get_ntquota(files_struct *fsp, enum SMB_QUOTA_TYPE qtype, struct dom_sid qt->hardlim = limit_unix2nt(D.hardlimit, D.bsize); qt->qflags = D.qflags; - - return 0; + return NT_STATUS_OK; } int vfs_set_ntquota(files_struct *fsp, enum SMB_QUOTA_TYPE qtype, struct dom_sid *psid, SMB_NTQUOTA_STRUCT *qt) @@ -181,6 +183,7 @@ int vfs_get_user_ntquota_list(files_struct *fsp, SMB_NTQUOTA_LIST **qt_list) SMB_NTQUOTA_STRUCT tmp_qt; SMB_NTQUOTA_LIST *tmp_list_ent; struct dom_sid sid; + NTSTATUS status; ZERO_STRUCT(tmp_qt); @@ -191,7 +194,9 @@ int vfs_get_user_ntquota_list(files_struct *fsp, SMB_NTQUOTA_LIST **qt_list) uid_to_sid(&sid, usr->pw_uid); - if (vfs_get_ntquota(fsp, SMB_USER_QUOTA_TYPE, &sid, &tmp_qt)!=0) { + status = + vfs_get_ntquota(fsp, SMB_USER_QUOTA_TYPE, &sid, &tmp_qt); + if (!NT_STATUS_IS_OK(status)) { DEBUG(5,("no quota entry for sid[%s] path[%s]\n", sid_string_dbg(&sid), fsp->conn->connectpath)); diff --git a/source3/smbd/nttrans.c b/source3/smbd/nttrans.c index 3a2c35fe7b1b..232cc687b504 100644 --- a/source3/smbd/nttrans.c +++ b/source3/smbd/nttrans.c @@ -2509,7 +2509,9 @@ static void call_nt_transact_get_user_quota(connection_struct *conn, return; } - if (vfs_get_ntquota(fsp, SMB_USER_QUOTA_TYPE, &sid, &qt)!=0) { + nt_status = vfs_get_ntquota(fsp, SMB_USER_QUOTA_TYPE, + &sid, &qt); + if (!NT_STATUS_IS_OK(nt_status)) { ZERO_STRUCT(qt); /* * we have to return zero's in all fields diff --git a/source3/smbd/proto.h b/source3/smbd/proto.h index 8e8cbc34ca32..36120347fe2d 100644 --- a/source3/smbd/proto.h +++ b/source3/smbd/proto.h @@ -600,7 +600,8 @@ NTSTATUS notify_walk(struct notify_context *notify, /* The following definitions come from smbd/ntquotas.c */ -int vfs_get_ntquota(files_struct *fsp, enum SMB_QUOTA_TYPE qtype, struct dom_sid *psid, SMB_NTQUOTA_STRUCT *qt); +NTSTATUS vfs_get_ntquota(files_struct *fsp, enum SMB_QUOTA_TYPE qtype, + struct dom_sid *psid, SMB_NTQUOTA_STRUCT *qt); int vfs_set_ntquota(files_struct *fsp, enum SMB_QUOTA_TYPE qtype, struct dom_sid *psid, SMB_NTQUOTA_STRUCT *qt); int vfs_get_user_ntquota_list(files_struct *fsp, SMB_NTQUOTA_LIST **qt_list); void *init_quota_handle(TALLOC_CTX *mem_ctx); diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c index f3510087b0c1..0e1c6d9eb842 100644 --- a/source3/smbd/trans2.c +++ b/source3/smbd/trans2.c @@ -3712,9 +3712,11 @@ cBytesSector=%u, cUnitTotal=%u, cUnitAvail=%d\n", (unsigned int)bsize, (unsigned return NT_STATUS_ACCESS_DENIED; } - if (vfs_get_ntquota(&fsp, SMB_USER_FS_QUOTA_TYPE, NULL, "as)!=0) { + status = vfs_get_ntquota(&fsp, SMB_USER_FS_QUOTA_TYPE, + NULL, "as); + if (!NT_STATUS_IS_OK(status)) { DEBUG(0,("vfs_get_ntquota() failed for service [%s]\n",lp_servicename(talloc_tos(), SNUM(conn)))); - return map_nt_error_from_unix(errno); + return status; } data_len = 48; -- 2.34.1