/*
set a simple ACL on a file, as a test
*/
-static PyObject *py_smbd_set_simple_acl(PyObject *self, PyObject *args)
+static PyObject *py_smbd_set_simple_acl(PyObject *self, PyObject *args, PyObject *kwargs)
{
+ const char * const kwnames[] = { "fname", "mode", "gid", "service", NULL };
NTSTATUS status;
char *fname, *service = NULL;
int mode, gid = -1;
TALLOC_CTX *frame;
connection_struct *conn;
- if (!PyArg_ParseTuple(args, "si|iz", &fname, &mode, &gid, &service))
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs, "si|iz",
+ discard_const_p(char *, kwnames),
+ &fname, &mode, &gid, &service))
return NULL;
acl = make_simple_acl(gid, mode);
/*
chown a file
*/
-static PyObject *py_smbd_chown(PyObject *self, PyObject *args)
+static PyObject *py_smbd_chown(PyObject *self, PyObject *args, PyObject *kwargs)
{
+ const char * const kwnames[] = { "fname", "uid", "gid", "service", NULL };
connection_struct *conn;
NTSTATUS status = NT_STATUS_OK;
int ret;
TALLOC_CTX *frame;
mode_t saved_umask;
- if (!PyArg_ParseTuple(args, "sii|z", &fname, &uid, &gid, &service))
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs, "sii|z",
+ discard_const_p(char *, kwnames),
+ &fname, &uid, &gid, &service))
return NULL;
frame = talloc_stackframe();
/*
chown a file
*/
-static PyObject *py_smbd_unlink(PyObject *self, PyObject *args)
+static PyObject *py_smbd_unlink(PyObject *self, PyObject *args, PyObject *kwargs)
{
+ const char * const kwnames[] = { "fname", "service", NULL };
connection_struct *conn;
NTSTATUS status = NT_STATUS_OK;
int ret;
frame = talloc_stackframe();
- if (!PyArg_ParseTuple(args, "s|z", &fname, &service)) {
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s|z",
+ discard_const_p(char *, kwnames),
+ &fname, &service)) {
TALLOC_FREE(frame);
return NULL;
}
/*
check if we have ACL support
*/
-static PyObject *py_smbd_have_posix_acls(PyObject *self, PyObject *args)
+static PyObject *py_smbd_have_posix_acls(PyObject *self)
{
#ifdef HAVE_POSIX_ACLS
return PyBool_FromLong(true);
/*
set the NT ACL on a file
*/
-static PyObject *py_smbd_set_nt_acl(PyObject *self, PyObject *args)
+static PyObject *py_smbd_set_nt_acl(PyObject *self, PyObject *args, PyObject *kwargs)
{
+ const char * const kwnames[] = { "fname", "security_info_sent", "sd", "service", NULL };
NTSTATUS status;
char *fname, *service = NULL;
int security_info_sent;
frame = talloc_stackframe();
- if (!PyArg_ParseTuple(args, "siO|z", &fname, &security_info_sent, &py_sd, &service)) {
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ "siO|z", discard_const_p(char *, kwnames),
+ &fname, &security_info_sent, &py_sd, &service)) {
TALLOC_FREE(frame);
return NULL;
}
/*
Return the NT ACL on a file
*/
-static PyObject *py_smbd_get_nt_acl(PyObject *self, PyObject *args)
+static PyObject *py_smbd_get_nt_acl(PyObject *self, PyObject *args, PyObject *kwargs)
{
+ const char * const kwnames[] = { "fname", "security_info_wanted", "service", NULL };
char *fname, *service = NULL;
int security_info_wanted;
PyObject *py_sd;
connection_struct *conn;
NTSTATUS status;
- if (!PyArg_ParseTuple(args, "si|z", &fname, &security_info_wanted, &service)) {
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs, "si|z", discard_const_p(char *, kwnames),
+ &fname, &security_info_wanted, &service)) {
TALLOC_FREE(tmp_ctx);
return NULL;
}
/*
set the posix (or similar) ACL on a file
*/
-static PyObject *py_smbd_set_sys_acl(PyObject *self, PyObject *args)
+static PyObject *py_smbd_set_sys_acl(PyObject *self, PyObject *args, PyObject *kwargs)
{
+ const char * const kwnames[] = { "fname", "acl_type", "acl", "service", NULL };
TALLOC_CTX *frame = talloc_stackframe();
NTSTATUS status;
char *fname, *service = NULL;
int acl_type;
connection_struct *conn;
- if (!PyArg_ParseTuple(args, "siO|z", &fname, &acl_type, &py_acl, &service)) {
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs, "siO|z",
+ discard_const_p(char *, kwnames),
+ &fname, &acl_type, &py_acl, &service)) {
TALLOC_FREE(frame);
return NULL;
}
/*
Return the posix (or similar) ACL on a file
*/
-static PyObject *py_smbd_get_sys_acl(PyObject *self, PyObject *args)
+static PyObject *py_smbd_get_sys_acl(PyObject *self, PyObject *args, PyObject *kwargs)
{
+ const char * const kwnames[] = { "fname", "acl_type", "service", NULL };
char *fname;
PyObject *py_acl;
struct smb_acl_t *acl;
return NULL;
}
- if (!PyArg_ParseTuple(args, "si|z", &fname, &acl_type, &service)) {
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs, "si|z",
+ discard_const_p(char *, kwnames),
+ &fname, &acl_type, &service)) {
TALLOC_FREE(frame);
TALLOC_FREE(tmp_ctx);
return NULL;
static PyMethodDef py_smbd_methods[] = {
{ "have_posix_acls",
- (PyCFunction)py_smbd_have_posix_acls, METH_VARARGS,
+ (PyCFunction)py_smbd_have_posix_acls, METH_NOARGS,
NULL },
{ "set_simple_acl",
- (PyCFunction)py_smbd_set_simple_acl, METH_VARARGS,
+ (PyCFunction)py_smbd_set_simple_acl, METH_VARARGS|METH_KEYWORDS,
NULL },
{ "set_nt_acl",
- (PyCFunction)py_smbd_set_nt_acl, METH_VARARGS,
+ (PyCFunction)py_smbd_set_nt_acl, METH_VARARGS|METH_KEYWORDS,
NULL },
{ "get_nt_acl",
- (PyCFunction)py_smbd_get_nt_acl, METH_VARARGS,
+ (PyCFunction)py_smbd_get_nt_acl, METH_VARARGS|METH_KEYWORDS,
NULL },
{ "get_sys_acl",
- (PyCFunction)py_smbd_get_sys_acl, METH_VARARGS,
+ (PyCFunction)py_smbd_get_sys_acl, METH_VARARGS|METH_KEYWORDS,
NULL },
{ "set_sys_acl",
- (PyCFunction)py_smbd_set_sys_acl, METH_VARARGS,
+ (PyCFunction)py_smbd_set_sys_acl, METH_VARARGS|METH_KEYWORDS,
NULL },
{ "chown",
- (PyCFunction)py_smbd_chown, METH_VARARGS,
+ (PyCFunction)py_smbd_chown, METH_VARARGS|METH_KEYWORDS,
NULL },
{ "unlink",
- (PyCFunction)py_smbd_unlink, METH_VARARGS,
+ (PyCFunction)py_smbd_unlink, METH_VARARGS|METH_KEYWORDS,
NULL },
{ NULL }
};
elif ntacl.version == 4:
return ntacl.info.sd
else:
- return smbd.get_nt_acl(file, security.SECINFO_OWNER | security.SECINFO_GROUP | security.SECINFO_DACL | security.SECINFO_SACL, service)
+ return smbd.get_nt_acl(file, security.SECINFO_OWNER | security.SECINFO_GROUP | security.SECINFO_DACL | security.SECINFO_SACL, service=service)
def setntacl(lp, file, sddl, domsid, backend=None, eadbfile=None, use_ntvfs=True, skip_invalid_chown=False, passdb=None, service=None):
sd2 = sd
sd2.owner_sid = administrator
- smbd.set_nt_acl(file, security.SECINFO_OWNER |security.SECINFO_GROUP | security.SECINFO_DACL | security.SECINFO_SACL, sd2, service)
+ smbd.set_nt_acl(file, security.SECINFO_OWNER |security.SECINFO_GROUP | security.SECINFO_DACL | security.SECINFO_SACL, sd2, service=service)
# and then set an NTVFS ACL (which does not set the posix ACL) to pretend the owner really was set
use_ntvfs = True
# This won't work in test environments, as it tries a real (rather than xattr-based fake) chown
os.chown(file, 0, 0)
- smbd.set_nt_acl(file, security.SECINFO_GROUP | security.SECINFO_DACL | security.SECINFO_SACL, sd, service)
+ smbd.set_nt_acl(file, security.SECINFO_GROUP | security.SECINFO_DACL | security.SECINFO_SACL, sd, service=service)
if use_ntvfs:
(backend_obj, dbname) = checkset_backend(lp, backend, eadbfile)
samba.xattr_native.wrap_setxattr(file, xattr.XATTR_NTACL_NAME,
ndr_pack(ntacl))
else:
- smbd.set_nt_acl(file, security.SECINFO_OWNER | security.SECINFO_GROUP | security.SECINFO_DACL | security.SECINFO_SACL, sd, service)
+ smbd.set_nt_acl(file, security.SECINFO_OWNER | security.SECINFO_GROUP | security.SECINFO_DACL | security.SECINFO_SACL, sd, service=service)
def ldapmask2filemask(ldm):