summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Disseldorp <ddiss@samba.org>2013-09-19 20:31:37 -0700
committerKarolin Seeger <kseeger@samba.org>2013-11-26 20:38:14 +0100
commit15cd0e09fa85cf148975b0db5fe7be06f16d7702 (patch)
tree5026ad5474d74caf11e80f95dc7550aebc5272af
parenteb9fde4097c1911bce3fbedc1d0e2555f6e3e7b2 (diff)
downloadsamba-15cd0e09fa85cf148975b0db5fe7be06f16d7702.tar.gz
spoolss: return the spoolss job ID in notifications
Print job notifications currently carry the system print job identifier from the queue structure. Instead, the spoolss job identifier should be resolved and returned. Print clients can use notification job-ids in subsequent spoolss SetJob requests. Returning an incorrect identifier can result in the failure of such requests, e.g. spoolss_SetJob(SPOOLSS_JOB_CONTROL_DELETE). BUG: https://bugzilla.samba.org/show_bug.cgi?id=10271 Signed-off-by: David Disseldorp <ddiss@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org> Reviewed-by: Günther Deschner <gd@samba.org> (cherry picked from commit 24d025f85d6eea272bff5e1040d4fd2ba0e6b8f3)
-rw-r--r--source3/include/printing.h1
-rw-r--r--source3/printing/printing.c2
-rw-r--r--source3/rpc_server/spoolss/srv_spoolss_nt.c32
3 files changed, 28 insertions, 7 deletions
diff --git a/source3/include/printing.h b/source3/include/printing.h
index 391fb7ae823..ec5a53b7fd6 100644
--- a/source3/include/printing.h
+++ b/source3/include/printing.h
@@ -193,6 +193,7 @@ uint16_t print_spool_rap_jobid(struct print_file_data *print_file);
/* The following definitions come from printing/printing.c */
+uint32 sysjob_to_jobid_pdb(struct tdb_print_db *pdb, int sysjob);
uint32 sysjob_to_jobid(int unix_jobid);
bool print_notify_register_pid(int snum);
bool print_notify_deregister_pid(int snum);
diff --git a/source3/printing/printing.c b/source3/printing/printing.c
index 43f75e5c438..57d2f0cf714 100644
--- a/source3/printing/printing.c
+++ b/source3/printing/printing.c
@@ -519,7 +519,7 @@ static int unixjob_traverse_fn(TDB_CONTEXT *the_tdb, TDB_DATA key,
return 0;
}
-static uint32 sysjob_to_jobid_pdb(struct tdb_print_db *pdb, int sysjob)
+uint32 sysjob_to_jobid_pdb(struct tdb_print_db *pdb, int sysjob)
{
struct unixjob_traverse_state state;
diff --git a/source3/rpc_server/spoolss/srv_spoolss_nt.c b/source3/rpc_server/spoolss/srv_spoolss_nt.c
index b13f8b0fd73..7359cb22b0d 100644
--- a/source3/rpc_server/spoolss/srv_spoolss_nt.c
+++ b/source3/rpc_server/spoolss/srv_spoolss_nt.c
@@ -3611,6 +3611,7 @@ static WERROR printer_notify_info(struct pipes_struct *p,
print_status_struct status;
struct spoolss_PrinterInfo2 *pinfo2 = NULL;
WERROR result;
+ struct tdb_print_db *pdb;
DEBUG(4,("printer_notify_info\n"));
@@ -3634,13 +3635,19 @@ static WERROR printer_notify_info(struct pipes_struct *p,
return WERR_BADFID;
}
+ pdb = get_print_db_byname(Printer->sharename);
+ if (pdb == NULL) {
+ return WERR_BADFID;
+ }
+
/* Maybe we should use the SYSTEM session_info here... */
result = winreg_get_printer_internal(mem_ctx,
get_session_info_system(),
p->msg_ctx,
lp_servicename(talloc_tos(), snum), &pinfo2);
if (!W_ERROR_IS_OK(result)) {
- return WERR_BADFID;
+ result = WERR_BADFID;
+ goto err_pdb_drop;
}
/*
@@ -3649,10 +3656,11 @@ static WERROR printer_notify_info(struct pipes_struct *p,
*/
pinfo2->servername = talloc_strdup(pinfo2, Printer->servername);
if (pinfo2->servername == NULL) {
- return WERR_NOMEM;
+ result = WERR_NOMEM;
+ goto err_pdb_drop;
}
- for (i=0; i<option->count; i++) {
+ for (i = 0; i < option->count; i++) {
option_type = option->types[i];
switch (option_type.type) {
@@ -3671,12 +3679,21 @@ static WERROR printer_notify_info(struct pipes_struct *p,
count = print_queue_status(p->msg_ctx, snum, &queue,
&status);
- for (j=0; j<count; j++) {
+ for (j = 0; j < count; j++) {
+ uint32_t jobid;
+ jobid = sysjob_to_jobid_pdb(pdb,
+ queue[j].sysjob);
+ if (jobid == (uint32_t)-1) {
+ DEBUG(2, ("ignoring untracked job %d\n",
+ queue[j].sysjob));
+ continue;
+ }
+ /* FIXME check return value */
construct_notify_jobs_info(p->msg_ctx,
&queue[j], info,
pinfo2, snum,
&option_type,
- queue[j].sysjob,
+ jobid,
mem_ctx);
}
@@ -3701,7 +3718,10 @@ static WERROR printer_notify_info(struct pipes_struct *p,
*/
talloc_free(pinfo2);
- return WERR_OK;
+ result = WERR_OK;
+err_pdb_drop:
+ release_print_db(pdb);
+ return result;
}
/****************************************************************