[SCM] Samba Shared Repository - branch master updated

Günther Deschner gd at samba.org
Wed Apr 7 06:41:04 MDT 2010


The branch, master has been updated
       via  95b9c48... s3-rpcclient: allow to define server_unc in cmd_srvsvc_srv_query_info().
       via  f63c345... s4-smbtorture: test all types and also use a wellknown builtin form name in RPC-SPOOLSS.
      from  3fdebc0... s3: add comment about what the FSCTL_QUERY_ALLOCATED_RANGES currently does

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 95b9c48ef1fbe6c1566a86cadf3295b6c7e28319
Author: Günther Deschner <gd at samba.org>
Date:   Wed Apr 7 14:38:31 2010 +0200

    s3-rpcclient: allow to define server_unc in cmd_srvsvc_srv_query_info().
    
    Guenther

commit f63c345bbd2b069c1f946529d559e8c6dbd7f2bc
Author: Günther Deschner <gd at samba.org>
Date:   Wed Apr 7 14:37:30 2010 +0200

    s4-smbtorture: test all types and also use a wellknown builtin form name in RPC-SPOOLSS.
    
    Guenther

-----------------------------------------------------------------------

Summary of changes:
 source3/rpcclient/cmd_srvsvc.c |   14 +++-
 source4/torture/rpc/spoolss.c  |  171 ++++++++++++++++++++++++++++++----------
 2 files changed, 138 insertions(+), 47 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/rpcclient/cmd_srvsvc.c b/source3/rpcclient/cmd_srvsvc.c
index 866b681..890151e 100644
--- a/source3/rpcclient/cmd_srvsvc.c
+++ b/source3/rpcclient/cmd_srvsvc.c
@@ -173,17 +173,23 @@ static WERROR cmd_srvsvc_srv_query_info(struct rpc_pipe_client *cli,
 	union srvsvc_NetSrvInfo info;
 	WERROR result;
 	NTSTATUS status;
+	const char *server_unc = cli->srv_name_slash;
 
-	if (argc > 2) {
-		printf("Usage: %s [infolevel]\n", argv[0]);
+	if (argc > 3) {
+		printf("Usage: %s [infolevel] [server_unc]\n", argv[0]);
 		return WERR_OK;
 	}
 
-	if (argc == 2)
+	if (argc >= 2) {
 		info_level = atoi(argv[1]);
+	}
+
+	if (argc >= 3) {
+		server_unc = argv[2];
+	}
 
 	status = rpccli_srvsvc_NetSrvGetInfo(cli, mem_ctx,
-					     cli->srv_name_slash,
+					     server_unc,
 					     info_level,
 					     &info,
 					     &result);
diff --git a/source4/torture/rpc/spoolss.c b/source4/torture/rpc/spoolss.c
index 4cc0e84..d4970c1 100644
--- a/source4/torture/rpc/spoolss.c
+++ b/source4/torture/rpc/spoolss.c
@@ -2386,7 +2386,8 @@ static bool test_EnumForms_find_one(struct torture_context *tctx,
 static bool test_DeleteForm(struct torture_context *tctx,
 			    struct dcerpc_binding_handle *b,
 			    struct policy_handle *handle,
-			    const char *form_name)
+			    const char *form_name,
+			    WERROR expected_result)
 {
 	struct spoolss_DeleteForm r;
 
@@ -2398,13 +2399,15 @@ static bool test_DeleteForm(struct torture_context *tctx,
 	torture_assert_ntstatus_ok(tctx,
 		dcerpc_spoolss_DeleteForm_r(b, tctx, &r),
 		"DeleteForm failed");
-	torture_assert_werr_ok(tctx, r.out.result,
-		"DeleteForm failed");
-	torture_assert_ntstatus_ok(tctx,
-		dcerpc_spoolss_DeleteForm_r(b, tctx, &r),
-		"2nd DeleteForm failed");
-	torture_assert_werr_equal(tctx, r.out.result, WERR_INVALID_FORM_NAME,
-		"2nd DeleteForm failed");
+	torture_assert_werr_equal(tctx, r.out.result, expected_result,
+		"DeleteForm gave unexpected result");
+	if (W_ERROR_IS_OK(r.out.result)) {
+		torture_assert_ntstatus_ok(tctx,
+			dcerpc_spoolss_DeleteForm_r(b, tctx, &r),
+			"2nd DeleteForm failed");
+		torture_assert_werr_equal(tctx, r.out.result, WERR_INVALID_FORM_NAME,
+			"2nd DeleteForm failed");
+	}
 
 	return true;
 }
@@ -2413,7 +2416,8 @@ static bool test_AddForm(struct torture_context *tctx,
 			 struct dcerpc_binding_handle *b,
 			 struct policy_handle *handle,
 			 uint32_t level,
-			 union spoolss_AddFormInfo *info)
+			 union spoolss_AddFormInfo *info,
+			 WERROR expected_result)
 {
 	struct spoolss_AddForm r;
 
@@ -2425,19 +2429,14 @@ static bool test_AddForm(struct torture_context *tctx,
 	r.in.level	= level;
 	r.in.info	= *info;
 
-	torture_comment(tctx, "Testing AddForm(%s) level %d\n",
-		r.in.info.info1->form_name, r.in.level);
+	torture_comment(tctx, "Testing AddForm(%s) level %d, type %d\n",
+		r.in.info.info1->form_name, r.in.level,
+		r.in.info.info1->flags);
 
 	torture_assert_ntstatus_ok(tctx, dcerpc_spoolss_AddForm_r(b, tctx, &r),
 		"AddForm failed");
-	if (W_ERROR_EQUAL(r.out.result, WERR_FILE_EXISTS)) {
-		test_DeleteForm(tctx, b, handle, r.in.info.info1->form_name);
-		torture_assert_ntstatus_ok(tctx, dcerpc_spoolss_AddForm_r(b, tctx, &r),
-			"AddForm failed");
-	}
-
-	torture_assert_werr_ok(tctx, r.out.result,
-		"AddForm failed");
+	torture_assert_werr_equal(tctx, r.out.result, expected_result,
+		"AddForm gave unexpected result");
 
 	torture_assert_ntstatus_ok(tctx, dcerpc_spoolss_AddForm_r(b, tctx, &r),
 		"2nd AddForm failed");
@@ -2483,41 +2482,33 @@ static bool test_GetForm_winreg(struct torture_context *tctx,
 				uint32_t *w_length,
 				uint8_t **w_data);
 
-static bool test_Forms(struct torture_context *tctx,
-		       struct dcerpc_binding_handle *b,
-		       struct policy_handle *handle,
-		       bool print_server,
-		       const char *printer_name,
-		       struct dcerpc_binding_handle *winreg_handle,
-		       struct policy_handle *hive_handle)
+static bool test_Forms_args(struct torture_context *tctx,
+			    struct dcerpc_binding_handle *b,
+			    struct policy_handle *handle,
+			    bool print_server,
+			    const char *printer_name,
+			    struct dcerpc_binding_handle *winreg_handle,
+			    struct policy_handle *hive_handle,
+			    const char *form_name,
+			    struct spoolss_AddFormInfo1 *info1,
+			    WERROR expected_add_result,
+			    WERROR expected_delete_result)
 {
 	union spoolss_FormInfo info;
-	const char *form_name = "testform3";
-
 	union spoolss_AddFormInfo add_info;
-	struct spoolss_AddFormInfo1 info1;
 
 	enum winreg_Type w_type;
 	uint32_t w_size;
 	uint32_t w_length;
 	uint8_t *w_data;
 
-	info1.flags		= SPOOLSS_FORM_USER;
-	info1.form_name		= form_name;
-	info1.size.width	= 50;
-	info1.size.height	= 25;
-	info1.area.left		= 5;
-	info1.area.top		= 10;
-	info1.area.right	= 45;
-	info1.area.bottom	= 15;
-
-	add_info.info1 = &info1;
+	add_info.info1 = info1;
 
 	torture_assert(tctx,
-		test_AddForm(tctx, b, handle, 1, &add_info),
+		test_AddForm(tctx, b, handle, 1, &add_info, expected_add_result),
 		"failed to add form");
 
-	if (winreg_handle && hive_handle) {
+	if (winreg_handle && hive_handle && W_ERROR_IS_OK(expected_add_result)) {
 
 		torture_assert(tctx,
 			test_GetForm_winreg(tctx, winreg_handle, hive_handle, TOP_LEVEL_CONTROL_FORMS_KEY, form_name, &w_type, &w_size, &w_length, &w_data),
@@ -2536,7 +2527,7 @@ static bool test_Forms(struct torture_context *tctx,
 		torture_assert_mem_equal(tctx, &w_data[28], &add_info.info1->flags, 4, "flags mismatch");
 	}
 
-	if (!print_server) {
+	if (!print_server && W_ERROR_IS_OK(expected_add_result)) {
 		torture_assert(tctx,
 			test_GetForm_args(tctx, b, handle, form_name, 1, &info),
 			"failed to get added form");
@@ -2577,12 +2568,106 @@ static bool test_Forms(struct torture_context *tctx,
 		"Newly added form not found in enum call");
 
 	torture_assert(tctx,
-		test_DeleteForm(tctx, b, handle, form_name),
+		test_DeleteForm(tctx, b, handle, form_name, expected_delete_result),
 		"failed to delete form");
 
 	return true;
 }
 
+static bool test_Forms(struct torture_context *tctx,
+		       struct dcerpc_binding_handle *b,
+		       struct policy_handle *handle,
+		       bool print_server,
+		       const char *printer_name,
+		       struct dcerpc_binding_handle *winreg_handle,
+		       struct policy_handle *hive_handle)
+{
+
+	struct spoolss_FormSize size;
+	struct spoolss_FormArea area;
+	int i;
+
+	size.width	= 50;
+	size.height	= 25;
+	area.left	= 5;
+	area.top	= 10;
+	area.right	= 45;
+	area.bottom	= 15;
+
+	struct {
+		struct spoolss_AddFormInfo1 info1;
+		WERROR expected_add_result;
+		WERROR expected_delete_result;
+	} forms[] = {
+		{
+			.info1.flags		= SPOOLSS_FORM_USER,
+			.info1.form_name	= "testform_user",
+			.info1.size		= size,
+			.info1.area		= area,
+			.expected_add_result	= WERR_OK,
+			.expected_delete_result	= WERR_OK
+		},
+/*
+		weird, we can add a builtin form but we can never remove it
+		again - gd
+
+		{
+			.info1.flags		= SPOOLSS_FORM_BUILTIN,
+			.info1.form_name	= "testform_builtin",
+			.info1.size		= size,
+			.info1.area		= area,
+			.expected_add_result	= WERR_OK,
+			.expected_delete_result	= WERR_INVALID_PARAM,
+		},
+*/
+		{
+			.info1.flags		= SPOOLSS_FORM_PRINTER,
+			.info1.form_name	= "testform_printer",
+			.info1.size		= size,
+			.info1.area		= area,
+			.expected_add_result	= WERR_OK,
+			.expected_delete_result	= WERR_OK
+		},
+		{
+			.info1.flags		= SPOOLSS_FORM_USER,
+			.info1.form_name	= "Letter",
+			.info1.size		= size,
+			.info1.area		= area,
+			.expected_add_result	= WERR_FILE_EXISTS,
+			.expected_delete_result	= WERR_INVALID_PARAM
+		},
+		{
+			.info1.flags		= SPOOLSS_FORM_BUILTIN,
+			.info1.form_name	= "Letter",
+			.info1.size		= size,
+			.info1.area		= area,
+			.expected_add_result	= WERR_FILE_EXISTS,
+			.expected_delete_result	= WERR_INVALID_PARAM
+		},
+		{
+			.info1.flags		= SPOOLSS_FORM_PRINTER,
+			.info1.form_name	= "Letter",
+			.info1.size		= size,
+			.info1.area		= area,
+			.expected_add_result	= WERR_FILE_EXISTS,
+			.expected_delete_result	= WERR_INVALID_PARAM
+		}
+	};
+
+	for (i=0; i < ARRAY_SIZE(forms); i++) {
+		torture_assert(tctx,
+			test_Forms_args(tctx, b, handle, print_server, printer_name,
+					winreg_handle, hive_handle,
+					forms[i].info1.form_name,
+					&forms[i].info1,
+					forms[i].expected_add_result,
+					forms[i].expected_delete_result),
+			talloc_asprintf(tctx, "failed to test form '%s'", forms[i].info1.form_name));
+	}
+
+	return true;
+}
+
 static bool test_EnumPorts_old(struct torture_context *tctx,
 			       struct dcerpc_pipe *p)
 {


-- 
Samba Shared Repository


More information about the samba-cvs mailing list