[PATCH] Add retrieving the correct servername for the rpc-spoolss-notify test

Volker Lendecke vl at samba.org
Mon Jan 28 18:33:54 GMT 2008


---
 source/torture/rpc/spoolss_notify.c |   30 +++++++++++++++++++++++++++++-
 1 files changed, 29 insertions(+), 1 deletions(-)

diff --git a/source/torture/rpc/spoolss_notify.c b/source/torture/rpc/spoolss_notify.c
index 0065101..7b54bef 100644
--- a/source/torture/rpc/spoolss_notify.c
+++ b/source/torture/rpc/spoolss_notify.c
@@ -20,7 +20,10 @@
 */
 
 #include "includes.h"
+#include "libcli/raw/libcliraw.h"
+#include "libcli/rap/rap.h"
 #include "torture/torture.h"
+#include "torture/rap/proto.h"
 #include "torture/ui.h"
 #include "torture/rpc/rpc.h"
 #include "librpc/gen_ndr/ndr_spoolss_c.h"
@@ -190,16 +193,41 @@ static bool test_RFFPCNEx(struct torture_context *tctx,
 	const char *endpoints[] = { "spoolss", NULL };
 	struct spoolss_NotifyOptionsContainer t1;
 	struct spoolss_ClosePrinter cp;
+	struct smbcli_tree *tree;
 
 	struct policy_handle handle;
 	const char *address;
 	struct interface *ifaces;
+	const char *servername = NULL;
 
 	ntvfs_init(tctx->lp_ctx);
 
 	ZERO_STRUCT(q);
 
-	q.in.printername	= talloc_asprintf(tctx, "\\\\%s", dcerpc_server_name(p));
+	tree = dcerpc_smb_tree(p->conn);
+	if (tree != NULL) {
+		struct rap_WserverGetInfo g;
+
+		g.in.level = 0;
+		g.in.bufsize = 0xffff;
+
+		status = smbcli_rap_netservergetinfo(tree, tctx, &g);
+
+		if (NT_STATUS_IS_OK(status)) {
+			char tmp[17];
+			char *name;
+			memcpy(tmp, g.out.info.info0.name, sizeof(tmp)-1);
+			tmp[sizeof(tmp)-1] = '\0';
+			pull_ascii_talloc(tctx, &name, tmp);
+			servername = name;
+		}
+	}
+
+	if (servername == NULL) {
+		servername = dcerpc_server_name(p);
+	}
+
+	q.in.printername	= talloc_asprintf(tctx, "\\\\%s", servername);
 	q.in.datatype		= NULL;
 	q.in.devmode_ctr.devmode= NULL;
 	q.in.access_mask	= SEC_FLAG_MAXIMUM_ALLOWED;
-- 
1.5.3.7



More information about the samba-technical mailing list