From: Volker Lendecke Date: Sun, 16 Oct 2022 17:41:58 +0000 (+0200) Subject: pylibsmb: Add smb1_posix() to request smb1 posix extensions X-Git-Tag: talloc-2.4.0~505 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=98a627b93f475d2da9882db1abeb44f6ecad38cf;p=thirdparty%2Fsamba.git pylibsmb: Add smb1_posix() to request smb1 posix extensions Signed-off-by: Volker Lendecke Reviewed-by: Jeremy Allison --- diff --git a/source3/libsmb/pylibsmb.c b/source3/libsmb/pylibsmb.c index 3101f66d779..dc4c0f48d96 100644 --- a/source3/libsmb/pylibsmb.c +++ b/source3/libsmb/pylibsmb.c @@ -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 } };