summaryrefslogtreecommitdiff
path: root/source3/python
diff options
context:
space:
mode:
authorTim Potter <tpot@samba.org>2002-05-28 02:09:54 +0000
committerTim Potter <tpot@samba.org>2002-05-28 02:09:54 +0000
commite99a265bad36f2525a5b04734ff996e66b624711 (patch)
treebb68aeb7a79f786f9669f4ddc06aa13c0d2224cd /source3/python
parentd21f10d3e65ebdee7db8e4c122a0a623b65bcd49 (diff)
downloadsamba-e99a265bad36f2525a5b04734ff996e66b624711.tar.gz
samba-e99a265bad36f2525a5b04734ff996e66b624711.tar.bz2
samba-e99a265bad36f2525a5b04734ff996e66b624711.zip
Allow None to be used as a valid credential for functions that take a
credential as a parameter. (This used to be commit 166aee6cc2abb5f6e91ebf3d4ec37454034b8dcd)
Diffstat (limited to 'source3/python')
-rw-r--r--source3/python/py_samr.c10
-rw-r--r--source3/python/py_spoolss_drivers.c30
-rw-r--r--source3/python/py_spoolss_ports.c9
-rw-r--r--source3/python/py_spoolss_printers.c18
4 files changed, 54 insertions, 13 deletions
diff --git a/source3/python/py_samr.c b/source3/python/py_samr.c
index f715f891b4..733a57c1d4 100644
--- a/source3/python/py_samr.c
+++ b/source3/python/py_samr.c
@@ -283,10 +283,16 @@ static PyObject *samr_connect(PyObject *self, PyObject *args, PyObject *kw)
NTSTATUS ntstatus;
if (!PyArg_ParseTupleAndKeywords(
- args, kw, "s|O!i", kwlist, &server, &PyDict_Type,
- &creds, &desired_access))
+ args, kw, "s|Oi", kwlist, &server, &creds,
+ &desired_access))
return NULL;
+ if (creds && creds != Py_None && !PyDict_Check(creds)) {
+ PyErr_SetString(PyExc_TypeError,
+ "credentials must be dictionary or None");
+ return NULL;
+ }
+
if (!(cli = open_pipe_creds(server, creds, PIPE_SAMR, &errstr))) {
PyErr_SetString(samr_error, errstr);
free(errstr);
diff --git a/source3/python/py_spoolss_drivers.c b/source3/python/py_spoolss_drivers.c
index 9b7a8d3294..19fe5800aa 100644
--- a/source3/python/py_spoolss_drivers.c
+++ b/source3/python/py_spoolss_drivers.c
@@ -38,8 +38,8 @@ PyObject *spoolss_enumprinterdrivers(PyObject *self, PyObject *args,
/* Parse parameters */
if (!PyArg_ParseTupleAndKeywords(
- args, kw, "s|iO!s", kwlist, &server, &level, &PyDict_Type,
- &creds, &arch))
+ args, kw, "s|iOs", kwlist, &server, &level, &creds,
+ &arch))
return NULL;
if (server[0] != '\\' || server[1] != '\\') {
@@ -49,6 +49,12 @@ PyObject *spoolss_enumprinterdrivers(PyObject *self, PyObject *args,
server += 2;
+ if (creds && creds != Py_None && !PyDict_Check(creds)) {
+ PyErr_SetString(PyExc_TypeError,
+ "credentials must be dictionary or None");
+ return NULL;
+ }
+
/* Call rpc function */
if (!(cli = open_pipe_creds(server, creds, PIPE_SPOOLSS, &errstr))) {
@@ -248,8 +254,8 @@ PyObject *spoolss_getprinterdriverdir(PyObject *self, PyObject *args,
/* Parse parameters */
if (!PyArg_ParseTupleAndKeywords(
- args, kw, "s|isO!", kwlist, &server, &level,
- &arch, &PyDict_Type, &creds))
+ args, kw, "s|isO", kwlist, &server, &level,
+ &arch, &creds))
return NULL;
if (server[0] != '\\' || server[1] != '\\') {
@@ -259,6 +265,12 @@ PyObject *spoolss_getprinterdriverdir(PyObject *self, PyObject *args,
server += 2;
+ if (creds && creds != Py_None && !PyDict_Check(creds)) {
+ PyErr_SetString(PyExc_TypeError,
+ "credentials must be dictionary or None");
+ return NULL;
+ }
+
/* Call rpc function */
if (!(cli = open_pipe_creds(server, creds, PIPE_SPOOLSS, &errstr))) {
@@ -324,13 +336,19 @@ PyObject *spoolss_addprinterdriver(PyObject *self, PyObject *args,
} dinfo;
if (!PyArg_ParseTupleAndKeywords(
- args, kw, "sO!|O!", kwlist, &server, &PyDict_Type,
- &info, &PyDict_Type, &creds))
+ args, kw, "sO!|O", kwlist, &server, &PyDict_Type,
+ &info, &creds))
return NULL;
if (server[0] == '\\' && server[1] == '\\')
server += 2;
+ if (creds && creds != Py_None && !PyDict_Check(creds)) {
+ PyErr_SetString(PyExc_TypeError,
+ "credentials must be dictionary or None");
+ return NULL;
+ }
+
if (!(mem_ctx = talloc_init())) {
PyErr_SetString(
spoolss_error, "unable to init talloc context\n");
diff --git a/source3/python/py_spoolss_ports.c b/source3/python/py_spoolss_ports.c
index f0bea5175d..8d59274a00 100644
--- a/source3/python/py_spoolss_ports.c
+++ b/source3/python/py_spoolss_ports.c
@@ -37,13 +37,18 @@ PyObject *spoolss_enumports(PyObject *self, PyObject *args, PyObject *kw)
/* Parse parameters */
if (!PyArg_ParseTupleAndKeywords(
- args, kw, "s|iO!", kwlist, &server, &level,
- &PyDict_Type, &creds))
+ args, kw, "s|iO", kwlist, &server, &level, &creds))
return NULL;
if (server[0] == '\\' && server[1] == '\\')
server += 2;
+ if (creds && creds != Py_None && !PyDict_Check(creds)) {
+ PyErr_SetString(PyExc_TypeError,
+ "credentials must be dictionary or None");
+ return NULL;
+ }
+
if (!(cli = open_pipe_creds(server, creds, PIPE_SPOOLSS, &errstr))) {
PyErr_SetString(spoolss_error, errstr);
free(errstr);
diff --git a/source3/python/py_spoolss_printers.c b/source3/python/py_spoolss_printers.c
index aa5f636b06..934bfcc818 100644
--- a/source3/python/py_spoolss_printers.c
+++ b/source3/python/py_spoolss_printers.c
@@ -34,7 +34,7 @@ PyObject *spoolss_openprinter(PyObject *self, PyObject *args, PyObject *kw)
struct cli_state *cli;
if (!PyArg_ParseTupleAndKeywords(
- args, kw, "s|O!i", kwlist, &unc_name, &PyDict_Type, &creds,
+ args, kw, "s|Oi", kwlist, &unc_name, &creds,
&desired_access))
return NULL;
@@ -50,6 +50,12 @@ PyObject *spoolss_openprinter(PyObject *self, PyObject *args, PyObject *kw)
*c = 0;
}
+ if (creds && creds != Py_None && !PyDict_Check(creds)) {
+ PyErr_SetString(PyExc_TypeError,
+ "credentials must be dictionary or None");
+ return NULL;
+ }
+
if (!(cli = open_pipe_creds(server, creds, PIPE_SPOOLSS, &errstr))) {
PyErr_SetString(spoolss_error, errstr);
free(errstr);
@@ -286,13 +292,19 @@ PyObject *spoolss_enumprinters(PyObject *self, PyObject *args, PyObject *kw)
/* Parse parameters */
if (!PyArg_ParseTupleAndKeywords(
- args, kw, "s|siiO!", kwlist, &server, &name, &level,
- &flags, &PyDict_Type, &creds))
+ args, kw, "s|siiO", kwlist, &server, &name, &level,
+ &flags, &creds))
return NULL;
if (server[0] == '\\' && server[1] == '\\')
server += 2;
+ if (creds && creds != Py_None && !PyDict_Check(creds)) {
+ PyErr_SetString(PyExc_TypeError,
+ "credentials must be dictionary or None");
+ return NULL;
+ }
+
if (!(cli = open_pipe_creds(server, creds, PIPE_SPOOLSS, &errstr))) {
PyErr_SetString(spoolss_error, errstr);
free(errstr);