summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2012-08-21 15:11:30 +1000
committerAndrew Bartlett <abartlet@samba.org>2012-08-21 15:25:50 +1000
commitdc063bf3bdf06aff1582c5c8784a8e0d5b06d378 (patch)
tree653709f10339439ac265e8b227a26c0a50e5a3ad
parent4df2c65ea637618971c406f05e68a93feb44c70c (diff)
downloadsamba-dc063bf3bdf06aff1582c5c8784a8e0d5b06d378.tar.gz
samba-dc063bf3bdf06aff1582c5c8784a8e0d5b06d378.tar.bz2
samba-dc063bf3bdf06aff1582c5c8784a8e0d5b06d378.zip
s3-pysmbd: Add get/set functions for the posix ACL layer
These will be used to verify that an ACL set as an NT ACL creates the correct posix ACL. Andrew Bartlett
-rw-r--r--source3/smbd/pysmbd.c89
1 files changed, 89 insertions, 0 deletions
diff --git a/source3/smbd/pysmbd.c b/source3/smbd/pysmbd.c
index 45362f8ccc..8fca4e77b7 100644
--- a/source3/smbd/pysmbd.c
+++ b/source3/smbd/pysmbd.c
@@ -384,6 +384,89 @@ static PyObject *py_smbd_get_nt_acl(PyObject *self, PyObject *args)
return py_sd;
}
+/*
+ set the posix (or similar) ACL on a file
+ */
+static PyObject *py_smbd_set_sys_acl(PyObject *self, PyObject *args)
+{
+ NTSTATUS status;
+ char *fname;
+ PyObject *py_acl;
+ struct smb_acl_t *acl;
+ int acl_type;
+
+ if (!PyArg_ParseTuple(args, "siO", &fname, &acl_type, &py_acl))
+ return NULL;
+
+ if (!py_check_dcerpc_type(py_acl, "samba.dcerpc.smb_acl", "sys_acl_t")) {
+ return NULL;
+ }
+
+ acl = pytalloc_get_type(py_acl, struct smb_acl_t);
+
+ status = set_sys_acl_no_snum(fname, acl_type, acl);
+ PyErr_NTSTATUS_IS_ERR_RAISE(status);
+
+ Py_RETURN_NONE;
+}
+
+/*
+ Return the posix (or similar) ACL on a file
+ */
+static PyObject *py_smbd_get_sys_acl(PyObject *self, PyObject *args)
+{
+ char *fname;
+ PyObject *py_acl;
+ struct smb_acl_t *acl;
+ int acl_type;
+ TALLOC_CTX *frame = talloc_stackframe();
+ connection_struct *conn;
+ NTSTATUS status = NT_STATUS_OK;
+
+ if (!PyArg_ParseTuple(args, "si", &fname, &acl_type)) {
+ TALLOC_FREE(frame);
+ return NULL;
+ }
+
+ conn = talloc_zero(frame, connection_struct);
+ if (conn == NULL) {
+ DEBUG(0, ("talloc failed\n"));
+ PyErr_NoMemory();
+ TALLOC_FREE(frame);
+ return NULL;
+ }
+
+ if (!(conn->params = talloc(conn, struct share_params))) {
+ DEBUG(0,("get_nt_acl_no_snum: talloc() failed!\n"));
+ PyErr_NoMemory();
+ TALLOC_FREE(frame);
+ return NULL;
+ }
+
+ conn->params->service = -1;
+
+ set_conn_connectpath(conn, "/");
+
+ smbd_vfs_init(conn);
+
+ acl = SMB_VFS_SYS_ACL_GET_FILE( conn, fname, acl_type);
+ if (!acl) {
+ TALLOC_FREE(frame);
+ status = map_nt_error_from_unix_common(errno);
+ DEBUG(0,("sys_acl_get_file returned NULL: %s\n", strerror(errno)));
+ PyErr_NTSTATUS_IS_ERR_RAISE(status);
+ }
+
+ talloc_steal(frame, acl);
+ conn_free(conn);
+
+ py_acl = py_return_ndr_struct("samba.dcerpc.smb_acl", "sys_acl_t", acl, acl);
+
+ TALLOC_FREE(frame);
+
+ return py_acl;
+}
+
static PyMethodDef py_smbd_methods[] = {
{ "have_posix_acls",
(PyCFunction)py_smbd_have_posix_acls, METH_VARARGS,
@@ -397,6 +480,12 @@ static PyMethodDef py_smbd_methods[] = {
{ "get_nt_acl",
(PyCFunction)py_smbd_get_nt_acl, METH_VARARGS,
NULL },
+ { "get_sys_acl",
+ (PyCFunction)py_smbd_get_sys_acl, METH_VARARGS,
+ NULL },
+ { "set_sys_acl",
+ (PyCFunction)py_smbd_set_sys_acl, METH_VARARGS,
+ NULL },
{ "chown",
(PyCFunction)py_smbd_chown, METH_VARARGS,
NULL },