summaryrefslogtreecommitdiff
path: root/source3/python
diff options
context:
space:
mode:
authorSimo Sorce <idra@samba.org>2003-08-02 20:06:57 +0000
committerSimo Sorce <idra@samba.org>2003-08-02 20:06:57 +0000
commit04bf12b176d5abe06b7f1401810369bcafe0b611 (patch)
tree8bb6627c3ffa4cab902787b874206f8012a33e3a /source3/python
parent7efce478976e2ac71bcaf4e4d1049bb263634711 (diff)
downloadsamba-04bf12b176d5abe06b7f1401810369bcafe0b611.tar.gz
samba-04bf12b176d5abe06b7f1401810369bcafe0b611.tar.bz2
samba-04bf12b176d5abe06b7f1401810369bcafe0b611.zip
port latest changes from SAMBA_3_0 tree
(This used to be commit 3101c236b8241dc0183995ffceed551876427de4)
Diffstat (limited to 'source3/python')
-rw-r--r--source3/python/py_common.c2
-rw-r--r--source3/python/py_lsa.c27
-rw-r--r--source3/python/py_ntsec.c39
-rw-r--r--source3/python/py_smb.c42
-rw-r--r--source3/python/py_winbind.c6
5 files changed, 87 insertions, 29 deletions
diff --git a/source3/python/py_common.c b/source3/python/py_common.c
index ea092d9370..02d22bbdab 100644
--- a/source3/python/py_common.c
+++ b/source3/python/py_common.c
@@ -223,7 +223,7 @@ struct cli_state *open_pipe_creds(char *server, PyObject *creds,
result = cli_full_connection(
&cli, NULL, server, NULL, 0, "IPC$", "IPC",
- username, domain, password, 0, NULL);
+ username, domain, password, 0, Undefined, NULL);
if (!NT_STATUS_IS_OK(result)) {
*errstr = strdup("error connecting to IPC$ pipe");
diff --git a/source3/python/py_lsa.c b/source3/python/py_lsa.c
index c063dcba81..4204f43f7b 100644
--- a/source3/python/py_lsa.c
+++ b/source3/python/py_lsa.c
@@ -213,6 +213,7 @@ static PyObject *lsa_lookup_sids(PyObject *self, PyObject *args,
char **domains, **names;
uint32 *types;
lsa_policy_hnd_object *hnd = (lsa_policy_hnd_object *)self;
+ TALLOC_CTX *mem_ctx = NULL;
DOM_SID *sids;
if (!PyArg_ParseTuple(args, "O", &py_sids))
@@ -223,12 +224,17 @@ static PyObject *lsa_lookup_sids(PyObject *self, PyObject *args,
return NULL;
}
+ if (!(mem_ctx = talloc_init("lsa_open_policy"))) {
+ PyErr_SetString(lsa_error, "unable to init talloc context\n");
+ goto done;
+ }
+
if (PyList_Check(py_sids)) {
/* Convert dictionary to char ** array */
num_sids = PyList_Size(py_sids);
- sids = (DOM_SID *)talloc(hnd->mem_ctx, num_sids * sizeof(DOM_SID));
+ sids = (DOM_SID *)talloc(mem_ctx, num_sids * sizeof(DOM_SID));
memset(sids, 0, num_sids * sizeof(DOM_SID));
@@ -237,7 +243,8 @@ static PyObject *lsa_lookup_sids(PyObject *self, PyObject *args,
if (!string_to_sid(&sids[i], PyString_AsString(obj))) {
PyErr_SetString(PyExc_ValueError, "string_to_sid failed");
- return NULL;
+ result = NULL;
+ goto done;
}
}
@@ -246,21 +253,23 @@ static PyObject *lsa_lookup_sids(PyObject *self, PyObject *args,
/* Just a single element */
num_sids = 1;
- sids = (DOM_SID *)talloc(hnd->mem_ctx, sizeof(DOM_SID));
+ sids = (DOM_SID *)talloc(mem_ctx, sizeof(DOM_SID));
if (!string_to_sid(&sids[0], PyString_AsString(py_sids))) {
PyErr_SetString(PyExc_ValueError, "string_to_sid failed");
- return NULL;
+ result = NULL;
+ goto done;
}
}
- ntstatus = cli_lsa_lookup_sids(hnd->cli, hnd->mem_ctx, &hnd->pol,
+ ntstatus = cli_lsa_lookup_sids(hnd->cli, mem_ctx, &hnd->pol,
num_sids, sids, &domains, &names,
&types);
if (!NT_STATUS_IS_OK(ntstatus)) {
PyErr_SetObject(lsa_ntstatus, py_ntstatus_tuple(ntstatus));
- return NULL;
+ result = NULL;
+ goto done;
}
result = PyList_New(num_sids);
@@ -274,7 +283,11 @@ static PyObject *lsa_lookup_sids(PyObject *self, PyObject *args,
PyList_SetItem(result, i, obj);
}
-
+
+ done:
+ if (mem_ctx)
+ talloc_destroy(mem_ctx);
+
return result;
}
diff --git a/source3/python/py_ntsec.c b/source3/python/py_ntsec.c
index 47524d8e19..3d408e0bda 100644
--- a/source3/python/py_ntsec.c
+++ b/source3/python/py_ntsec.c
@@ -58,14 +58,14 @@ BOOL py_from_ACE(PyObject **dict, SEC_ACE *ace)
return True;
}
- *dict = PyDict_New();
-
- PyDict_SetItemString(*dict, "type", PyInt_FromLong(ace->type));
- PyDict_SetItemString(*dict, "flags", PyInt_FromLong(ace->flags));
- PyDict_SetItemString(*dict, "mask", PyInt_FromLong(ace->info.mask));
+ *dict = Py_BuildValue("{sisisi}", "type", ace->type,
+ "flags", ace->flags,
+ "mask", ace->info.mask);
- if (py_from_SID(&obj, &ace->trustee))
+ if (py_from_SID(&obj, &ace->trustee)) {
PyDict_SetItemString(*dict, "trustee", obj);
+ Py_DECREF(obj);
+ }
return True;
}
@@ -125,10 +125,6 @@ BOOL py_from_ACL(PyObject **dict, SEC_ACL *acl)
return True;
}
- *dict = PyDict_New();
-
- PyDict_SetItemString(*dict, "revision", PyInt_FromLong(acl->revision));
-
ace_list = PyList_New(acl->num_aces);
for (i = 0; i < acl->num_aces; i++) {
@@ -138,7 +134,8 @@ BOOL py_from_ACL(PyObject **dict, SEC_ACL *acl)
PyList_SetItem(ace_list, i, obj);
}
- PyDict_SetItemString(*dict, "ace_list", ace_list);
+ *dict = Py_BuildValue("{sisN}", "revision", acl->revision,
+ "ace_list", ace_list);
return True;
}
@@ -181,19 +178,29 @@ BOOL py_from_SECDESC(PyObject **dict, SEC_DESC *sd)
*dict = PyDict_New();
- PyDict_SetItemString(*dict, "revision", PyInt_FromLong(sd->revision));
+ obj = PyInt_FromLong(sd->revision);
+ PyDict_SetItemString(*dict, "revision", obj);
+ Py_DECREF(obj);
- if (py_from_SID(&obj, sd->owner_sid))
+ if (py_from_SID(&obj, sd->owner_sid)) {
PyDict_SetItemString(*dict, "owner_sid", obj);
+ Py_DECREF(obj);
+ }
- if (py_from_SID(&obj, sd->grp_sid))
+ if (py_from_SID(&obj, sd->grp_sid)) {
PyDict_SetItemString(*dict, "group_sid", obj);
+ Py_DECREF(obj);
+ }
- if (py_from_ACL(&obj, sd->dacl))
+ if (py_from_ACL(&obj, sd->dacl)) {
PyDict_SetItemString(*dict, "dacl", obj);
+ Py_DECREF(obj);
+ }
- if (py_from_ACL(&obj, sd->sacl))
+ if (py_from_ACL(&obj, sd->sacl)) {
PyDict_SetItemString(*dict, "sacl", obj);
+ Py_DECREF(obj);
+ }
return True;
}
diff --git a/source3/python/py_smb.c b/source3/python/py_smb.c
index d37b73cceb..bb84a337c9 100644
--- a/source3/python/py_smb.c
+++ b/source3/python/py_smb.c
@@ -238,7 +238,8 @@ static PyObject *py_smb_query_secdesc(PyObject *self, PyObject *args,
if (cli_is_error(cli->cli)) {
PyErr_SetString(PyExc_RuntimeError, "query_secdesc failed");
- return NULL;
+ result = NULL;
+ goto done;
}
if (!secdesc) {
@@ -342,11 +343,48 @@ static PyMethodDef smb_methods[] = {
{ "connect", (PyCFunction)py_smb_connect, METH_VARARGS | METH_KEYWORDS,
"Connect to a host" },
+ /* Other stuff - this should really go into a samba config module
+ but for the moment let's leave it here. */
+
+ { "setup_logging", (PyCFunction)py_setup_logging,
+ METH_VARARGS | METH_KEYWORDS,
+ "Set up debug logging.\n"
+"\n"
+"Initialises Samba's debug logging system. One argument is expected which\n"
+"is a boolean specifying whether debugging is interactive and sent to stdout\n"
+"or logged to a file.\n"
+"\n"
+"Example:\n"
+"\n"
+">>> smb.setup_logging(interactive = 1)" },
+
+ { "get_debuglevel", (PyCFunction)get_debuglevel,
+ METH_VARARGS,
+ "Set the current debug level.\n"
+"\n"
+"Example:\n"
+"\n"
+">>> smb.get_debuglevel()\n"
+"0" },
+
+ { "set_debuglevel", (PyCFunction)set_debuglevel,
+ METH_VARARGS,
+ "Get the current debug level.\n"
+"\n"
+"Example:\n"
+"\n"
+">>> smb.set_debuglevel(10)" },
+
{ NULL }
};
static void py_cli_state_dealloc(PyObject* self)
{
+ cli_state_object *cli = (cli_state_object *)self;
+
+ if (cli->cli)
+ cli_shutdown(cli->cli);
+
PyObject_Del(self);
}
@@ -395,5 +433,5 @@ void initsmb(void)
py_samba_init();
setup_logging("smb", True);
- DEBUGLEVEL = 10;
+ DEBUGLEVEL = 3;
}
diff --git a/source3/python/py_winbind.c b/source3/python/py_winbind.c
index db66be2321..ebceb95d71 100644
--- a/source3/python/py_winbind.c
+++ b/source3/python/py_winbind.c
@@ -259,14 +259,14 @@ static PyObject *py_config_dict(void)
PyDict_SetItemString(result, "template_shell",
PyString_FromString(lp_template_shell()));
- /* Winbind uid/gid range */
+ /* idmap uid/gid range */
- if (lp_winbind_uid(&ulow, &uhi)) {
+ if (lp_idmap_uid(&ulow, &uhi)) {
PyDict_SetItemString(result, "uid_low", PyInt_FromLong(ulow));
PyDict_SetItemString(result, "uid_high", PyInt_FromLong(uhi));
}
- if (lp_winbind_gid(&glow, &ghi)) {
+ if (lp_idmap_gid(&glow, &ghi)) {
PyDict_SetItemString(result, "gid_low", PyInt_FromLong(glow));
PyDict_SetItemString(result, "gid_high", PyInt_FromLong(ghi));
}