svn commit: samba r7328 - in branches/SAMBA_4_0/source: include librpc/idl librpc/ndr torture/rpc

metze at samba.org metze at samba.org
Mon Jun 6 09:59:43 GMT 2005


Author: metze
Date: 2005-06-06 09:59:43 +0000 (Mon, 06 Jun 2005)
New Revision: 7328

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=7328

Log:
fix GetPrinterData and SetPrinterData, with zero length subcontexts

metze
Modified:
   branches/SAMBA_4_0/source/include/structs.h
   branches/SAMBA_4_0/source/librpc/idl/spoolss.idl
   branches/SAMBA_4_0/source/librpc/ndr/ndr_spoolss_buf.c
   branches/SAMBA_4_0/source/torture/rpc/spoolss.c


Changeset:
Modified: branches/SAMBA_4_0/source/include/structs.h
===================================================================
--- branches/SAMBA_4_0/source/include/structs.h	2005-06-06 09:52:07 UTC (rev 7327)
+++ branches/SAMBA_4_0/source/include/structs.h	2005-06-06 09:59:43 UTC (rev 7328)
@@ -37,6 +37,8 @@
 union spoolss_PortInfo;
 union spoolss_MonitorInfo;
 union spoolss_PrintProcessorInfo;
+struct spoolss_GetPrinterData;
+struct spoolss_SetPrinterData;
 
 struct drsuapi_DsReplicaObjectListItem;
 struct drsuapi_DsReplicaObjectListItemEx;

Modified: branches/SAMBA_4_0/source/librpc/idl/spoolss.idl
===================================================================
--- branches/SAMBA_4_0/source/librpc/idl/spoolss.idl	2005-06-06 09:52:07 UTC (rev 7327)
+++ branches/SAMBA_4_0/source/librpc/idl/spoolss.idl	2005-06-06 09:59:43 UTC (rev 7328)
@@ -652,23 +652,45 @@
 		[default,flag(NDR_REMAINING)] DATA_BLOB data;
 	} spoolss_PrinterData;
 
-	WERROR spoolss_GetPrinterData(
+	[noopnum,nopush,noprint,public] WERROR _spoolss_GetPrinterData(
 		[in,ref] policy_handle *handle,
 		[in] unistr value_name,
 		[out] spoolss_PrinterDataType type,
+		[out] DATA_BLOB data,
+		[in,out,ref] uint32 *buf_size
+	);
+	[noopnum,nopush,noprint,public] void __spoolss_GetPrinterData(
+		[in] spoolss_PrinterDataType type,
+		[out,switch_is(type)] spoolss_PrinterData data
+	);
+	[nopull] WERROR spoolss_GetPrinterData(
+		[in,ref] policy_handle *handle,
+		[in] unistr value_name,
+		[out] spoolss_PrinterDataType type,
 		[out,subcontext(4),switch_is(type)] spoolss_PrinterData data,
 		[in,out,ref] uint32 *buf_size
 	);
 
 	/******************/
 	/* Function: 0x1b */
-	WERROR spoolss_SetPrinterData(	
+	[noopnum,nopull,noprint,public] WERROR _spoolss_SetPrinterData(
 		[in,ref] policy_handle *handle,
 		[in] unistr value_name,
-		[in] uint32 type,
-		[in] DATA_BLOB buffer,
-		[in] uint32 real_len
+		[in] spoolss_PrinterDataType type,
+		[in] DATA_BLOB data,
+		[in] uint32 _buf_size
 	);
+	[noopnum,nopull,noprint,public] void __spoolss_SetPrinterData(
+		[in] spoolss_PrinterDataType type,
+		[out,switch_is(type)] spoolss_PrinterData data
+	);
+	[nopush] WERROR spoolss_SetPrinterData(
+		[in,ref] policy_handle *handle,
+		[in] unistr value_name,
+		[in] spoolss_PrinterDataType type,
+		[in,subcontext(4),switch_is(type)] spoolss_PrinterData data,
+		[in,value(ndr_size_spoolss_PrinterData(&r->in.data,r->in.type,flags))] uint32 _buf_size
+	);
 
 	/******************/
 	/* Function: 0x1c */

Modified: branches/SAMBA_4_0/source/librpc/ndr/ndr_spoolss_buf.c
===================================================================
--- branches/SAMBA_4_0/source/librpc/ndr/ndr_spoolss_buf.c	2005-06-06 09:52:07 UTC (rev 7327)
+++ branches/SAMBA_4_0/source/librpc/ndr/ndr_spoolss_buf.c	2005-06-06 09:59:43 UTC (rev 7328)
@@ -350,3 +350,94 @@
 {
 	NDR_SPOOLSS_SIZE_ENUM(spoolss_EnumPrintProcessors);
 }
+
+/*
+  spoolss_GetPrinterData
+*/
+NTSTATUS ndr_pull_spoolss_GetPrinterData(struct ndr_pull *ndr, int flags, struct spoolss_GetPrinterData *r)
+{
+	struct _spoolss_GetPrinterData _r;
+	if (flags & NDR_IN) {
+		ZERO_STRUCT(r->out);
+
+		_r.in.handle	= r->in.handle;
+		_r.in.value_name= r->in.value_name;
+		_r.in.buf_size	= r->in.buf_size;
+		_r.out.type	= r->out.type;
+		_r.out.data	= data_blob(NULL,0),
+		_r.out.buf_size	= r->out.buf_size;
+		NDR_CHECK(ndr_pull__spoolss_GetPrinterData(ndr, flags, &_r));
+		r->in.handle	= _r.in.handle;
+		r->in.value_name= _r.in.value_name;
+		r->in.buf_size	= _r.in.buf_size;
+	}
+	if (flags & NDR_OUT) {
+		_r.in.handle	= r->in.handle;
+		_r.in.value_name= r->in.value_name;
+		_r.in.buf_size	= r->in.buf_size;
+		_r.out.type	= r->out.type;
+		_r.out.data	= data_blob(NULL,0),
+		_r.out.buf_size	= r->out.buf_size;
+		_r.out.result	= r->out.result;
+		NDR_CHECK(ndr_pull__spoolss_GetPrinterData(ndr, flags, &_r));
+		r->out.type	= _r.out.type;
+		ZERO_STRUCT(r->out.data);
+		r->out.buf_size	= _r.out.buf_size;
+		r->out.result	= _r.out.result;
+		if (_r.out.data.length > 0) {
+			struct __spoolss_GetPrinterData __r;
+			struct ndr_pull *_ndr_data = ndr_pull_init_blob(&_r.out.data, ndr);\
+			if (!_ndr_data) return NT_STATUS_NO_MEMORY;\
+			_ndr_data->flags= ndr->flags;\
+			__r.in.type	= r->out.type;
+			__r.out.data	= r->out.data;
+			NDR_CHECK(ndr_pull___spoolss_GetPrinterData(_ndr_data, flags, &__r));
+			r->out.data	= __r.out.data;
+		} else {
+			r->out.type	= SPOOLSS_PRINTER_DATA_TYPE_NULL;
+		}
+	}
+	return NT_STATUS_OK;
+}
+
+/*
+  spoolss_SetPrinterData
+*/
+NTSTATUS ndr_push_spoolss_SetPrinterData(struct ndr_push *ndr, int flags, struct spoolss_SetPrinterData *r)
+{
+	struct _spoolss_SetPrinterData _r;
+	if (flags & NDR_IN) {
+		struct ndr_push *_ndr_data;
+		struct __spoolss_SetPrinterData __r;
+		DATA_BLOB _data_blob_data;
+
+		_ndr_data = ndr_push_init_ctx(ndr);\
+		if (!_ndr_data) return NT_STATUS_NO_MEMORY;\
+		_ndr_data->flags= ndr->flags;\
+
+		__r.in.type	= r->in.type;
+		__r.out.data	= r->in.data;
+		NDR_CHECK(ndr_push___spoolss_SetPrinterData(_ndr_data, NDR_OUT, &__r));
+		_data_blob_data = ndr_push_blob(_ndr_data);
+
+		r->in._buf_size	= _data_blob_data.length;
+
+		_r.in.handle	= r->in.handle;
+		_r.in.value_name= r->in.value_name;
+		_r.in.type	= r->in.type;
+		_r.in.data	= _data_blob_data;
+		_r.in._buf_size	= r->in._buf_size;
+		_r.out.result	= r->out.result;
+		NDR_CHECK(ndr_push__spoolss_SetPrinterData(ndr, flags, &_r));
+	}
+	if (flags & NDR_OUT) {
+		_r.in.handle	= r->in.handle;
+		_r.in.value_name= r->in.value_name;
+		_r.in.type	= r->in.type;
+		_r.in.data	= data_blob(NULL,0),
+		_r.in._buf_size	= r->in._buf_size;
+		_r.out.result	= r->out.result;
+		NDR_CHECK(ndr_push__spoolss_SetPrinterData(ndr, flags, &_r));
+	}
+	return NT_STATUS_OK;
+}

Modified: branches/SAMBA_4_0/source/torture/rpc/spoolss.c
===================================================================
--- branches/SAMBA_4_0/source/torture/rpc/spoolss.c	2005-06-06 09:52:07 UTC (rev 7327)
+++ branches/SAMBA_4_0/source/torture/rpc/spoolss.c	2005-06-06 09:59:43 UTC (rev 7328)
@@ -1324,9 +1324,8 @@
 	
 	r.in.handle = handle;
 	r.in.value_name = value_name;
-	r.in.type = 0;
-	r.in.buffer = data_blob_talloc(mem_ctx, "dog", 4);
-	r.in.real_len = 4;
+	r.in.type = SPOOLSS_PRINTER_DATA_TYPE_STRING;
+	r.in.data.string = "dog";
 
 	printf("Testing SetPrinterData\n");
 
@@ -1337,6 +1336,10 @@
 		return False;
 	}
 
+	if (!test_GetPrinterData(p, mem_ctx, handle, value_name)) {
+		return False;
+	}
+
 	if (!test_DeletePrinterData(p, mem_ctx, handle, value_name)) {
 		return False;
 	}
@@ -1828,7 +1831,7 @@
 
 	ret &= test_GetPrinterData(ctx->p, ctx, &ctx->server_handle, "Architecture");
 
-	/*ret &= test_GetPrinterData(ctx->p, ctx, &ctx->server_handle, "DefaultSpoolDirectory");*/
+	ret &= test_GetPrinterData(ctx->p, ctx, &ctx->server_handle, "DefaultSpoolDirectory");
 
 	ret &= test_EnumPorts(ctx);
 



More information about the samba-cvs mailing list