nt-quotas: vfs_get_ntquota() return NTSTATUS
authorUri Simchoni <uri@samba.org>
Tue, 29 Mar 2016 20:30:23 +0000 (23:30 +0300)
committerJeremy Allison <jra@samba.org>
Thu, 31 Mar 2016 18:30:10 +0000 (20:30 +0200)
Signed-off-by: Uri Simchoni <uri@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/smbd/ntquotas.c
source3/smbd/nttrans.c
source3/smbd/proto.h
source3/smbd/trans2.c

index aa2ec3b76a535b9badbb063b91b8c4272e14d726..a36196b817bbe12815c6f16b45e4e0a634e9fcf8 100644 (file)
@@ -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));
index 3a2c35fe7b1b073a06959df77cec34671ed1a1e0..232cc687b504fdba4146e817b3c8fe2756428532 100644 (file)
@@ -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
index 8e8cbc34ca32a9fafa3d19f17ddc31fcdb7c8775..36120347fe2de940607850a174d84132f7eed588 100644 (file)
@@ -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);
index f3510087b0c146230db5eb8b8c95bb0e2e587b35..0e1c6d9eb84230c9dfb490b5bd32101ff2d4f606 100644 (file)
@@ -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, &quotas)!=0) {
+                       status = vfs_get_ntquota(&fsp, SMB_USER_FS_QUOTA_TYPE,
+                                                NULL, &quotas);
+                       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;