summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2012-08-21 14:23:35 +1000
committerAndrew Bartlett <abartlet@samba.org>2012-08-21 15:25:49 +1000
commitd963aaf73be22b0a027b3636c6c51292412b5931 (patch)
tree17dd52e0689da2a08839d50d9847e5936b7eabb8 /source3
parent4d5471f1c634450020c4530f8d0c8dfcd7252fb3 (diff)
downloadsamba-d963aaf73be22b0a027b3636c6c51292412b5931.tar.gz
samba-d963aaf73be22b0a027b3636c6c51292412b5931.tar.bz2
samba-d963aaf73be22b0a027b3636c6c51292412b5931.zip
s3-pysmbd: Add hook for a VFS chown()
Diffstat (limited to 'source3')
-rw-r--r--source3/smbd/pysmbd.c53
1 files changed, 53 insertions, 0 deletions
diff --git a/source3/smbd/pysmbd.c b/source3/smbd/pysmbd.c
index 0004887720..0e8ecaacf1 100644
--- a/source3/smbd/pysmbd.c
+++ b/source3/smbd/pysmbd.c
@@ -274,6 +274,56 @@ static PyObject *py_smbd_set_simple_acl(PyObject *self, PyObject *args)
}
/*
+ 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
*/
static PyObject *py_smbd_have_posix_acls(PyObject *self, PyObject *args)
@@ -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 }
};