s3:smbd: allow SMB 2.002 dialect in SMB1 negprot
authorStefan Metzmacher <metze@samba.org>
Tue, 19 May 2009 08:47:51 +0000 (10:47 +0200)
committerStefan Metzmacher <metze@samba.org>
Wed, 20 May 2009 13:43:00 +0000 (15:43 +0200)
We create a dummy SMB2 Negotiate inbuf and pass the
connection to the SMB2 engine.

metze

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

index 22e4837bf3aaf149fcd3fa037e5eed5f39f5cdba..d0935e10f1f78747395e6f0af6a07ffe066a6577 100644 (file)
@@ -206,6 +206,7 @@ DATA_BLOB negprot_spnego(void);
 
 bool smbd_is_smb2_header(const uint8_t *inbuf, size_t size);
 
+void reply_smb2002(struct smb_request *req, uint16_t choice);
 void smbd_smb2_first_negprot(struct smbd_server_connection *conn,
                             const uint8_t *inbuf, size_t size);
 
index b3eb698a37c25e967afefede3fe14f44636d4288..6d15f486df3a480bf44d08a0ace8ba8a74ba696d 100644 (file)
@@ -481,6 +481,7 @@ static const struct {
        void (*proto_reply_fn)(struct smb_request *req, uint16 choice);
        int protocol_level;
 } supported_protocols[] = {
+       {"SMB 2.002",               "SMB2",     reply_smb2002,  PROTOCOL_SMB2},
        {"NT LANMAN 1.0",           "NT1",      reply_nt1,      PROTOCOL_NT1},
        {"NT LM 0.12",              "NT1",      reply_nt1,      PROTOCOL_NT1},
        {"POSIX 2",                 "NT1",      reply_nt1,      PROTOCOL_NT1},
index d82d04885df1c2a6b0ac3f43963263774694cf4f..38dfe6dab3a26c178262d2363329729dd1aafa83 100644 (file)
 
 extern enum protocol_types Protocol;
 
+/*
+ * this is the entry point if SMB2 is selected via
+ * the SMB negprot
+ */
+void reply_smb2002(struct smb_request *req, uint16_t choice)
+{
+       uint8_t *smb2_inbuf;
+       uint8_t *smb2_hdr;
+       uint8_t *smb2_body;
+       uint8_t *smb2_dyn;
+       size_t len = 4 + SMB2_HDR_BODY + 0x24 + 2;
+
+       smb2_inbuf = talloc_zero_array(talloc_tos(), uint8_t, len);
+       if (smb2_inbuf == NULL) {
+               DEBUG(0, ("Could not push spnego blob\n"));
+               reply_nterror(req, NT_STATUS_NO_MEMORY);
+               return;
+       }
+       smb2_hdr = smb2_inbuf + 4;
+       smb2_body = smb2_hdr + SMB2_HDR_BODY;
+       smb2_dyn = smb2_body + 0x24;
+
+       SIVAL(smb2_hdr, SMB2_HDR_PROTOCOL_ID,   SMB2_MAGIC);
+       SIVAL(smb2_hdr, SMB2_HDR_LENGTH,        SMB2_HDR_BODY);
+
+       SSVAL(smb2_body, 0x00, 0x0024); /* struct size */
+       SSVAL(smb2_body, 0x02, 0x0001); /* dialect count */
+
+       SSVAL(smb2_dyn,  0x00, 0x0202); /* dialect 2.002 */
+
+       req->outbuf = NULL;
+
+       smbd_smb2_first_negprot(smbd_server_conn, smb2_inbuf, len);
+       return;
+}
+
 NTSTATUS smbd_smb2_request_process_negprot(struct smbd_smb2_request *req)
 {
        const uint8_t *inbody;