summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source4/build/pidl/swig.pm6
-rw-r--r--source4/scripting/swig/dcerpc.i17
-rw-r--r--source4/scripting/swig/torture/spoolss.py27
3 files changed, 48 insertions, 2 deletions
diff --git a/source4/build/pidl/swig.pm b/source4/build/pidl/swig.pm
index 20b658b19f..55ded24f21 100644
--- a/source4/build/pidl/swig.pm
+++ b/source4/build/pidl/swig.pm
@@ -97,7 +97,11 @@ sub FieldFromPython($$)
}
if ($e->{TYPE} eq "DATA_BLOB") {
- $result .= "\tDATA_BLOB_ptr_from_python(mem_ctx, &s->$prefix$e->{NAME}, $obj, \"$e->{NAME}\");\n";
+ if ($e->{POINTERS} == 0) {
+ $result .= "\tDATA_BLOB_from_python(mem_ctx, &s->$prefix$e->{NAME}, $obj, \"$e->{NAME}\");\n";
+ } else {
+ $result .= "\tDATA_BLOB_ptr_from_python(mem_ctx, &s->$prefix$e->{NAME}, $obj, \"$e->{NAME}\");\n";
+ }
return $result;
}
diff --git a/source4/scripting/swig/dcerpc.i b/source4/scripting/swig/dcerpc.i
index 796384d6e7..c7e2d79c12 100644
--- a/source4/scripting/swig/dcerpc.i
+++ b/source4/scripting/swig/dcerpc.i
@@ -254,6 +254,23 @@ PyObject *string_ptr_to_python(TALLOC_CTX *mem_ctx, char *obj)
#define dom_sid2_ptr_to_python dom_sid_ptr_to_python
#define dom_sid2_ptr_from_python dom_sid_ptr_from_python
+void DATA_BLOB_from_python(TALLOC_CTX *mem_ctx, DATA_BLOB *s,
+ PyObject *obj, char name)
+{
+ if (obj == NULL) {
+ PyErr_Format(PyExc_ValueError, "Expecting key %s", name);
+ return;
+ }
+
+ if (!PyString_Check(obj)) {
+ PyErr_Format(PyExc_TypeError, "Expecting string value for key '%s'", name);
+ return;
+ }
+
+ s->length = PyString_Size(obj);
+ s->data = PyString_AsString(obj);
+}
+
void DATA_BLOB_ptr_from_python(TALLOC_CTX *mem_ctx, DATA_BLOB **s,
PyObject *obj, char *name)
{
diff --git a/source4/scripting/swig/torture/spoolss.py b/source4/scripting/swig/torture/spoolss.py
index 4779c278f2..ef8b3150e1 100644
--- a/source4/scripting/swig/torture/spoolss.py
+++ b/source4/scripting/swig/torture/spoolss.py
@@ -267,7 +267,31 @@ def test_EnumPrinterData(pipe, handle):
enum_index += 1
- sys.exit(1)
+def test_SetPrinterData(pipe, handle):
+
+ print 'testing spoolss_SetPrinterData'
+
+ valuename = '__printerdatatest__'
+ data = '12345'
+
+ r = {}
+ r['handle'] = handle
+ r['value_name'] = valuename
+ r['type'] = 3 # REG_BINARY
+ r['buffer'] = data
+ r['real_len'] = 5
+
+ dcerpc.spoolss_SetPrinterData(pipe, r)
+
+ s = {}
+ s['handle'] = handle
+ s['value_name'] = valuename
+
+ result = ResizeBufferCall(dcerpc.spoolss_GetPrinterData, pipe, r)
+
+ if result['buffer'] != data:
+ print 'SetPrinterData: mismatch'
+ sys.exit(1)
def test_EnumPrinters(pipe):
@@ -321,6 +345,7 @@ def test_EnumPrinters(pipe):
test_AddForm(pipe, handle)
test_EnumJobs(pipe, handle)
test_EnumPrinterData(pipe, handle)
+ test_SetPrinterData(pipe, handle)
test_ClosePrinter(pipe, handle)