From: Joe Guo Date: Fri, 1 Jun 2018 01:40:42 +0000 (+1200) Subject: pysmbd: add py_smbd_mkdir X-Git-Tag: tevent-0.9.37~198 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=f1566c2ef9af0ca86778a58f855e1602ac43c3c2;p=thirdparty%2Fsamba.git pysmbd: add py_smbd_mkdir Add mkdir for smbd API. Signed-off-by: Joe Guo Reviewed-by: Andrew Bartlett Reviewed-by: Douglas Bagnall --- diff --git a/source3/smbd/pysmbd.c b/source3/smbd/pysmbd.c index ee918e1d727..a63194aa166 100644 --- a/source3/smbd/pysmbd.c +++ b/source3/smbd/pysmbd.c @@ -697,6 +697,54 @@ static PyObject *py_smbd_get_sys_acl(PyObject *self, PyObject *args, PyObject *k return py_acl; } +static PyObject *py_smbd_mkdir(PyObject *self, PyObject *args, PyObject *kwargs) +{ + const char * const kwnames[] = { "fname", "service", NULL }; + char *fname, *service = NULL; + TALLOC_CTX *frame = talloc_stackframe(); + struct connection_struct *conn = NULL; + struct smb_filename *smb_fname = NULL; + + if (!PyArg_ParseTupleAndKeywords(args, + kwargs, + "s|z", + discard_const_p(char *, + kwnames), + &fname, + &service)) { + TALLOC_FREE(frame); + return NULL; + } + + conn = get_conn_tos(service); + if (!conn) { + TALLOC_FREE(frame); + return NULL; + } + + smb_fname = synthetic_smb_fname(talloc_tos(), + fname, + NULL, + NULL, + lp_posix_pathnames() ? + SMB_FILENAME_POSIX_PATH : 0); + + if (smb_fname == NULL) { + TALLOC_FREE(frame); + return NULL; + } + + + if (SMB_VFS_MKDIR(conn, smb_fname, 00755) == -1) { + DBG_ERR("mkdir error=%d (%s)\n", errno, strerror(errno)); + TALLOC_FREE(frame); + return NULL; + } + + TALLOC_FREE(frame); + Py_RETURN_NONE; +} + static PyMethodDef py_smbd_methods[] = { { "have_posix_acls", (PyCFunction)py_smbd_have_posix_acls, METH_NOARGS, @@ -722,6 +770,9 @@ static PyMethodDef py_smbd_methods[] = { { "unlink", (PyCFunction)py_smbd_unlink, METH_VARARGS|METH_KEYWORDS, NULL }, + { "mkdir", + (PyCFunction)py_smbd_mkdir, METH_VARARGS|METH_KEYWORDS, + NULL }, { NULL } };