svn commit: samba r24934 - in branches/4.0-spoolsstest: . source source/lib/socket source/rpc_server source/rpc_server/spoolss source/smb_server source/smbd source/torture source/torture/rpc

jelmer at samba.org jelmer at samba.org
Mon Sep 3 12:46:32 GMT 2007


Author: jelmer
Date: 2007-09-03 12:46:29 +0000 (Mon, 03 Sep 2007)
New Revision: 24934

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

Log:
Start the SMB server from smbtorture.
Modified:
   branches/4.0-spoolsstest/
   branches/4.0-spoolsstest/source/lib/socket/netif.h
   branches/4.0-spoolsstest/source/main.mk
   branches/4.0-spoolsstest/source/rpc_server/dcerpc_server.c
   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/smb_server/smb_server.c
   branches/4.0-spoolsstest/source/smb_server/smb_server.h
   branches/4.0-spoolsstest/source/smbd/process_model.h
   branches/4.0-spoolsstest/source/smbd/process_single.c
   branches/4.0-spoolsstest/source/torture/config.mk
   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:revision-id:v3-trunk0
...skipped...

Modified: branches/4.0-spoolsstest/source/lib/socket/netif.h
===================================================================
--- branches/4.0-spoolsstest/source/lib/socket/netif.h	2007-09-03 12:46:22 UTC (rev 24933)
+++ branches/4.0-spoolsstest/source/lib/socket/netif.h	2007-09-03 12:46:29 UTC (rev 24934)
@@ -19,6 +19,8 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
+#include "system/network.h"
+
 struct iface_struct {
 	char name[16];
 	struct in_addr ip;

Modified: branches/4.0-spoolsstest/source/main.mk
===================================================================
--- branches/4.0-spoolsstest/source/main.mk	2007-09-03 12:46:22 UTC (rev 24933)
+++ branches/4.0-spoolsstest/source/main.mk	2007-09-03 12:46:29 UTC (rev 24934)
@@ -315,7 +315,7 @@
 testenv: everything
 	$(SELFTEST) --socket-wrapper --testenv
 
-valgrindtest: valgrindtest-quick
+valgrindtest: valgrindtest-all
 
 valgrindtest-quick: all
 	SMBD_VALGRIND="xterm -n smbd -e valgrind -q --db-attach=yes --num-callers=30" \
@@ -332,7 +332,7 @@
 	VALGRIND="valgrind -q --num-callers=30 --log-file=${selftest_prefix}/valgrind.log" \
 	$(SELFTEST) --socket-wrapper --testenv
 
-gdbtest: gdbtest-quick
+gdbtest: gdbtest-all
 
 gdbtest-quick: all
 	SMBD_VALGRIND="xterm -n smbd -e $(srcdir)/script/gdb_run " \

Modified: branches/4.0-spoolsstest/source/rpc_server/dcerpc_server.c
===================================================================
--- branches/4.0-spoolsstest/source/rpc_server/dcerpc_server.c	2007-09-03 12:46:22 UTC (rev 24933)
+++ branches/4.0-spoolsstest/source/rpc_server/dcerpc_server.c	2007-09-03 12:46:29 UTC (rev 24934)
@@ -1362,3 +1362,20 @@
 
 	return &critical_sizes;
 }
+
+/*
+  initialise the dcerpc server context for ncacn_np based services
+*/
+_PUBLIC_ NTSTATUS dcesrv_init_ipc_context(TALLOC_CTX *mem_ctx, struct dcesrv_context **_dce_ctx)
+{
+	NTSTATUS status;
+	struct dcesrv_context *dce_ctx;
+
+	status = dcesrv_init_context(mem_ctx, lp_dcerpc_endpoint_servers(), &dce_ctx);
+	NT_STATUS_NOT_OK_RETURN(status);
+
+	*_dce_ctx = dce_ctx;
+	return NT_STATUS_OK;
+}
+
+

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:22 UTC (rev 24933)
+++ branches/4.0-spoolsstest/source/rpc_server/service_rpc.c	2007-09-03 12:46:29 UTC (rev 24934)
@@ -453,19 +453,4 @@
 	return register_server_service("rpc", dcesrv_init);
 }
 
-/*
-  initialise the dcerpc server context for ncacn_np based services
-*/
-_PUBLIC_ NTSTATUS dcesrv_init_ipc_context(TALLOC_CTX *mem_ctx, struct dcesrv_context **_dce_ctx)
-{
-	NTSTATUS status;
-	struct dcesrv_context *dce_ctx;
 
-	status = dcesrv_init_context(mem_ctx, lp_dcerpc_endpoint_servers(), &dce_ctx);
-	NT_STATUS_NOT_OK_RETURN(status);
-
-	*_dce_ctx = dce_ctx;
-	return NT_STATUS_OK;
-}
-
-

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:22 UTC (rev 24933)
+++ branches/4.0-spoolsstest/source/rpc_server/spoolss/dcesrv_spoolss.c	2007-09-03 12:46:29 UTC (rev 24934)
@@ -28,6 +28,7 @@
 #include "lib/socket/socket.h"
 #include "smbd/service_stream.h"
 #include "librpc/gen_ndr/ndr_spoolss_c.h"
+#include "auth/credentials/credentials.h"
 
 enum spoolss_handle {
 	SPOOLSS_NOTIFY
@@ -1131,6 +1132,7 @@
 	struct dcerpc_binding *binding;
 	NTSTATUS status;
 	struct spoolss_ReplyOpenPrinter rop;
+	struct cli_credentials *creds;
 
 	DEBUG(2, ("Received RFFPCNex from %s\n", r->in.str));
 
@@ -1148,8 +1150,10 @@
 		return WERR_INVALID_COMPUTERNAME;
 	binding->host = r->in.str+2;
 
+	creds = cli_credentials_init_anon(mem_ctx); /* FIXME: Use machine credentials instead ? */
+
 	status = dcerpc_pipe_connect_b(mem_ctx, &p, binding, &ndr_table_spoolss, 
-				  NULL, NULL);
+				  creds, NULL);
 
 	if (NT_STATUS_IS_ERR(status)) {
 		DEBUG(0, ("unable to call back to %s\n", r->in.str));

Modified: branches/4.0-spoolsstest/source/smb_server/smb_server.c
===================================================================
--- branches/4.0-spoolsstest/source/smb_server/smb_server.c	2007-09-03 12:46:22 UTC (rev 24933)
+++ branches/4.0-spoolsstest/source/smb_server/smb_server.c	2007-09-03 12:46:29 UTC (rev 24934)
@@ -173,7 +173,7 @@
 /*
   setup a listening socket on all the SMB ports for a particular address
 */
-static NTSTATUS smb_add_socket(struct event_context *event_context,
+_PUBLIC_ NTSTATUS smbsrv_add_socket(struct event_context *event_context,
 			       const struct model_ops *model_ops,
 			       const char *address)
 {
@@ -224,12 +224,12 @@
 		*/
 		for(i = 0; i < num_interfaces; i++) {
 			const char *address = iface_n_ip(i);
-			status = smb_add_socket(task->event_ctx, task->model_ops, address);
+			status = smbsrv_add_socket(task->event_ctx, task->model_ops, address);
 			if (!NT_STATUS_IS_OK(status)) goto failed;
 		}
 	} else {
 		/* Just bind to lp_socket_address() (usually 0.0.0.0) */
-		status = smb_add_socket(task->event_ctx, task->model_ops, lp_socket_address());
+		status = smbsrv_add_socket(task->event_ctx, task->model_ops, lp_socket_address());
 		if (!NT_STATUS_IS_OK(status)) goto failed;
 	}
 

Modified: branches/4.0-spoolsstest/source/smb_server/smb_server.h
===================================================================
--- branches/4.0-spoolsstest/source/smb_server/smb_server.h	2007-09-03 12:46:22 UTC (rev 24933)
+++ branches/4.0-spoolsstest/source/smb_server/smb_server.h	2007-09-03 12:46:29 UTC (rev 24934)
@@ -376,6 +376,10 @@
 	struct share_context *share_context;
 };
 
+NTSTATUS smbsrv_add_socket(struct event_context *event_context,
+			       const struct model_ops *model_ops,
+			       const char *address);
+
 #include "smb_server/smb_server_proto.h"
 #include "smb_server/smb/smb_proto.h"
 

Modified: branches/4.0-spoolsstest/source/smbd/process_model.h
===================================================================
--- branches/4.0-spoolsstest/source/smbd/process_model.h	2007-09-03 12:46:22 UTC (rev 24933)
+++ branches/4.0-spoolsstest/source/smbd/process_model.h	2007-09-03 12:46:29 UTC (rev 24934)
@@ -67,6 +67,8 @@
 	int sizeof_model_ops;
 };
 
+extern const struct model_ops single_ops;
+
 #include "smbd/process_model_proto.h"
 
 #endif /* __PROCESS_MODEL_H__ */

Modified: branches/4.0-spoolsstest/source/smbd/process_single.c
===================================================================
--- branches/4.0-spoolsstest/source/smbd/process_single.c	2007-09-03 12:46:22 UTC (rev 24933)
+++ branches/4.0-spoolsstest/source/smbd/process_single.c	2007-09-03 12:46:29 UTC (rev 24934)
@@ -87,7 +87,7 @@
 {
 }
 
-static const struct model_ops single_ops = {
+const struct model_ops single_ops = {
 	.name			= "single",
 	.model_init		= single_model_init,
 	.new_task               = single_new_task,

Modified: branches/4.0-spoolsstest/source/torture/config.mk
===================================================================
--- branches/4.0-spoolsstest/source/torture/config.mk	2007-09-03 12:46:22 UTC (rev 24933)
+++ branches/4.0-spoolsstest/source/torture/config.mk	2007-09-03 12:46:29 UTC (rev 24934)
@@ -166,7 +166,7 @@
 		RPC_NDR_SRVSVC RPC_NDR_WKSSVC RPC_NDR_ROT RPC_NDR_DSSETUP \
 		RPC_NDR_REMACT RPC_NDR_OXIDRESOLVER WB_HELPER LIBSAMBA-NET \
 		LIBCLI_AUTH POPT_CREDENTIALS TORTURE_LDAP TORTURE_UTIL TORTURE_RAP \
-		dcerpc_server
+		dcerpc_server service process_model
 
 #################################
 # Start SUBSYSTEM TORTURE_RAP

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:22 UTC (rev 24933)
+++ branches/4.0-spoolsstest/source/torture/rpc/spoolss_notify.c	2007-09-03 12:46:29 UTC (rev 24934)
@@ -26,6 +26,9 @@
 #include "librpc/gen_ndr/ndr_spoolss_c.h"
 #include "rpc_server/dcerpc_server.h"
 #include "lib/events/events.h"
+#include "smbd/process_model.h"
+#include "smb_server/smb_server.h"
+#include "lib/socket/netif.h"
 #include "dlinklist.h"
 
 static NTSTATUS spoolss__op_bind(struct dcesrv_call_state *dce_call, const struct dcesrv_interface *iface)
@@ -175,23 +178,23 @@
 }
 
 static bool test_RFFPCNEx(struct torture_context *tctx, 
-				  struct dcerpc_pipe *pipe)
+			  struct dcerpc_pipe *p)
 {
 	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 spoolss_NotifyOptionsContainer t1;
 	struct spoolss_ClosePrinter cp;
 
 	struct policy_handle handle;
+	const char *address;
 
 	ZERO_STRUCT(q);
 
-	q.in.printername	= talloc_asprintf(tctx, "\\\\%s", dcerpc_server_name(pipe));
+	q.in.printername	= talloc_asprintf(tctx, "\\\\%s", dcerpc_server_name(p));
 	q.in.datatype		= NULL;
 	q.in.devmode_ctr.devmode= NULL;
 	q.in.access_mask	= SEC_FLAG_MAXIMUM_ALLOWED;
@@ -199,14 +202,38 @@
 
 	torture_comment(tctx, "Testing OpenPrinter(%s)\n", q.in.printername);
 
-	status = dcerpc_spoolss_OpenPrinter(pipe, tctx, &q);
+	status = dcerpc_spoolss_OpenPrinter(p, tctx, &q);
 
 	torture_assert_ntstatus_ok(tctx, status, "OpenPrinter failed");
 
 	torture_assert_werr_ok(tctx, q.out.result, "OpenPrinter failed");
 
+	/* Start DCE/RPC server */
+
+	/* fill in our name */
+	ep_server.name = "spoolss";
+
+	/* fill in all the operations */
+	ep_server.init_server = spoolss__op_init_server;
+
+	ep_server.interface_by_uuid = spoolss__op_interface_by_uuid;
+	ep_server.interface_by_name = spoolss__op_interface_by_name;
+
+	torture_assert_ntstatus_ok(tctx, dcerpc_register_ep_server(&ep_server),
+				  "unable to register spoolss server");
+
+	address = iface_n_ip(0);
+	torture_comment(tctx, "Listening for callbacks on %s\n", address);
+	status = smbsrv_add_socket(p->conn->event_ctx, &single_ops, address);
+	torture_assert_ntstatus_ok(tctx, status, "starting smb server");
+
+	status = dcesrv_init_context(tctx, endpoints, &dce_ctx);
+	torture_assert_ntstatus_ok(tctx, status, 
+				   "unable to initialize DCE/RPC server");
+
+
 	r.in.flags = 0;
-	r.in.str = talloc_asprintf(tctx, "\\\\%s", get_myname());
+	r.in.str = talloc_asprintf(tctx, "\\\\%s", address);
 	r.in.options = 0;
 	r.in.printer_local = 123;
 	t1.version = 2;
@@ -226,30 +253,10 @@
 	r.in.t1 = &t1;
 	r.in.handle = &handle;
 
-	/* Start DCE/RPC server */
 
-	/* fill in our name */
-	ep_server.name = "spoolss";
+	status = dcerpc_spoolss_RemoteFindFirstPrinterChangeNotifyEx(p, tctx, &r);
 
-	/* fill in all the operations */
-	ep_server.init_server = spoolss__op_init_server;
-
-	ep_server.interface_by_uuid = spoolss__op_interface_by_uuid;
-	ep_server.interface_by_name = spoolss__op_interface_by_name;
-
-	torture_assert_ntstatus_ok(tctx, dcerpc_register_ep_server(&ep_server),
-				  "unable to register spoolss server");
-
-	status = dcesrv_init_context(tctx, 
-				     endpoints,
-				     &dce_ctx);
 	torture_assert_ntstatus_ok(tctx, status, 
-				   "unable to initialize DCE/RPC server");
-
-	req = dcerpc_spoolss_RemoteFindFirstPrinterChangeNotifyEx_send(pipe, tctx, &r);
-
-	status  = dcerpc_ndr_request_recv(req);
-	torture_assert_ntstatus_ok(tctx, status, 
 				   "FFPCNEx failed");
 	
 	torture_assert_werr_ok(tctx, r.out.result, "error return code for FFPCNEx");
@@ -259,9 +266,13 @@
 
 	torture_comment(tctx, "Testing ClosePrinter\n");
 
-	status = dcerpc_spoolss_ClosePrinter(pipe, tctx, &cp);
+	status = dcerpc_spoolss_ClosePrinter(p, tctx, &cp);
 	torture_assert_ntstatus_ok(tctx, status, "ClosePrinter failed");
 
+	/* We should've had an incoming packet 58 (ReplyOpenPrinter) */
+	torture_assert(tctx, received_packets != NULL, "no packets received");
+	torture_assert_int_equal(tctx, received_packets->opnum, 58, "invalid opnum");
+
 	/* Shut down DCE/RPC server */
 	talloc_free(dce_ctx);
 



More information about the samba-cvs mailing list