diff options
author | David Disseldorp <ddiss@samba.org> | 2012-02-08 18:47:11 +0100 |
---|---|---|
committer | David Disseldorp <ddiss@samba.org> | 2012-06-26 16:10:39 +0200 |
commit | c29773d89036153a122f577ff9fb2a789e7f156f (patch) | |
tree | e4ec146dfa33a1e97d2d1ecebdd5ab30a68cf01e | |
parent | 91cd9a47974e0099d550c88ee646ee3b1f44df72 (diff) | |
download | samba-c29773d89036153a122f577ff9fb2a789e7f156f.tar.gz samba-c29773d89036153a122f577ff9fb2a789e7f156f.tar.bz2 samba-c29773d89036153a122f577ff9fb2a789e7f156f.zip |
s3-printing: pass lpq command to job_submit
Currently the generic print backend does not fill the printing backend
job identifier (sysjob) on submission of a new job. The sysjob
identifier is required to correctly map jobs in the printer queue to
corresponding spoolss print jobs.
Passing the lpq command to job_submit allows the generic print backend
to check the printer queue for the new job following submission. This
behaviour will come in a later commit.
-rw-r--r-- | source3/include/printing.h | 4 | ||||
-rw-r--r-- | source3/printing/print_cups.c | 4 | ||||
-rw-r--r-- | source3/printing/print_generic.c | 4 | ||||
-rw-r--r-- | source3/printing/print_iprint.c | 4 | ||||
-rw-r--r-- | source3/printing/printing.c | 26 |
5 files changed, 37 insertions, 5 deletions
diff --git a/source3/include/printing.h b/source3/include/printing.h index 222da8c478..5d0672cc36 100644 --- a/source3/include/printing.h +++ b/source3/include/printing.h @@ -102,7 +102,9 @@ struct printif int (*job_delete)(const char *sharename, const char *lprm_command, struct printjob *pjob); int (*job_pause)(int snum, struct printjob *pjob); int (*job_resume)(int snum, struct printjob *pjob); - int (*job_submit)(int snum, struct printjob *pjob); + int (*job_submit)(int snum, struct printjob *pjob, + enum printing_types printing_type, + char *lpq_command); }; extern struct printif generic_printif; diff --git a/source3/printing/print_cups.c b/source3/printing/print_cups.c index 88f143c0c7..b5c7b0d4ec 100644 --- a/source3/printing/print_cups.c +++ b/source3/printing/print_cups.c @@ -852,7 +852,9 @@ static int cups_job_resume(int snum, struct printjob *pjob) * 'cups_job_submit()' - Submit a job for printing. */ -static int cups_job_submit(int snum, struct printjob *pjob) +static int cups_job_submit(int snum, struct printjob *pjob, + enum printing_types printing_type, + char *lpq_cmd) { TALLOC_CTX *frame = talloc_stackframe(); int ret = 1; /* Return value */ diff --git a/source3/printing/print_generic.c b/source3/printing/print_generic.c index 14f4c6dbe7..3211705b8e 100644 --- a/source3/printing/print_generic.c +++ b/source3/printing/print_generic.c @@ -142,7 +142,9 @@ static int generic_job_resume(int snum, struct printjob *pjob) Submit a file for printing - called from print_job_end() ****************************************************************************/ -static int generic_job_submit(int snum, struct printjob *pjob) +static int generic_job_submit(int snum, struct printjob *pjob, + enum printing_types printing_type, + char *lpq_cmd) { int ret = -1; char *current_directory = NULL; diff --git a/source3/printing/print_iprint.c b/source3/printing/print_iprint.c index 78d5098fdf..ea0c93778b 100644 --- a/source3/printing/print_iprint.c +++ b/source3/printing/print_iprint.c @@ -722,7 +722,9 @@ static int iprint_job_resume(int snum, struct printjob *pjob) * 'iprint_job_submit()' - Submit a job for printing. */ -static int iprint_job_submit(int snum, struct printjob *pjob) +static int iprint_job_submit(int snum, struct printjob *pjob, + enum printing_types printing_type, + char *lpq_cmd) { int ret = 1; /* Return value */ http_t *http = NULL; /* HTTP connection to server */ diff --git a/source3/printing/printing.c b/source3/printing/printing.c index 4d0178f185..1e0d61df32 100644 --- a/source3/printing/printing.c +++ b/source3/printing/printing.c @@ -2903,6 +2903,7 @@ NTSTATUS print_job_end(struct messaging_context *msg_ctx, int snum, SMB_STRUCT_STAT sbuf; struct printif *current_printif = get_printer_fns(snum); NTSTATUS status = NT_STATUS_UNSUCCESSFUL; + char *lpq_cmd; TALLOC_CTX *tmp_ctx = talloc_new(msg_ctx); if (tmp_ctx == NULL) { return NT_STATUS_NO_MEMORY; @@ -2970,8 +2971,31 @@ NTSTATUS print_job_end(struct messaging_context *msg_ctx, int snum, return NT_STATUS_OK; } - ret = (*(current_printif->job_submit))(snum, pjob); + /* don't strip out characters like '$' from the printername */ + lpq_cmd = talloc_string_sub2(tmp_ctx, + lp_lpqcommand(snum), + "%p", + lp_printername(snum), + false, false, false); + if (lpq_cmd == NULL) { + status = NT_STATUS_PRINT_CANCELLED; + goto fail; + } + lpq_cmd = talloc_sub_advanced(tmp_ctx, + lp_servicename(snum), + current_user_info.unix_name, + "", + current_user.ut.gid, + get_current_username(), + current_user_info.domain, + lpq_cmd); + if (lpq_cmd == NULL) { + status = NT_STATUS_PRINT_CANCELLED; + goto fail; + } + ret = (*(current_printif->job_submit))(snum, pjob, + current_printif->type, lpq_cmd); if (ret) { status = NT_STATUS_PRINT_CANCELLED; goto fail; |