]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
pylibsmb: Add smb1_posix() to request smb1 posix extensions
authorVolker Lendecke <vl@samba.org>
Sun, 16 Oct 2022 17:41:58 +0000 (19:41 +0200)
committerJeremy Allison <jra@samba.org>
Tue, 22 Nov 2022 18:27:33 +0000 (18:27 +0000)
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/libsmb/pylibsmb.c

index 3101f66d7796f680af87c894f79c2a20a4d4717c..dc4c0f48d96e72c25ef4817256b16c17c7d27793 100644 (file)
@@ -2323,6 +2323,48 @@ static PyObject *py_smb_set_sd(struct py_cli_state *self, PyObject *args)
        Py_RETURN_NONE;
 }
 
+static PyObject *py_smb_smb1_posix(
+       struct py_cli_state *self, PyObject *Py_UNUSED(ignored))
+{
+       NTSTATUS status;
+       struct tevent_req *req = NULL;
+       uint16_t major, minor;
+       uint32_t caplow, caphigh;
+       PyObject *result = NULL;
+
+       req = cli_unix_extensions_version_send(NULL, self->ev, self->cli);
+       if (!py_tevent_req_wait_exc(self, req)) {
+               return NULL;
+       }
+       status = cli_unix_extensions_version_recv(
+               req, &major, &minor, &caplow, &caphigh);
+       TALLOC_FREE(req);
+       if (!NT_STATUS_IS_OK(status)) {
+               PyErr_SetNTSTATUS(status);
+               return NULL;
+       }
+
+       req = cli_set_unix_extensions_capabilities_send(
+               NULL, self->ev, self->cli, major, minor, caplow, caphigh);
+       if (!py_tevent_req_wait_exc(self, req)) {
+               return NULL;
+       }
+       status = cli_set_unix_extensions_capabilities_recv(req);
+       TALLOC_FREE(req);
+       if (!NT_STATUS_IS_OK(status)) {
+               PyErr_SetNTSTATUS(status);
+               return NULL;
+       }
+
+       result = Py_BuildValue(
+               "[IIII]",
+               (unsigned)minor,
+               (unsigned)major,
+               (unsigned)caplow,
+               (unsigned)caphigh);
+       return result;
+}
+
 static PyMethodDef py_cli_state_methods[] = {
        { "settimeout", (PyCFunction)py_cli_settimeout, METH_VARARGS,
          "settimeout(new_timeout_msecs) => return old_timeout_msecs" },
@@ -2404,6 +2446,11 @@ static PyMethodDef py_cli_state_methods[] = {
          "have_posix() -> True/False\n\n"
          "\t\tReturn if the server has posix extensions"
        },
+       { "smb1_posix",
+         (PyCFunction)py_smb_smb1_posix,
+         METH_NOARGS,
+         "Negotiate SMB1 posix extensions",
+       },
        { NULL, NULL, 0, NULL }
 };