Signed-off-by: Uri Simchoni <uri@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
-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;
{
int ret;
SMB_DISK_QUOTA D;
- if (!fsp||!fsp->conn||!qt)
- return (-1);
+ if (!fsp || !fsp->conn || !qt) {
+ return NT_STATUS_INTERNAL_ERROR;
+ }
if (psid && !sid_to_uid(psid, &id.uid)) {
DEBUG(0,("sid_to_uid: failed, SID[%s]\n",
sid_string_dbg(psid)));
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);
}
ret = SMB_VFS_GET_QUOTA(fsp->conn, ".", qtype, id, &D);
qt->sid = *psid;
if (ret!=0) {
qt->sid = *psid;
if (ret!=0) {
+ return map_nt_error_from_unix(errno);
}
qt->usedspace = (uint64_t)D.curblocks*D.bsize;
}
qt->usedspace = (uint64_t)D.curblocks*D.bsize;
qt->hardlim = limit_unix2nt(D.hardlimit, D.bsize);
qt->qflags = D.qflags;
qt->hardlim = limit_unix2nt(D.hardlimit, D.bsize);
qt->qflags = D.qflags;
}
int vfs_set_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)
SMB_NTQUOTA_STRUCT tmp_qt;
SMB_NTQUOTA_LIST *tmp_list_ent;
struct dom_sid sid;
SMB_NTQUOTA_STRUCT tmp_qt;
SMB_NTQUOTA_LIST *tmp_list_ent;
struct dom_sid sid;
uid_to_sid(&sid, usr->pw_uid);
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));
DEBUG(5,("no quota entry for sid[%s] path[%s]\n",
sid_string_dbg(&sid),
fsp->conn->connectpath));
- 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
ZERO_STRUCT(qt);
/*
* we have to return zero's in all fields
/* The following definitions come from smbd/ntquotas.c */
/* 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);
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);
return NT_STATUS_ACCESS_DENIED;
}
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))));
DEBUG(0,("vfs_get_ntquota() failed for service [%s]\n",lp_servicename(talloc_tos(), SNUM(conn))));
- return map_nt_error_from_unix(errno);