svn commit: samba r19202 - in branches/SAMBA_4_0/source/torture/rpc: .

vlendec at samba.org vlendec at samba.org
Mon Oct 9 11:52:57 GMT 2006


Author: vlendec
Date: 2006-10-09 11:52:57 +0000 (Mon, 09 Oct 2006)
New Revision: 19202

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

Log:
Make RPC-SAMBA3-SPOOLSS work against w2k3 again
Modified:
   branches/SAMBA_4_0/source/torture/rpc/samba3rpc.c


Changeset:
Modified: branches/SAMBA_4_0/source/torture/rpc/samba3rpc.c
===================================================================
--- branches/SAMBA_4_0/source/torture/rpc/samba3rpc.c	2006-10-09 11:31:55 UTC (rev 19201)
+++ branches/SAMBA_4_0/source/torture/rpc/samba3rpc.c	2006-10-09 11:52:57 UTC (rev 19202)
@@ -22,8 +22,10 @@
 
 #include "includes.h"
 #include "libcli/raw/libcliraw.h"
+#include "libcli/rap/rap.h"
 #include "torture/torture.h"
 #include "torture/util.h"
+#include "torture/rap/proto.h"
 #include "librpc/gen_ndr/ndr_lsa.h"
 #include "librpc/gen_ndr/ndr_lsa_c.h"
 #include "librpc/gen_ndr/ndr_samr.h"
@@ -2171,6 +2173,32 @@
 	return ret;
 }
 
+static NTSTATUS get_servername(TALLOC_CTX *mem_ctx, struct smbcli_tree *tree,
+			       char **name)
+{
+	struct rap_WserverGetInfo r;
+	NTSTATUS status;
+	char servername[17];
+
+	r.in.level = 0;
+	r.in.bufsize = 0xffff;
+
+	status = smbcli_rap_netservergetinfo(tree, mem_ctx, &r);
+	if (!NT_STATUS_IS_OK(status)) {
+		return status;
+	}
+
+	memcpy(servername, r.out.info.info0.name, 16);
+	servername[16] = '\0';
+
+	if (pull_ascii_talloc(mem_ctx, name, servername) < 0) {
+		return NT_STATUS_NO_MEMORY;
+	}
+
+	return NT_STATUS_OK;
+}
+
+
 static NTSTATUS find_printers(TALLOC_CTX *ctx, struct smbcli_tree *tree,
 			      const char ***printers, int *num_printers)
 {
@@ -2230,14 +2258,14 @@
 }
 
 static BOOL enumprinters(TALLOC_CTX *mem_ctx, struct dcerpc_pipe *pipe,
-			 int level, int *num_printers)
+			 const char *servername, int level, int *num_printers)
 {
 	struct spoolss_EnumPrinters r;
 	NTSTATUS status;
 	DATA_BLOB blob;
 
 	r.in.flags = PRINTER_ENUM_LOCAL;
-	r.in.server = "\\\\localhost";
+	r.in.server = talloc_asprintf(mem_ctx, "\\\\%s", servername);
 	r.in.level = level;
 	r.in.buffer = NULL;
 	r.in.offered = 0;
@@ -2354,6 +2382,7 @@
 	const char **printers;
 	int num_printers;
 	struct spoolss_UserLevel1 userlevel1;
+	char *servername;
 
 	if (!(mem_ctx = talloc_new(torture))) {
 		return False;
@@ -2367,6 +2396,14 @@
 		return False;
 	}
 
+	status = get_servername(mem_ctx, cli->tree, &servername);
+	if (!NT_STATUS_IS_OK(status)) {
+		d_fprintf(stderr, "(%s) get_servername returned %s\n",
+			  __location__, nt_errstr(status));
+		talloc_free(mem_ctx);
+		return False;
+	}
+
 	if (!NT_STATUS_IS_OK(find_printers(mem_ctx, cli->tree,
 					   &printers, &num_printers))) {
 		talloc_free(mem_ctx);
@@ -2401,7 +2438,8 @@
 		struct spoolss_OpenPrinterEx r;
 
 		ZERO_STRUCT(r);
-		r.in.printername = "\\\\localhost";
+		r.in.printername = talloc_asprintf(mem_ctx, "\\\\%s",
+						   servername);
 		r.in.datatype = NULL;
 		r.in.access_mask = 0;
 		r.in.level = 1;
@@ -2451,7 +2489,7 @@
 
 		ZERO_STRUCT(r);
 		r.in.printername = talloc_asprintf(
-			mem_ctx, "\\\\localhost\\%s", printers[0]);
+			mem_ctx, "\\\\%s\\%s", servername, printers[0]);
 		r.in.datatype = NULL;
 		r.in.access_mask = 0;
 		r.in.level = 1;
@@ -2510,7 +2548,8 @@
 
 	{
 		int num_enumerated;
-		if (!enumprinters(mem_ctx, p, 1, &num_enumerated)) {
+		if (!enumprinters(mem_ctx, p, servername, 1,
+				  &num_enumerated)) {
 			d_printf("(%s) enumprinters failed\n", __location__);
 			talloc_free(mem_ctx);
 			return False;
@@ -2526,7 +2565,8 @@
 
 	{
 		int num_enumerated;
-		if (!enumprinters(mem_ctx, p, 2, &num_enumerated)) {
+		if (!enumprinters(mem_ctx, p, servername, 2,
+				  &num_enumerated)) {
 			d_printf("(%s) enumprinters failed\n", __location__);
 			talloc_free(mem_ctx);
 			return False;



More information about the samba-cvs mailing list