[SCM] Samba Shared Repository - branch master updated
Günther Deschner
gd at samba.org
Tue Apr 27 16:11:37 MDT 2010
The branch, master has been updated
via f4f9d54... s3-lanman: use spoolss for api_PrintJobInfo().
via d6d8c3f... s4-smbtorture: also try renaming jobname in test_DoPrintTest_check_jobs().
via b87b1de... s4-smbtorture: allow to pass down spoolss_JobInfoContainer to SetJob functions.
via 2af4493... s4-smbtorture: be more liberal when spoolss_SetJob fails.
via 1691eb7... s3-spoolss: add support for SetJobInfo level 1 (for jobfile rename).
via 2b7002f... s3-lanman: remove unsupported print_job_set_place().
from ce8595f... Fix more S3 build breakage. Matthias, please ensure S3 builds when changing common code.
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit f4f9d54721a3b6b9bf61ba84eaf144cbecbcf937
Author: Günther Deschner <gd at samba.org>
Date: Tue Apr 27 19:58:32 2010 +0200
s3-lanman: use spoolss for api_PrintJobInfo().
Guenther
commit d6d8c3ffe3a235fe6b55a79989e1734d229ca8f1
Author: Günther Deschner <gd at samba.org>
Date: Wed Apr 28 00:05:41 2010 +0200
s4-smbtorture: also try renaming jobname in test_DoPrintTest_check_jobs().
Guenther
commit b87b1de83432611e511e511d0320b8c1c1a8b323
Author: Günther Deschner <gd at samba.org>
Date: Tue Apr 27 23:33:05 2010 +0200
s4-smbtorture: allow to pass down spoolss_JobInfoContainer to SetJob functions.
Guenther
commit 2af449391b28dda10ebb797fcf61e2319b36a0b0
Author: Günther Deschner <gd at samba.org>
Date: Tue Apr 27 23:31:25 2010 +0200
s4-smbtorture: be more liberal when spoolss_SetJob fails.
For some reason, spoolss_SetJob pausing and resuming of printjob is still racy
on the buildfarm. Converting the fatal assert to a warning for now.
Guenther
commit 1691eb73da62f3a50c12031d0a76cc6d4deed955
Author: Günther Deschner <gd at samba.org>
Date: Tue Apr 27 19:57:47 2010 +0200
s3-spoolss: add support for SetJobInfo level 1 (for jobfile rename).
Guenther
commit 2b7002f38571a920244d9ad309c606caaf2c0411
Author: Günther Deschner <gd at samba.org>
Date: Tue Apr 27 19:30:49 2010 +0200
s3-lanman: remove unsupported print_job_set_place().
Guenther
-----------------------------------------------------------------------
Summary of changes:
source3/include/proto.h | 4 +-
source3/printing/printing.c | 32 +++++++---
source3/rpc_server/srv_spoolss_nt.c | 49 +++++++++++++++
source3/smbd/lanman.c | 110 ++++++++++++++++++++++++++++-------
source4/torture/rpc/spoolss.c | 57 +++++++++++++++---
5 files changed, 209 insertions(+), 43 deletions(-)
Changeset truncated at 500 lines:
diff --git a/source3/include/proto.h b/source3/include/proto.h
index 09c2c02..f5e9ec4 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -4976,8 +4976,8 @@ bool print_job_exists(const char* sharename, uint32 jobid);
int print_job_fd(const char* sharename, uint32 jobid);
char *print_job_fname(const char* sharename, uint32 jobid);
NT_DEVICEMODE *print_job_devmode(const char* sharename, uint32 jobid);
-bool print_job_set_place(const char *sharename, uint32 jobid, int place);
-bool print_job_set_name(const char *sharename, uint32 jobid, char *name);
+bool print_job_set_name(const char *sharename, uint32 jobid, const char *name);
+bool print_job_get_name(TALLOC_CTX *mem_ctx, const char *sharename, uint32_t jobid, char **name);
bool print_job_delete(struct auth_serversupplied_info *server_info, int snum,
uint32 jobid, WERROR *errcode);
bool print_job_pause(struct auth_serversupplied_info *server_info, int snum,
diff --git a/source3/printing/printing.c b/source3/printing/printing.c
index 9bd98a6..e67c5d4 100644
--- a/source3/printing/printing.c
+++ b/source3/printing/printing.c
@@ -1854,31 +1854,43 @@ NT_DEVICEMODE *print_job_devmode(const char* sharename, uint32 jobid)
}
/****************************************************************************
- Set the place in the queue for a job.
+ Set the name of a job. Only possible for owner.
****************************************************************************/
-bool print_job_set_place(const char *sharename, uint32 jobid, int place)
+bool print_job_set_name(const char *sharename, uint32 jobid, const char *name)
{
- DEBUG(2,("print_job_set_place not implemented yet\n"));
- return False;
+ struct printjob *pjob;
+
+ pjob = print_job_find(sharename, jobid);
+ if (!pjob || pjob->pid != sys_getpid())
+ return False;
+
+ fstrcpy(pjob->jobname, name);
+ return pjob_store(sharename, jobid, pjob);
}
/****************************************************************************
- Set the name of a job. Only possible for owner.
+ Get the name of a job. Only possible for owner.
****************************************************************************/
-bool print_job_set_name(const char *sharename, uint32 jobid, char *name)
+bool print_job_get_name(TALLOC_CTX *mem_ctx, const char *sharename, uint32_t jobid, char **name)
{
struct printjob *pjob;
pjob = print_job_find(sharename, jobid);
- if (!pjob || pjob->pid != sys_getpid())
- return False;
+ if (!pjob || pjob->pid != sys_getpid()) {
+ return false;
+ }
- fstrcpy(pjob->jobname, name);
- return pjob_store(sharename, jobid, pjob);
+ *name = talloc_strdup(mem_ctx, pjob->jobname);
+ if (!*name) {
+ return false;
+ }
+
+ return true;
}
+
/***************************************************************************
Remove a jobid from the 'jobs changed' list.
***************************************************************************/
diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c
index 28e8a7d..db6a6d7 100644
--- a/source3/rpc_server/srv_spoolss_nt.c
+++ b/source3/rpc_server/srv_spoolss_nt.c
@@ -6427,6 +6427,31 @@ WERROR _spoolss_ScheduleJob(pipes_struct *p,
}
/****************************************************************
+****************************************************************/
+
+static WERROR spoolss_setjob_1(TALLOC_CTX *mem_ctx,
+ const char *printer_name,
+ uint32_t job_id,
+ struct spoolss_SetJobInfo1 *r)
+{
+ char *old_doc_name;
+
+ if (!print_job_get_name(mem_ctx, printer_name, job_id, &old_doc_name)) {
+ return WERR_BADFID;
+ }
+
+ if (strequal(old_doc_name, r->document_name)) {
+ return WERR_OK;
+ }
+
+ if (!print_job_set_name(printer_name, job_id, r->document_name)) {
+ return WERR_BADFID;
+ }
+
+ return WERR_OK;
+}
+
+/****************************************************************
_spoolss_SetJob
****************************************************************/
@@ -6462,6 +6487,30 @@ WERROR _spoolss_SetJob(pipes_struct *p,
errcode = WERR_OK;
}
break;
+ case 0:
+ errcode = WERR_OK;
+ break;
+ default:
+ return WERR_UNKNOWN_LEVEL;
+ }
+
+ if (!W_ERROR_IS_OK(errcode)) {
+ return errcode;
+ }
+
+ if (r->in.ctr == NULL) {
+ return errcode;
+ }
+
+ switch (r->in.ctr->level) {
+ case 1:
+ errcode = spoolss_setjob_1(p->mem_ctx, lp_const_servicename(snum),
+ r->in.job_id,
+ r->in.ctr->info.info1);
+ break;
+ case 2:
+ case 3:
+ case 4:
default:
return WERR_UNKNOWN_LEVEL;
}
diff --git a/source3/smbd/lanman.c b/source3/smbd/lanman.c
index 300d9fb..4b7703b 100644
--- a/source3/smbd/lanman.c
+++ b/source3/smbd/lanman.c
@@ -3341,7 +3341,17 @@ static bool api_PrintJobInfo(connection_struct *conn, uint16 vuid,
fstring sharename;
int uLevel = get_safe_SVAL(param,tpscnt,p,2,-1);
int function = get_safe_SVAL(param,tpscnt,p,4,-1);
- int place, errcode;
+ int errcode;
+
+ TALLOC_CTX *mem_ctx = talloc_tos();
+ WERROR werr;
+ NTSTATUS status;
+ struct rpc_pipe_client *cli = NULL;
+ struct policy_handle handle;
+ struct spoolss_DevmodeContainer devmode_ctr;
+ struct spoolss_JobInfoContainer ctr;
+ union spoolss_JobInfo info;
+ struct spoolss_SetJobInfo1 info1;
if (!str1 || !str2 || !p) {
return False;
@@ -3361,10 +3371,34 @@ static bool api_PrintJobInfo(connection_struct *conn, uint16 vuid,
return False;
}
- if (!share_defined(sharename)) {
- DEBUG(0,("api_PrintJobInfo: sharen [%s] not defined\n",
- sharename));
- return False;
+ ZERO_STRUCT(handle);
+
+ status = rpc_pipe_open_internal(mem_ctx, &ndr_table_spoolss.syntax_id,
+ rpc_spoolss_dispatch, conn->server_info,
+ &cli);
+ if (!NT_STATUS_IS_OK(status)) {
+ DEBUG(0,("api_PrintJobInfo: could not connect to spoolss: %s\n",
+ nt_errstr(status)));
+ errcode = W_ERROR_V(ntstatus_to_werror(status));
+ goto out;
+ }
+
+ ZERO_STRUCT(devmode_ctr);
+
+ status = rpccli_spoolss_OpenPrinter(cli, mem_ctx,
+ sharename,
+ NULL,
+ devmode_ctr,
+ SEC_FLAG_MAXIMUM_ALLOWED,
+ &handle,
+ &werr);
+ if (!NT_STATUS_IS_OK(status)) {
+ errcode = W_ERROR_V(ntstatus_to_werror(status));
+ goto out;
+ }
+ if (!W_ERROR_IS_OK(werr)) {
+ errcode = W_ERROR_V(werr);
+ goto out;
}
*rdata_len = 0;
@@ -3374,35 +3408,67 @@ static bool api_PrintJobInfo(connection_struct *conn, uint16 vuid,
(!check_printjob_info(&desc,uLevel,str2)))
return(False);
- if (!print_job_exists(sharename, jobid)) {
- errcode=NERR_JobNotFound;
+ werr = rpccli_spoolss_getjob(cli, mem_ctx,
+ &handle,
+ jobid,
+ 1, /* level */
+ 0, /* offered */
+ &info);
+ if (!W_ERROR_IS_OK(werr)) {
+ errcode = W_ERROR_V(werr);
goto out;
}
errcode = NERR_notsupported;
switch (function) {
- case 0x6:
- /* change job place in the queue,
- data gives the new place */
- place = SVAL(data,0);
- if (print_job_set_place(sharename, jobid, place)) {
- errcode=NERR_Success;
- }
- break;
-
- case 0xb:
+ case 0xb:
/* change print job name, data gives the name */
- if (print_job_set_name(sharename, jobid, data)) {
- errcode=NERR_Success;
- }
break;
-
default:
- return False;
+ goto out;
+ }
+
+ ZERO_STRUCT(ctr);
+
+ info1.job_id = info.info1.job_id;
+ info1.printer_name = info.info1.printer_name;
+ info1.user_name = info.info1.user_name;
+ info1.document_name = data;
+ info1.data_type = info.info1.data_type;
+ info1.text_status = info.info1.text_status;
+ info1.status = info.info1.status;
+ info1.priority = info.info1.priority;
+ info1.position = info.info1.position;
+ info1.total_pages = info.info1.total_pages;
+ info1.pages_printed = info.info1.pages_printed;
+ info1.submitted = info.info1.submitted;
+
+ ctr.level = 1;
+ ctr.info.info1 = &info1;
+
+ status = rpccli_spoolss_SetJob(cli, mem_ctx,
+ &handle,
+ jobid,
+ &ctr,
+ 0,
+ &werr);
+ if (!NT_STATUS_IS_OK(status)) {
+ errcode = W_ERROR_V(ntstatus_to_werror(status));
+ goto out;
+ }
+ if (!W_ERROR_IS_OK(werr)) {
+ errcode = W_ERROR_V(werr);
+ goto out;
}
+ errcode = NERR_Success;
out:
+
+ if (is_valid_policy_hnd(&handle)) {
+ rpccli_spoolss_ClosePrinter(cli, mem_ctx, &handle, NULL);
+ }
+
SSVALS(*rparam,0,errcode);
SSVAL(*rparam,2,0); /* converter word */
diff --git a/source4/torture/rpc/spoolss.c b/source4/torture/rpc/spoolss.c
index 7d0038e..674682b 100644
--- a/source4/torture/rpc/spoolss.c
+++ b/source4/torture/rpc/spoolss.c
@@ -2954,7 +2954,9 @@ static bool test_GetJob(struct torture_context *tctx,
static bool test_SetJob(struct torture_context *tctx,
struct dcerpc_binding_handle *b,
- struct policy_handle *handle, uint32_t job_id,
+ struct policy_handle *handle,
+ uint32_t job_id,
+ struct spoolss_JobInfoContainer *ctr,
enum spoolss_JobControl command)
{
NTSTATUS status;
@@ -2962,7 +2964,7 @@ static bool test_SetJob(struct torture_context *tctx,
r.in.handle = handle;
r.in.job_id = job_id;
- r.in.ctr = NULL;
+ r.in.ctr = ctr;
r.in.command = command;
switch (command) {
@@ -3180,6 +3182,10 @@ static bool test_DoPrintTest_check_jobs(struct torture_context *tctx,
for (i=0; i < num_jobs; i++) {
union spoolss_JobInfo ginfo;
+ const char *document_name;
+ const char *new_document_name = "any_other_docname";
+ struct spoolss_JobInfoContainer ctr;
+ struct spoolss_SetJobInfo1 info1;
torture_assert_int_equal(tctx, info[i].info1.job_id, job_ids[i], "job id mismatch");
@@ -3188,15 +3194,48 @@ static bool test_DoPrintTest_check_jobs(struct torture_context *tctx,
"failed to call test_GetJob");
torture_assert_int_equal(tctx, ginfo.info1.job_id, info[i].info1.job_id, "job id mismatch");
- }
- for (i=0; i < num_jobs; i++) {
+ document_name = ginfo.info1.document_name;
+
+ info1.job_id = ginfo.info1.job_id;
+ info1.printer_name = ginfo.info1.printer_name;
+ info1.server_name = ginfo.info1.server_name;
+ info1.user_name = ginfo.info1.user_name;
+ info1.document_name = new_document_name;
+ info1.data_type = ginfo.info1.data_type;
+ info1.text_status = ginfo.info1.text_status;
+ info1.status = ginfo.info1.status;
+ info1.priority = ginfo.info1.priority;
+ info1.position = ginfo.info1.position;
+ info1.total_pages = ginfo.info1.total_pages;
+ info1.pages_printed = ginfo.info1.pages_printed;
+ info1.submitted = ginfo.info1.submitted;
+
+ ctr.level = 1;
+ ctr.info.info1 = &info1;
+
torture_assert(tctx,
- test_SetJob(tctx, b, handle, info[i].info1.job_id, SPOOLSS_JOB_CONTROL_PAUSE),
- "failed to pause printjob");
+ test_SetJob(tctx, b, handle, info[i].info1.job_id, &ctr, 0),
+ "failed to call test_SetJob level 1");
+
torture_assert(tctx,
- test_SetJob(tctx, b, handle, info[i].info1.job_id, SPOOLSS_JOB_CONTROL_RESUME),
- "failed to resume printjob");
+ test_GetJob_args(tctx, b, handle, info[i].info1.job_id, 1, &ginfo),
+ "failed to call test_GetJob");
+
+ if (strequal(ginfo.info1.document_name, document_name)) {
+ torture_warning(tctx,
+ talloc_asprintf(tctx, "document_name did *NOT* change from '%s' to '%s'\n",
+ document_name, new_document_name));
+ }
+ }
+
+ for (i=0; i < num_jobs; i++) {
+ if (!test_SetJob(tctx, b, handle, info[i].info1.job_id, NULL, SPOOLSS_JOB_CONTROL_PAUSE)) {
+ torture_warning(tctx, "failed to pause printjob\n");
+ }
+ if (!test_SetJob(tctx, b, handle, info[i].info1.job_id, NULL, SPOOLSS_JOB_CONTROL_RESUME)) {
+ torture_warning(tctx, "failed to resume printjob\n");
+ }
}
return true;
@@ -3220,7 +3259,7 @@ static bool test_DoPrintTest(struct torture_context *tctx,
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);
+ ret &= test_SetJob(tctx, b, handle, job_ids[i], NULL, SPOOLSS_JOB_CONTROL_DELETE);
}
return ret;
--
Samba Shared Repository
More information about the samba-cvs
mailing list