From: Andrew Bartlett Date: Tue, 21 Aug 2012 04:23:35 +0000 (+1000) Subject: s3-pysmbd: Add hook for a VFS chown() X-Git-Url: http://git.samba.org/?a=commitdiff_plain;h=d963aaf73be22b0a027b3636c6c51292412b5931;p=obnox%2Fsamba%2Fsamba-obnox.git s3-pysmbd: Add hook for a VFS chown() --- diff --git a/source3/smbd/pysmbd.c b/source3/smbd/pysmbd.c index 0004887720d..0e8ecaacf14 100644 --- a/source3/smbd/pysmbd.c +++ b/source3/smbd/pysmbd.c @@ -273,6 +273,56 @@ static PyObject *py_smbd_set_simple_acl(PyObject *self, PyObject *args) Py_RETURN_NONE; } +/* + chown a file + */ +static PyObject *py_smbd_chown(PyObject *self, PyObject *args) +{ + connection_struct *conn; + NTSTATUS status = NT_STATUS_OK; + int ret; + + char *fname; + int uid, gid; + TALLOC_CTX *frame; + + if (!PyArg_ParseTuple(args, "sii", &fname, &uid, &gid)) + return NULL; + + frame = talloc_stackframe(); + + conn = talloc_zero(frame, connection_struct); + if (conn == NULL) { + PyErr_NoMemory(); + return NULL; + } + + if (!(conn->params = talloc(conn, struct share_params))) { + PyErr_NoMemory(); + return NULL; + } + + conn->params->service = -1; + + set_conn_connectpath(conn, "/"); + + smbd_vfs_init(conn); + + ret = SMB_VFS_CHOWN( conn, fname, uid, gid); + if (ret != 0) { + status = map_nt_error_from_unix_common(ret); + DEBUG(0,("chwon returned failure: %s\n", strerror(ret))); + } + + conn_free(conn); + + TALLOC_FREE(frame); + + PyErr_NTSTATUS_IS_ERR_RAISE(status); + + Py_RETURN_NONE; +} + /* check if we have ACL support */ @@ -347,6 +397,9 @@ static PyMethodDef py_smbd_methods[] = { { "get_nt_acl", (PyCFunction)py_smbd_get_nt_acl, METH_VARARGS, NULL }, + { "chown", + (PyCFunction)py_smbd_chown, METH_VARARGS, + NULL }, { NULL } };