s3-cliquota: correctly handle no-more-entries
authorUri Simchoni <uri@samba.org>
Fri, 16 Sep 2016 18:57:50 +0000 (21:57 +0300)
committerJeremy Allison <jra@samba.org>
Tue, 4 Oct 2016 00:00:22 +0000 (02:00 +0200)
When listing quota records, a Windows server would
return STATUS_SUCCESS until no more entries are available,
where it would return STATUS_NO_MORE_ENTRIES.

The fix keeps old behavior of empty answer also signifying
end of record, to maintain compatibility with Samba servers.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=12270

Signed-off-by: Uri Simchoni <uri@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/libsmb/cliquota.c

index 875c41977734a613417f5d26ff162eef22490236..778fefcd8658321686bab3dcaf82385b246efddc 100644 (file)
@@ -242,13 +242,15 @@ NTSTATUS cli_list_user_quota(struct cli_state *cli, int quota_fnum,
                           &rparam, 0, &rparam_count,
                           &rdata, 0, &rdata_count);
 
-       if (!NT_STATUS_IS_OK(status)) {
+       if (!NT_STATUS_IS_OK(status) &&
+           !NT_STATUS_EQUAL(status, NT_STATUS_NO_MORE_ENTRIES)) {
                DEBUG(1, ("NT_TRANSACT_GET_USER_QUOTA failed: %s\n",
                          nt_errstr(status)));
                goto cleanup;
        }
 
-       if (rdata_count == 0) {
+       if (NT_STATUS_EQUAL(status, NT_STATUS_NO_MORE_ENTRIES) ||
+           rdata_count == 0) {
                *pqt_list = NULL;
                return NT_STATUS_OK;
        }
@@ -304,13 +306,16 @@ NTSTATUS cli_list_user_quota(struct cli_state *cli, int quota_fnum,
                                   &rparam, 0, &rparam_count,
                                   &rdata, 0, &rdata_count);
 
-               if (!NT_STATUS_IS_OK(status)) {
+               if (!NT_STATUS_IS_OK(status) &&
+                   !NT_STATUS_EQUAL(status, NT_STATUS_NO_MORE_ENTRIES)) {
                        DEBUG(1, ("NT_TRANSACT_GET_USER_QUOTA failed: %s\n",
                                  nt_errstr(status)));
                        goto cleanup;
                }
 
-               if (rdata_count == 0) {
+               if (NT_STATUS_EQUAL(status, NT_STATUS_NO_MORE_ENTRIES) ||
+                   rdata_count == 0) {
+                       status = NT_STATUS_OK;
                        break;
                }