svn commit: samba r24933 - in branches/4.0-spoolsstest: .
source/rpc_server source/rpc_server/spoolss source/smbd
source/torture/rpc
jelmer at samba.org
jelmer at samba.org
Mon Sep 3 12:46:26 GMT 2007
Author: jelmer
Date: 2007-09-03 12:46:22 +0000 (Mon, 03 Sep 2007)
New Revision: 24933
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=24933
Log:
Finish test properly - setup of SMB server is all that's left to do now.
Modified:
branches/4.0-spoolsstest/
branches/4.0-spoolsstest/source/rpc_server/config.mk
branches/4.0-spoolsstest/source/rpc_server/service_rpc.c
branches/4.0-spoolsstest/source/rpc_server/spoolss/dcesrv_spoolss.c
branches/4.0-spoolsstest/source/smbd/service_stream.c
branches/4.0-spoolsstest/source/torture/rpc/rpc.c
branches/4.0-spoolsstest/source/torture/rpc/spoolss_notify.c
Changeset:
Property changes on: branches/4.0-spoolsstest
___________________________________________________________________
Name: bzr:revision-info
...skipped...
Name: bzr:file-ids
...skipped...
Name: bzr:revision-id:v3-trunk0
...skipped...
Modified: branches/4.0-spoolsstest/source/rpc_server/config.mk
===================================================================
--- branches/4.0-spoolsstest/source/rpc_server/config.mk 2007-09-03 12:46:17 UTC (rev 24932)
+++ branches/4.0-spoolsstest/source/rpc_server/config.mk 2007-09-03 12:46:22 UTC (rev 24933)
@@ -157,7 +157,8 @@
PRIVATE_DEPENDENCIES = \
DCERPC_COMMON \
NDR_SPOOLSS \
- ntptr
+ ntptr \
+ RPC_NDR_SPOOLSS
# End MODULE dcerpc_spoolss
################################################
Modified: branches/4.0-spoolsstest/source/rpc_server/service_rpc.c
===================================================================
--- branches/4.0-spoolsstest/source/rpc_server/service_rpc.c 2007-09-03 12:46:17 UTC (rev 24932)
+++ branches/4.0-spoolsstest/source/rpc_server/service_rpc.c 2007-09-03 12:46:22 UTC (rev 24933)
@@ -241,7 +241,7 @@
}
NTSTATUS dcesrv_add_ep_ncalrpc(struct dcesrv_context *dce_ctx, struct dcesrv_endpoint *e,
- struct event_context *event_ctx, const struct model_ops *model_ops)
+ struct event_context *event_ctx, const struct model_ops *model_ops)
{
struct dcesrv_socket_context *dcesrv_sock;
uint16_t port = 1;
Modified: branches/4.0-spoolsstest/source/rpc_server/spoolss/dcesrv_spoolss.c
===================================================================
--- branches/4.0-spoolsstest/source/rpc_server/spoolss/dcesrv_spoolss.c 2007-09-03 12:46:17 UTC (rev 24932)
+++ branches/4.0-spoolsstest/source/rpc_server/spoolss/dcesrv_spoolss.c 2007-09-03 12:46:22 UTC (rev 24933)
@@ -27,6 +27,7 @@
#include "ntptr/ntptr.h"
#include "lib/socket/socket.h"
#include "smbd/service_stream.h"
+#include "librpc/gen_ndr/ndr_spoolss_c.h"
enum spoolss_handle {
SPOOLSS_NOTIFY
@@ -1045,10 +1046,10 @@
handle = dcesrv_handle_new(dce_call->context, SPOOLSS_NOTIFY);
W_ERROR_HAVE_NO_MEMORY(handle);
+ /* For now, just return a handle */
+
*r->out.handle = handle->wire_handle;
- /* TODO: Sent received information by irpc */
-
return WERR_OK;
}
@@ -1126,11 +1127,50 @@
static WERROR dcesrv_spoolss_RemoteFindFirstPrinterChangeNotifyEx(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
struct spoolss_RemoteFindFirstPrinterChangeNotifyEx *r)
{
+ struct dcerpc_pipe *p;
+ struct dcerpc_binding *binding;
+ NTSTATUS status;
+ struct spoolss_ReplyOpenPrinter rop;
+
+ DEBUG(2, ("Received RFFPCNex from %s\n", r->in.str));
+
/*
- * TODO: for now just return ok,
+ * TODO: for now just open a connection to the client and drop it again
* to keep the w2k3 PrintServer
* happy to allow to open the Add Printer GUI
+ * and the torture suite passing
*/
+
+ binding = talloc_zero(mem_ctx, struct dcerpc_binding);
+
+ binding->transport = NCACN_NP;
+ if (strncmp(r->in.str, "\\\\", 2))
+ return WERR_INVALID_COMPUTERNAME;
+ binding->host = r->in.str+2;
+
+ status = dcerpc_pipe_connect_b(mem_ctx, &p, binding, &ndr_table_spoolss,
+ NULL, NULL);
+
+ if (NT_STATUS_IS_ERR(status)) {
+ DEBUG(0, ("unable to call back to %s\n", r->in.str));
+ return WERR_SERVER_UNAVAILABLE;
+ }
+
+ ZERO_STRUCT(rop);
+ rop.in.server_name = NULL;
+ rop.in.printer_local = 0;
+ rop.in.type = REG_NONE;
+ rop.in.unknown1 = 0;
+ rop.in.unknown2 = 0;
+
+ status = dcerpc_spoolss_ReplyOpenPrinter(p, mem_ctx, &rop);
+ if (NT_STATUS_IS_ERR(status)) {
+ DEBUG(0, ("unable to open remote printer %s\n", r->in.str));
+ return WERR_SERVER_UNAVAILABLE;
+ }
+
+ talloc_free(p);
+
return WERR_OK;
}
Modified: branches/4.0-spoolsstest/source/smbd/service_stream.c
===================================================================
--- branches/4.0-spoolsstest/source/smbd/service_stream.c 2007-09-03 12:46:17 UTC (rev 24932)
+++ branches/4.0-spoolsstest/source/smbd/service_stream.c 2007-09-03 12:46:22 UTC (rev 24933)
@@ -224,11 +224,13 @@
stream_new_connection, stream_socket);
}
-
-
/*
setup a listen stream socket
if you pass *port == 0, then a port > 1024 is used
+
+ FIXME: This function is TCP/IP specific - uses an int rather than
+ a string for the port. Should leave allocating a port nr
+ to the socket implementation - JRV20070903
*/
NTSTATUS stream_setup_socket(struct event_context *event_context,
const struct model_ops *model_ops,
Modified: branches/4.0-spoolsstest/source/torture/rpc/rpc.c
===================================================================
--- branches/4.0-spoolsstest/source/torture/rpc/rpc.c 2007-09-03 12:46:17 UTC (rev 24932)
+++ branches/4.0-spoolsstest/source/torture/rpc/rpc.c 2007-09-03 12:46:22 UTC (rev 24933)
@@ -388,7 +388,7 @@
torture_suite_add_suite(suite, torture_rpc_handles(suite));
torture_suite_add_suite(suite, torture_rpc_winreg(suite));
torture_suite_add_simple_test(suite, "SPOOLSS", torture_rpc_spoolss);
- torture_suite_add_suite(suite, torture_rpc_spoolss_notify());
+ torture_suite_add_suite(suite, torture_rpc_spoolss_notify(suite));
torture_suite_add_simple_test(suite, "SAMR", torture_rpc_samr);
torture_suite_add_simple_test(suite, "SAMR-USERS", torture_rpc_samr_users);
torture_suite_add_simple_test(suite, "SAMR-PASSWORDS", torture_rpc_samr_passwords);
Modified: branches/4.0-spoolsstest/source/torture/rpc/spoolss_notify.c
===================================================================
--- branches/4.0-spoolsstest/source/torture/rpc/spoolss_notify.c 2007-09-03 12:46:17 UTC (rev 24932)
+++ branches/4.0-spoolsstest/source/torture/rpc/spoolss_notify.c 2007-09-03 12:46:22 UTC (rev 24933)
@@ -26,6 +26,7 @@
#include "librpc/gen_ndr/ndr_spoolss_c.h"
#include "rpc_server/dcerpc_server.h"
#include "lib/events/events.h"
+#include "dlinklist.h"
static NTSTATUS spoolss__op_bind(struct dcesrv_call_state *dce_call, const struct dcesrv_interface *iface)
{
@@ -63,9 +64,42 @@
return NT_STATUS_OK;
}
+/* FIXME: What context does this belong in ? -- JRV20070903 */
+static struct received_packet {
+ uint16_t opnum;
+ void *r;
+ struct received_packet *prev, *next;
+} *received_packets = NULL;
+
static NTSTATUS spoolss__op_dispatch(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, void *r)
{
+ uint16_t opnum = dce_call->pkt.u.request.opnum;
+ struct received_packet *rp;
+
+ rp = talloc_zero(mem_ctx, struct received_packet);
+ rp->opnum = opnum;
+ rp->r = talloc_reference(mem_ctx, r);
+
+ DLIST_ADD_END(received_packets, rp, struct received_packet *);
+
+ switch (opnum) {
+ case 58: {
+ struct spoolss_ReplyOpenPrinter *r2 = (struct spoolss_ReplyOpenPrinter *)r;
+ r2->out.result = WERR_OK;
+ break;
+ }
+
+ default:
+ dce_call->fault_code = DCERPC_FAULT_OP_RNG_ERROR;
+ break;
+ }
+
+ if (dce_call->fault_code != 0) {
+ dcerpc_log_packet(&ndr_table_spoolss, opnum, NDR_IN,
+ &dce_call->pkt.u.request.stub_and_verifier);
+ return NT_STATUS_NET_WRITE_FAULT;
+ }
return NT_STATUS_OK;
}
@@ -140,28 +174,58 @@
return NT_STATUS_OK;
}
-/** Test that makes sure that calling ReplyOpenPrinter()
- * on Samba 4 will cause an irpc broadcast call.
- */
-static bool test_ReplyOpenPrinter(struct torture_context *tctx,
+static bool test_RFFPCNEx(struct torture_context *tctx,
struct dcerpc_pipe *pipe)
{
- struct spoolss_ReplyOpenPrinter r;
- struct policy_handle h;
+ struct spoolss_OpenPrinter q;
+ struct spoolss_RemoteFindFirstPrinterChangeNotifyEx r;
struct dcesrv_endpoint_server ep_server;
NTSTATUS status;
struct dcesrv_context *dce_ctx;
struct rpc_request *req;
const char *endpoints[] = { "spoolss", NULL };
- struct dcesrv_endpoint *e;
+ struct spoolss_NotifyOptionsContainer t1;
+ struct spoolss_ClosePrinter cp;
- r.in.server_name = "earth";
- r.in.printer_local = 2;
- r.in.type = REG_DWORD;
- r.in.unknown1 = 0;
- r.in.unknown2 = 0;
- r.out.handle = &h;
+ struct policy_handle handle;
+ ZERO_STRUCT(q);
+
+ q.in.printername = talloc_asprintf(tctx, "\\\\%s", dcerpc_server_name(pipe));
+ q.in.datatype = NULL;
+ q.in.devmode_ctr.devmode= NULL;
+ q.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
+ q.out.handle = &handle;
+
+ torture_comment(tctx, "Testing OpenPrinter(%s)\n", q.in.printername);
+
+ status = dcerpc_spoolss_OpenPrinter(pipe, tctx, &q);
+
+ torture_assert_ntstatus_ok(tctx, status, "OpenPrinter failed");
+
+ torture_assert_werr_ok(tctx, q.out.result, "OpenPrinter failed");
+
+ r.in.flags = 0;
+ r.in.str = talloc_asprintf(tctx, "\\\\%s", get_myname());
+ r.in.options = 0;
+ r.in.printer_local = 123;
+ t1.version = 2;
+ t1.flags = 0;
+ t1.count = 2;
+ t1.options = talloc_zero_array(tctx, struct spoolss_NotifyOptionsArray, 2);
+ t1.options[0].type = SPOOLSS_NOTIFY_PRINTER;
+ t1.options[0].count = 1;
+ t1.options[0].fields = talloc_array(t1.options, enum spoolss_Field, 1);
+ t1.options[0].fields[0] = SPOOLSS_FIELD_SERVER_NAME;
+
+ t1.options[1].type = SPOOLSS_NOTIFY_JOB;
+ t1.options[1].count = 1;
+ t1.options[1].fields = talloc_array(t1.options, enum spoolss_Field, 1);
+ t1.options[1].fields[0] = SPOOLSS_FIELD_PRINTER_NAME;
+
+ r.in.t1 = &t1;
+ r.in.handle = &handle;
+
/* Start DCE/RPC server */
/* fill in our name */
@@ -182,39 +246,36 @@
torture_assert_ntstatus_ok(tctx, status,
"unable to initialize DCE/RPC server");
- for (e=dce_ctx->endpoint_list;e;e=e->next) {
- status = dcesrv_add_ep_np(dce_ctx, e, pipe->conn->event_ctx, NULL);
- torture_assert_ntstatus_ok(tctx, status,
- "Unable to add ncacn_np endpoint");
- }
+ req = dcerpc_spoolss_RemoteFindFirstPrinterChangeNotifyEx_send(pipe, tctx, &r);
- req = dcerpc_spoolss_ReplyOpenPrinter_send(pipe, tctx, &r);
-
- while(1)
- event_loop_once(pipe->conn->event_ctx);
-
status = dcerpc_ndr_request_recv(req);
torture_assert_ntstatus_ok(tctx, status,
- "ReplyOpenPrinter failed");
+ "FFPCNEx failed");
- torture_assert_werr_ok(tctx, r.out.result, "error return code");
+ torture_assert_werr_ok(tctx, r.out.result, "error return code for FFPCNEx");
+ cp.in.handle = &handle;
+ cp.out.handle = &handle;
+
+ torture_comment(tctx, "Testing ClosePrinter\n");
+
+ status = dcerpc_spoolss_ClosePrinter(pipe, tctx, &cp);
+ torture_assert_ntstatus_ok(tctx, status, "ClosePrinter failed");
+
/* Shut down DCE/RPC server */
talloc_free(dce_ctx);
return true;
}
-struct torture_suite *torture_rpc_spoolss_notify(void)
+struct torture_suite *torture_rpc_spoolss_notify(TALLOC_CTX *mem_ctx)
{
- struct torture_suite *suite = torture_suite_create(
- talloc_autofree_context(), "SPOOLSS-NOTIFY");
+ struct torture_suite *suite = torture_suite_create(mem_ctx, "SPOOLSS-NOTIFY");
struct torture_rpc_tcase *tcase = torture_suite_add_rpc_iface_tcase(suite,
"notify", &ndr_table_spoolss);
- torture_rpc_tcase_add_test(tcase, "test_replyopenprinter",
- test_ReplyOpenPrinter);
+ torture_rpc_tcase_add_test(tcase, "testRFFPCNEx", test_RFFPCNEx);
return suite;
}
More information about the samba-cvs
mailing list