s3:pylibsmb: remember that a connection uses SMB1
authorStefan Metzmacher <metze@samba.org>
Tue, 4 Dec 2018 09:42:55 +0000 (10:42 +0100)
committerStefan Metzmacher <metze@samba.org>
Thu, 13 Dec 2018 07:52:23 +0000 (08:52 +0100)
BUG: https://bugzilla.samba.org/show_bug.cgi?id=7113
BUG: https://bugzilla.samba.org/show_bug.cgi?id=11892
BUG: https://bugzilla.samba.org/show_bug.cgi?id=13676

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Tim Beale <timbeale@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
source3/libsmb/pylibsmb.c

index ed3c041d4ff7a37ef85597b9e8f01006aa1dd7d8..e4552a2d68a24b07c7f754fa5b0f4499ecdab010 100644 (file)
@@ -21,6 +21,7 @@
 #include <Python.h>
 #include "includes.h"
 #include "python/py3compat.h"
+#include "libcli/smb/smbXcli_base.h"
 #include "libsmb/libsmb.h"
 #include "libcli/security/security.h"
 #include "system/select.h"
@@ -80,6 +81,7 @@ struct py_cli_oplock_break {
 struct py_cli_state {
        PyObject_HEAD
        struct cli_state *cli;
+       bool is_smb1;
        struct tevent_context *ev;
        int (*req_wait_fn)(struct tevent_context *ev,
                           struct tevent_req *req);
@@ -403,6 +405,7 @@ static PyObject *py_cli_state_new(PyTypeObject *type, PyObject *args,
                return NULL;
        }
        self->cli = NULL;
+       self->is_smb1 = false;
        self->ev = NULL;
        self->thread_state = NULL;
        self->oplock_waiter = NULL;
@@ -519,6 +522,10 @@ static int py_cli_state_init(struct py_cli_state *self, PyObject *args,
                return -1;
        }
 
+       if (smbXcli_conn_protocol(self->cli->conn) < PROTOCOL_SMB2_02) {
+               self->is_smb1 = true;
+       }
+
        self->oplock_waiter = cli_smb_oplock_break_waiter_send(
                self->ev, self->ev, self->cli);
        if (self->oplock_waiter == NULL) {