s3:smb2_lock: error out early in smbd_smb2_lock_send()
authorStefan Metzmacher <metze@samba.org>
Tue, 13 Aug 2019 14:39:41 +0000 (16:39 +0200)
committerStefan Metzmacher <metze@samba.org>
Mon, 9 Sep 2019 14:23:40 +0000 (14:23 +0000)
We no longer expect NT_STATUS_FILE_LOCK_CONFLICT from
the VFS layer and assert that in a future version.

This makes it easier to port the same logic to smbd_smb2_lock_try().

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
source3/smbd/smb2_lock.c

index c2b4603f3e10645c7b22aa3c746c1c3c4d6671d4..c049c33ebbcb8ccd8643280d792c843cd85d4286 100644 (file)
@@ -383,10 +383,26 @@ static struct tevent_req *smbd_smb2_lock_send(TALLOC_CTX *mem_ctx,
                tevent_req_done(req);
                return tevent_req_post(req, ev);
        }
+       if (NT_STATUS_EQUAL(status, NT_STATUS_FILE_LOCK_CONFLICT)) {
+               /*
+                * This is a bug and will be changed into an assert
+                * in a future version. We should only
+                * ever get NT_STATUS_LOCK_NOT_GRANTED here!
+                */
+               static uint64_t _bug_count;
+               int _level = (_bug_count++ == 0) ? DBGLVL_ERR: DBGLVL_DEBUG;
+               DBG_PREFIX(_level, ("BUG: Got %s mapping to "
+                          "NT_STATUS_LOCK_NOT_GRANTED\n",
+                          nt_errstr(status)));
+               status = NT_STATUS_LOCK_NOT_GRANTED;
+       }
+       if (!NT_STATUS_EQUAL(status, NT_STATUS_LOCK_NOT_GRANTED)) {
+               TALLOC_FREE(lck);
+               tevent_req_nterror(req, status);
+               return tevent_req_post(req, ev);
+       }
 
-       if (state->blocking &&
-           (NT_STATUS_EQUAL(status, NT_STATUS_LOCK_NOT_GRANTED) ||
-            NT_STATUS_EQUAL(status, NT_STATUS_FILE_LOCK_CONFLICT))) {
+       if (state->blocking) {
                struct tevent_req *subreq;
 
                DBG_DEBUG("Watching share mode lock\n");