diff options
author | Joe Guo <joeg@catalyst.net.nz> | 2018-06-01 13:40:42 +1200 |
---|---|---|
committer | Andrew Bartlett <abartlet@samba.org> | 2018-06-28 09:25:09 +0200 |
commit | f1566c2ef9af0ca86778a58f855e1602ac43c3c2 (patch) | |
tree | 60a8c556c54896e3814b79eb92b3430c15dae06e /source3 | |
parent | 4320dcc4bc32ef26c2bd512b94e3bc9aedb9d192 (diff) | |
download | samba-f1566c2ef9af0ca86778a58f855e1602ac43c3c2.tar.gz |
pysmbd: add py_smbd_mkdir
Add mkdir for smbd API.
Signed-off-by: Joe Guo <joeg@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Diffstat (limited to 'source3')
-rw-r--r-- | source3/smbd/pysmbd.c | 51 |
1 files changed, 51 insertions, 0 deletions
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 } }; |