summaryrefslogtreecommitdiff
path: root/source4/torture
diff options
context:
space:
mode:
authorVolker Lendecke <vlendec@samba.org>2006-10-09 11:52:57 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 14:20:53 -0500
commit22abc6b927eae03aae238b016022a40e2fab8d36 (patch)
tree27afdcbd043cf40e249c42b8ecfa10017a252906 /source4/torture
parent51b4a41d52c464005e288064d25c4ee8c5203c0a (diff)
downloadsamba-22abc6b927eae03aae238b016022a40e2fab8d36.tar.gz
samba-22abc6b927eae03aae238b016022a40e2fab8d36.tar.bz2
samba-22abc6b927eae03aae238b016022a40e2fab8d36.zip
r19202: Make RPC-SAMBA3-SPOOLSS work against w2k3 again
(This used to be commit f67a0159d107238a0b2197777fb2d51596f66097)
Diffstat (limited to 'source4/torture')
-rw-r--r--source4/torture/rpc/samba3rpc.c52
1 files changed, 46 insertions, 6 deletions
diff --git a/source4/torture/rpc/samba3rpc.c b/source4/torture/rpc/samba3rpc.c
index ecc0378471..91a86387ff 100644
--- a/source4/torture/rpc/samba3rpc.c
+++ b/source4/torture/rpc/samba3rpc.c
@@ -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 @@ BOOL torture_samba3_rpc_lsa(struct torture_context *torture)
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 NTSTATUS find_printers(TALLOC_CTX *ctx, struct smbcli_tree *tree,
}
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 @@ BOOL torture_samba3_rpc_spoolss(struct torture_context *torture)
const char **printers;
int num_printers;
struct spoolss_UserLevel1 userlevel1;
+ char *servername;
if (!(mem_ctx = talloc_new(torture))) {
return False;
@@ -2367,6 +2396,14 @@ BOOL torture_samba3_rpc_spoolss(struct torture_context *torture)
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 @@ BOOL torture_samba3_rpc_spoolss(struct torture_context *torture)
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 @@ BOOL torture_samba3_rpc_spoolss(struct torture_context *torture)
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 @@ BOOL torture_samba3_rpc_spoolss(struct torture_context *torture)
{
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 @@ BOOL torture_samba3_rpc_spoolss(struct torture_context *torture)
{
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;