[SCM] Samba Shared Repository - branch master updated

Günther Deschner gd at samba.org
Fri Mar 26 07:36:43 MDT 2010


The branch, master has been updated
       via  f70e1b4... s4-smbtorture: fail spoolss test on SetJob failure.
       via  dcec932... s3-spoolss: return info for the correct printjob in _spoolss_GetJob().
       via  3da91b7... s3-printing: avoid mixing cups backend code with nt_printing code in cups_pull_comment_location.
      from  7728396... s3-event: switch s3 to using tevent_re_initialise()

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


- Log -----------------------------------------------------------------
commit f70e1b4d43995ac4c7ab020613d3f0af24eb03f6
Author: Günther Deschner <gd at samba.org>
Date:   Fri Mar 26 13:37:42 2010 +0100

    s4-smbtorture: fail spoolss test on SetJob failure.
    
    Guenther

commit dcec9322798ffb848ec70bae67220eb0526942ac
Author: Günther Deschner <gd at samba.org>
Date:   Fri Mar 26 13:36:00 2010 +0100

    s3-spoolss: return info for the correct printjob in _spoolss_GetJob().
    
    Guenther

commit 3da91b786ef87bd13ae1210a1bf671e2209d9c1f
Author: Günther Deschner <gd at samba.org>
Date:   Fri Mar 26 13:17:49 2010 +0100

    s3-printing: avoid mixing cups backend code with nt_printing code in cups_pull_comment_location.
    
    Guenther

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

Summary of changes:
 source3/include/proto.h             |    5 ++-
 source3/printing/nt_printing.c      |   26 +++++++++--
 source3/printing/print_cups.c       |   35 ++++++---------
 source3/rpc_server/srv_spoolss_nt.c |   10 +++--
 source4/torture/rpc/spoolss.c       |   83 +++++++++++++++++++++++++---------
 5 files changed, 107 insertions(+), 52 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/include/proto.h b/source3/include/proto.h
index c211501..ecb2961 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -4897,7 +4897,10 @@ bool aix_cache_reload(void);
 /* The following definitions come from printing/print_cups.c  */
 
 bool cups_cache_reload(void);
-bool cups_pull_comment_location(NT_PRINTER_INFO_LEVEL_2 *printer);
+bool cups_pull_comment_location(TALLOC_CTX *mem_ctx,
+				const char *printername,
+				char **comment,
+				char **location);
 
 /* The following definitions come from printing/print_generic.c  */
 
diff --git a/source3/printing/nt_printing.c b/source3/printing/nt_printing.c
index b29000a..5096ca0 100644
--- a/source3/printing/nt_printing.c
+++ b/source3/printing/nt_printing.c
@@ -3831,8 +3831,17 @@ static WERROR get_a_printer_2_default(NT_PRINTER_INFO_LEVEL_2 *info,
 	if (get_loc_com && (enum printing_types)lp_printing(snum) == PRINT_CUPS ) {
 		/* Pull the location and comment strings from cups if we don't
 		   already have one */
-		if ( !strlen(info->location) || !strlen(info->comment) )
-			cups_pull_comment_location( info );
+		if ( !strlen(info->location) || !strlen(info->comment) ) {
+			char *comment = NULL;
+			char *location = NULL;
+			if (cups_pull_comment_location(info, info->sharename,
+						       &comment, &location)) {
+				strlcpy(info->comment, comment, sizeof(info->comment));
+				fstrcpy(info->location, location);
+				TALLOC_FREE(comment);
+				TALLOC_FREE(location);
+			}
+		}
 	}
 #endif
 
@@ -3953,8 +3962,17 @@ static WERROR get_a_printer_2(NT_PRINTER_INFO_LEVEL_2 *info,
 	if (get_loc_com && (enum printing_types)lp_printing(snum) == PRINT_CUPS ) {
 		/* Pull the location and comment strings from cups if we don't
 		   already have one */
-		if ( !strlen(info->location) || !strlen(info->comment) )
-			cups_pull_comment_location( info );
+		if ( !strlen(info->location) || !strlen(info->comment) ) {
+			char *location = NULL;
+			comment = NULL;
+			if (cups_pull_comment_location(info, info->sharename,
+						       &comment, &location)) {
+				strlcpy(info->comment, comment, sizeof(info->comment));
+				fstrcpy(info->location, location);
+				TALLOC_FREE(comment);
+				TALLOC_FREE(location);
+			}
+		}
 	}
 #endif
 
diff --git a/source3/printing/print_cups.c b/source3/printing/print_cups.c
index 5c023ed..6735f14 100644
--- a/source3/printing/print_cups.c
+++ b/source3/printing/print_cups.c
@@ -1631,7 +1631,10 @@ struct printif	cups_printif =
 	cups_job_submit,
 };
 
-bool cups_pull_comment_location(NT_PRINTER_INFO_LEVEL_2 *printer)
+bool cups_pull_comment_location(TALLOC_CTX *mem_ctx,
+				const char *printername,
+				char **comment,
+				char **location)
 {
 	TALLOC_CTX *frame = talloc_stackframe();
 	http_t		*http = NULL;		/* HTTP connection to server */
@@ -1652,7 +1655,7 @@ bool cups_pull_comment_location(NT_PRINTER_INFO_LEVEL_2 *printer)
 	bool ret = False;
 	size_t size;
 
-	DEBUG(5, ("pulling %s location\n", printer->sharename));
+	DEBUG(5, ("pulling %s location\n", printername));
 
 	/*
 	 * Make sure we don't ask for passwords...
@@ -1691,7 +1694,7 @@ bool cups_pull_comment_location(NT_PRINTER_INFO_LEVEL_2 *printer)
 	if (server) {
 		goto out;
 	}
-	if (!push_utf8_talloc(frame, &sharename, printer->sharename, &size)) {
+	if (!push_utf8_talloc(frame, &sharename, printername, &size)) {
 		goto out;
 	}
 	slprintf(uri, sizeof(uri) - 1, "ipp://%s/printers/%s",
@@ -1743,40 +1746,30 @@ bool cups_pull_comment_location(NT_PRINTER_INFO_LEVEL_2 *printer)
 
 			/* Grab the comment if we don't have one */
         		if ( (strcmp(attr->name, "printer-info") == 0)
-			     && (attr->value_tag == IPP_TAG_TEXT)
-			     && !strlen(printer->comment) )
+			     && (attr->value_tag == IPP_TAG_TEXT))
 			{
-				char *comment = NULL;
-				if (!pull_utf8_talloc(frame,
-						&comment,
+				if (!pull_utf8_talloc(mem_ctx,
+						comment,
 						attr->values[0].string.text,
 						&size)) {
 					goto out;
 				}
 				DEBUG(5,("cups_pull_comment_location: Using cups comment: %s\n",
-					 comment));
-			    	strlcpy(printer->comment,
-					comment,
-					sizeof(printer->comment));
+					 *comment));
 			}
 
 			/* Grab the location if we don't have one */
 			if ( (strcmp(attr->name, "printer-location") == 0)
-			     && (attr->value_tag == IPP_TAG_TEXT)
-			     && !strlen(printer->location) )
+			     && (attr->value_tag == IPP_TAG_TEXT))
 			{
-				char *location = NULL;
-				if (!pull_utf8_talloc(frame,
-						&location,
+				if (!pull_utf8_talloc(mem_ctx,
+						location,
 						attr->values[0].string.text,
 						&size)) {
 					goto out;
 				}
 				DEBUG(5,("cups_pull_comment_location: Using cups location: %s\n",
-					 location));
-			    	strlcpy(printer->location,
-					location,
-					sizeof(printer->location));
+					 *location));
 			}
 
         		attr = attr->next;
diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c
index 0cf1e13..bb14c59 100644
--- a/source3/rpc_server/srv_spoolss_nt.c
+++ b/source3/rpc_server/srv_spoolss_nt.c
@@ -8481,9 +8481,10 @@ static WERROR getjob_level_1(TALLOC_CTX *mem_ctx,
 	int i = 0;
 	bool found = false;
 
-	for (i=0; i<count && found == false; i++) {
+	for (i=0; i<count; i++) {
 		if (queue[i].job == (int)jobid) {
 			found = true;
+			break;
 		}
 	}
 
@@ -8494,7 +8495,7 @@ static WERROR getjob_level_1(TALLOC_CTX *mem_ctx,
 
 	return fill_job_info1(mem_ctx,
 			      r,
-			      &queue[i-1],
+			      &queue[i],
 			      i,
 			      snum,
 			      ntprinter);
@@ -8516,9 +8517,10 @@ static WERROR getjob_level_2(TALLOC_CTX *mem_ctx,
 	NT_DEVICEMODE *nt_devmode;
 	WERROR result;
 
-	for (i=0; i<count && found == false; i++) {
+	for (i=0; i<count; i++) {
 		if (queue[i].job == (int)jobid) {
 			found = true;
+			break;
 		}
 	}
 
@@ -8549,7 +8551,7 @@ static WERROR getjob_level_2(TALLOC_CTX *mem_ctx,
 
 	return fill_job_info2(mem_ctx,
 			      r,
-			      &queue[i-1],
+			      &queue[i],
 			      i,
 			      snum,
 			      ntprinter,
diff --git a/source4/torture/rpc/spoolss.c b/source4/torture/rpc/spoolss.c
index 6bd3389..61808c0 100644
--- a/source4/torture/rpc/spoolss.c
+++ b/source4/torture/rpc/spoolss.c
@@ -2655,9 +2655,12 @@ static bool test_AddJob(struct torture_context *tctx,
 }
 
 
-static bool test_EnumJobs(struct torture_context *tctx,
-			  struct dcerpc_binding_handle *b,
-			  struct policy_handle *handle)
+static bool test_EnumJobs_args(struct torture_context *tctx,
+			       struct dcerpc_binding_handle *b,
+			       struct policy_handle *handle,
+			       uint32_t level,
+			       uint32_t *count_p,
+			       union spoolss_JobInfo **info_p)
 {
 	NTSTATUS status;
 	struct spoolss_EnumJobs r;
@@ -2668,21 +2671,20 @@ static bool test_EnumJobs(struct torture_context *tctx,
 	r.in.handle = handle;
 	r.in.firstjob = 0;
 	r.in.numjobs = 0xffffffff;
-	r.in.level = 1;
+	r.in.level = level;
 	r.in.buffer = NULL;
 	r.in.offered = 0;
 	r.out.needed = &needed;
 	r.out.count = &count;
 	r.out.info = &info;
 
-	torture_comment(tctx, "Testing EnumJobs\n");
+	torture_comment(tctx, "Testing EnumJobs level %d\n", level);
 
 	status = dcerpc_spoolss_EnumJobs_r(b, tctx, &r);
 
 	torture_assert_ntstatus_ok(tctx, status, "EnumJobs failed");
 
 	if (W_ERROR_EQUAL(r.out.result, WERR_INSUFFICIENT_BUFFER)) {
-		int j;
 		DATA_BLOB blob = data_blob_talloc(tctx, NULL, needed);
 		data_blob_clear(&blob);
 		r.in.buffer = &blob;
@@ -2696,26 +2698,24 @@ static bool test_EnumJobs(struct torture_context *tctx,
 
 		CHECK_NEEDED_SIZE_ENUM_LEVEL(spoolss_EnumJobs, *r.out.info, r.in.level, count, lp_iconv_convenience(tctx->lp_ctx), needed, 4);
 
-		for (j = 0; j < count; j++) {
-
-			torture_assert(tctx, test_GetJob(tctx, b, handle, info[j].info1.job_id),
-				"failed to call test_GetJob");
-
-			test_SetJob(tctx, b, handle, info[j].info1.job_id, SPOOLSS_JOB_CONTROL_PAUSE);
-			test_SetJob(tctx, b, handle, info[j].info1.job_id, SPOOLSS_JOB_CONTROL_RESUME);
-		}
-
 	} else {
 		torture_assert_werr_ok(tctx, r.out.result, "EnumJobs failed");
 	}
 
+	if (count_p) {
+		*count_p = count;
+	}
+	if (info_p) {
+		*info_p = info;
+	}
+
 	return true;
 }
 
-static bool test_DoPrintTest_one_job(struct torture_context *tctx,
-				     struct dcerpc_binding_handle *b,
-				     struct policy_handle *handle,
-				     uint32_t *job_id)
+static bool test_DoPrintTest_add_one_job(struct torture_context *tctx,
+					 struct dcerpc_binding_handle *b,
+					 struct policy_handle *handle,
+					 uint32_t *job_id)
 {
 	NTSTATUS status;
 	struct spoolss_StartDocPrinter s;
@@ -2781,6 +2781,46 @@ static bool test_DoPrintTest_one_job(struct torture_context *tctx,
 	return true;
 }
 
+static bool test_DoPrintTest_check_jobs(struct torture_context *tctx,
+					struct dcerpc_binding_handle *b,
+					struct policy_handle *handle,
+					uint32_t num_jobs,
+					uint32_t *job_ids)
+{
+	uint32_t count;
+	union spoolss_JobInfo *info = NULL;
+	int i;
+
+	torture_assert(tctx,
+		test_AddJob(tctx, b, handle),
+		"AddJob failed");
+
+	torture_assert(tctx,
+		test_EnumJobs_args(tctx, b, handle, 1, &count, &info),
+		"EnumJobs level 1 failed");
+
+	torture_assert_int_equal(tctx, count, num_jobs, "unexpected number of jobs in queue");
+
+	for (i=0; i < num_jobs; i++) {
+		torture_assert_int_equal(tctx, info[i].info1.job_id, job_ids[i], "job id mismatch");
+
+		torture_assert(tctx,
+			test_GetJob(tctx, b, handle, info[i].info1.job_id),
+			"failed to call test_GetJob");
+	}
+
+	for (i=0; i < num_jobs; i++) {
+		torture_assert(tctx,
+			test_SetJob(tctx, b, handle, info[i].info1.job_id, SPOOLSS_JOB_CONTROL_PAUSE),
+			"failed to pause printjob");
+		torture_assert(tctx,
+			test_SetJob(tctx, b, handle, info[i].info1.job_id, SPOOLSS_JOB_CONTROL_RESUME),
+			"failed to resume printjob");
+	}
+
+	return true;
+}
+
 static bool test_DoPrintTest(struct torture_context *tctx,
 			     struct dcerpc_binding_handle *b,
 			     struct policy_handle *handle)
@@ -2793,11 +2833,10 @@ static bool test_DoPrintTest(struct torture_context *tctx,
 	job_ids = talloc_zero_array(tctx, uint32_t, num_jobs);
 
 	for (i=0; i < num_jobs; i++) {
-		ret &= test_DoPrintTest_one_job(tctx, b, handle, &job_ids[i]);
+		ret &= test_DoPrintTest_add_one_job(tctx, b, handle, &job_ids[i]);
 	}
 
-	ret &= test_AddJob(tctx, b, handle);
-	ret &= test_EnumJobs(tctx, b, handle);
+	ret &= test_DoPrintTest_check_jobs(tctx, b, handle, num_jobs, job_ids);
 
 	for (i=0; i < num_jobs; i++) {
 		ret &= test_SetJob(tctx, b, handle, job_ids[i], SPOOLSS_JOB_CONTROL_DELETE);


-- 
Samba Shared Repository


More information about the samba-cvs mailing list