]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3: smbd: Change (*proto_reply_fn()) to return an NTSTATUS.
authorJeremy Allison <jra@samba.org>
Tue, 26 Nov 2019 20:43:25 +0000 (12:43 -0800)
committerKarolin Seeger <kseeger@samba.org>
Mon, 16 Dec 2019 08:22:36 +0000 (08:22 +0000)
That way the caller can know if the negprot really
succeeded or not.

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

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
(cherry picked from commit f4caa4159bd3db5127e114718e606867348a4f47)

source3/smbd/globals.h
source3/smbd/negprot.c
source3/smbd/smb2_negprot.c

index 0a4fcd96b4311a44f782ab727ae2294254b56f18..9bb7b1f49c8766c86c1d02da2025fa2e9a3aa743 100644 (file)
@@ -237,8 +237,8 @@ bool smbd_smb2_is_compound(const struct smbd_smb2_request *req);
 NTSTATUS smbd_add_connection(struct smbXsrv_client *client, int sock_fd,
                             struct smbXsrv_connection **_xconn);
 
-void reply_smb2002(struct smb_request *req, uint16_t choice);
-void reply_smb20ff(struct smb_request *req, uint16_t choice);
+NTSTATUS reply_smb2002(struct smb_request *req, uint16_t choice);
+NTSTATUS reply_smb20ff(struct smb_request *req, uint16_t choice);
 NTSTATUS smbd_smb2_process_negprot(struct smbXsrv_connection *xconn,
                               uint64_t expected_seq_low,
                               const uint8_t *inpdu, size_t size);
index 2d5edf1282c0ce1edab8339eae4397e400d19fc3..3b2555e3d21f6bb67bbad77509fdeec184841f20 100644 (file)
@@ -66,7 +66,7 @@ static void get_challenge(struct smbXsrv_connection *xconn, uint8_t buff[8])
  Reply for the lanman 1.0 protocol.
 ****************************************************************************/
 
-static void reply_lanman1(struct smb_request *req, uint16_t choice)
+static NTSTATUS reply_lanman1(struct smb_request *req, uint16_t choice)
 {
        int secword=0;
        time_t t = time(NULL);
@@ -100,7 +100,7 @@ static void reply_lanman1(struct smb_request *req, uint16_t choice)
        status = smbXsrv_connection_init_tables(xconn, PROTOCOL_LANMAN1);
        if (!NT_STATUS_IS_OK(status)) {
                reply_nterror(req, status);
-               return;
+               return status;
        }
 
        /* Reply, SMBlockread, SMBwritelock supported. */
@@ -115,14 +115,14 @@ static void reply_lanman1(struct smb_request *req, uint16_t choice)
 
        srv_put_dos_date((char *)req->outbuf,smb_vwv8,t);
 
-       return;
+       return NT_STATUS_OK;
 }
 
 /****************************************************************************
  Reply for the lanman 2.0 protocol.
 ****************************************************************************/
 
-static void reply_lanman2(struct smb_request *req, uint16_t choice)
+static NTSTATUS reply_lanman2(struct smb_request *req, uint16_t choice)
 {
        int secword=0;
        time_t t = time(NULL);
@@ -158,7 +158,7 @@ static void reply_lanman2(struct smb_request *req, uint16_t choice)
        status = smbXsrv_connection_init_tables(xconn, PROTOCOL_LANMAN2);
        if (!NT_STATUS_IS_OK(status)) {
                reply_nterror(req, status);
-               return;
+               return status;
        }
 
        /* Reply, SMBlockread, SMBwritelock supported. */
@@ -169,6 +169,7 @@ static void reply_lanman2(struct smb_request *req, uint16_t choice)
        SSVAL(req->outbuf,smb_vwv5,raw); /* readbraw and/or writebraw */
        SSVAL(req->outbuf,smb_vwv10, set_server_zone_offset(t)/60);
        srv_put_dos_date((char *)req->outbuf,smb_vwv8,t);
+       return NT_STATUS_OK;
 }
 
 /****************************************************************************
@@ -266,7 +267,7 @@ DATA_BLOB negprot_spnego(TALLOC_CTX *ctx, struct smbXsrv_connection *xconn)
  Reply for the nt protocol.
 ****************************************************************************/
 
-static void reply_nt1(struct smb_request *req, uint16_t choice)
+static NTSTATUS reply_nt1(struct smb_request *req, uint16_t choice)
 {
        /* dual names + lock_and_read + nt SMBs + remote API calls */
        int capabilities = CAP_NT_FIND|CAP_LOCK_AND_READ|
@@ -359,7 +360,7 @@ static void reply_nt1(struct smb_request *req, uint16_t choice)
        status = smbXsrv_connection_init_tables(xconn, PROTOCOL_NT1);
        if (!NT_STATUS_IS_OK(status)) {
                reply_nterror(req, status);
-               return;
+               return status;
        }
 
        SSVAL(req->outbuf,smb_vwv1+1, lp_max_mux()); /* maxmpx */
@@ -385,7 +386,7 @@ static void reply_nt1(struct smb_request *req, uint16_t choice)
                        if (ret == -1) {
                                DEBUG(0, ("Could not push challenge\n"));
                                reply_nterror(req, NT_STATUS_NO_MEMORY);
-                               return;
+                               return NT_STATUS_NO_MEMORY;
                        }
                        SCVAL(req->outbuf, smb_vwv16+1, ret);
                }
@@ -395,7 +396,7 @@ static void reply_nt1(struct smb_request *req, uint16_t choice)
                if (ret == -1) {
                        DEBUG(0, ("Could not push workgroup string\n"));
                        reply_nterror(req, NT_STATUS_NO_MEMORY);
-                       return;
+                       return NT_STATUS_NO_MEMORY;
                }
                ret = message_push_string(&req->outbuf, lp_netbios_name(),
                                          STR_UNICODE|STR_TERMINATE
@@ -403,7 +404,7 @@ static void reply_nt1(struct smb_request *req, uint16_t choice)
                if (ret == -1) {
                        DEBUG(0, ("Could not push netbios name string\n"));
                        reply_nterror(req, NT_STATUS_NO_MEMORY);
-                       return;
+                       return NT_STATUS_NO_MEMORY;
                }
                DEBUG(3,("not using SPNEGO\n"));
        } else {
@@ -411,14 +412,14 @@ static void reply_nt1(struct smb_request *req, uint16_t choice)
 
                if (spnego_blob.data == NULL) {
                        reply_nterror(req, NT_STATUS_NO_MEMORY);
-                       return;
+                       return NT_STATUS_NO_MEMORY;
                }
 
                ret = message_push_blob(&req->outbuf, spnego_blob);
                if (ret == -1) {
                        DEBUG(0, ("Could not push spnego blob\n"));
                        reply_nterror(req, NT_STATUS_NO_MEMORY);
-                       return;
+                       return NT_STATUS_NO_MEMORY;
                }
                data_blob_free(&spnego_blob);
 
@@ -426,7 +427,7 @@ static void reply_nt1(struct smb_request *req, uint16_t choice)
                DEBUG(3,("using SPNEGO\n"));
        }
 
-       return;
+       return NT_STATUS_OK;
 }
 
 /* these are the protocol lists used for auto architecture detection:
@@ -540,7 +541,7 @@ protocol [SMB 2.???]
 static const struct {
        const char *proto_name;
        const char *short_name;
-       void (*proto_reply_fn)(struct smb_request *req, uint16_t choice);
+       NTSTATUS (*proto_reply_fn)(struct smb_request *req, uint16_t choice);
        int protocol_level;
 } supported_protocols[] = {
        {"SMB 2.???",               "SMB2_FF",  reply_smb20ff,  PROTOCOL_SMB2_10},
index fc0d884ad1da34afe4891b1b5ca85d7456df7f03..1785fcf5ee8850f4758631b9c6d77d2328bb1967 100644 (file)
@@ -71,20 +71,20 @@ static NTSTATUS reply_smb20xx(struct smb_request *req, uint16_t dialect)
  * this is the entry point if SMB2 is selected via
  * the SMB negprot and the "SMB 2.002" dialect.
  */
-void reply_smb2002(struct smb_request *req, uint16_t choice)
+NTSTATUS reply_smb2002(struct smb_request *req, uint16_t choice)
 {
-       reply_smb20xx(req, SMB2_DIALECT_REVISION_202);
+       return reply_smb20xx(req, SMB2_DIALECT_REVISION_202);
 }
 
 /*
  * this is the entry point if SMB2 is selected via
  * the SMB negprot and the "SMB 2.???" dialect.
  */
-void reply_smb20ff(struct smb_request *req, uint16_t choice)
+NTSTATUS reply_smb20ff(struct smb_request *req, uint16_t choice)
 {
        struct smbXsrv_connection *xconn = req->xconn;
        xconn->smb2.allow_2ff = true;
-       reply_smb20xx(req, SMB2_DIALECT_REVISION_2FF);
+       return reply_smb20xx(req, SMB2_DIALECT_REVISION_2FF);
 }
 
 enum protocol_types smbd_smb2_protocol_dialect_match(const uint8_t *indyn,