From d418f9f11abb5b5ed038acbaf5dbb2a656d39d87 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Mon, 16 Aug 2010 13:53:10 +0200 Subject: s3-printing: Lift the use of smbd_server_fd from job_submit. Signed-off-by: Andreas Schneider --- source3/include/printing.h | 3 ++- source3/printing/print_cups.c | 9 +-------- source3/printing/print_iprint.c | 9 +-------- source3/printing/printing.c | 14 ++++++++++++-- 4 files changed, 16 insertions(+), 19 deletions(-) diff --git a/source3/include/printing.h b/source3/include/printing.h index 334b7a1e71..1aa4e38b80 100644 --- a/source3/include/printing.h +++ b/source3/include/printing.h @@ -39,6 +39,7 @@ struct printjob { fstring filename; /* the filename used to spool the file */ fstring jobname; /* the job name given to us by the client */ fstring user; /* the user who started the job */ + fstring clientmachine; /* The client machine which started this job */ fstring queuename; /* service number of printer for this job */ struct spoolss_DeviceMode *devmode; }; @@ -82,7 +83,7 @@ extern struct printif iprint_printif; #ifndef PRINT_SPOOL_PREFIX #define PRINT_SPOOL_PREFIX "smbprn." #endif -#define PRINT_DATABASE_VERSION 5 +#define PRINT_DATABASE_VERSION 6 /* There can be this many printing tdb's open, plus any locked ones. */ #define MAX_PRINT_DBS_OPEN 1 diff --git a/source3/printing/print_cups.c b/source3/printing/print_cups.c index 2441cfc275..a85fba8997 100644 --- a/source3/printing/print_cups.c +++ b/source3/printing/print_cups.c @@ -912,7 +912,6 @@ static int cups_job_submit(int snum, struct printjob *pjob) ipp_attribute_t *attr_job_id = NULL; /* IPP Attribute "job-id" */ cups_lang_t *language = NULL; /* Default language */ char uri[HTTP_MAX_URI]; /* printer-uri attribute */ - const char *clientname = NULL; /* hostname of client for job-originating-host attribute */ char *new_jobname = NULL; int num_options = 0; cups_option_t *options = NULL; @@ -923,7 +922,6 @@ static int cups_job_submit(int snum, struct printjob *pjob) char *filename = NULL; size_t size; uint32_t jobid = (uint32_t)-1; - char addr[INET6_ADDRSTRLEN]; DEBUG(5,("cups_job_submit(%d, %p)\n", snum, pjob)); @@ -981,14 +979,9 @@ static int cups_job_submit(int snum, struct printjob *pjob) ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "requesting-user-name", NULL, user); - clientname = client_name(smbd_server_fd()); - if (strcmp(clientname, "UNKNOWN") == 0) { - clientname = client_addr(smbd_server_fd(),addr,sizeof(addr)); - } - ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "job-originating-host-name", NULL, - clientname); + pjob->clientmachine); /* Get the jobid from the filename. */ jobid = print_parse_jobid(pjob->filename); diff --git a/source3/printing/print_iprint.c b/source3/printing/print_iprint.c index 75324960ef..ea375da3b7 100644 --- a/source3/printing/print_iprint.c +++ b/source3/printing/print_iprint.c @@ -731,8 +731,6 @@ static int iprint_job_submit(int snum, struct printjob *pjob) ipp_attribute_t *attr; /* Current attribute */ cups_lang_t *language = NULL; /* Default language */ char uri[HTTP_MAX_URI]; /* printer-uri attribute */ - const char *clientname = NULL; /* hostname of client for job-originating-host attribute */ - char addr[INET6_ADDRSTRLEN]; DEBUG(5,("iprint_job_submit(%d, %p (%d))\n", snum, pjob, pjob->sysjob)); @@ -785,14 +783,9 @@ static int iprint_job_submit(int snum, struct printjob *pjob) ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "requesting-user-name", NULL, pjob->user); - clientname = client_name(smbd_server_fd()); - if (strcmp(clientname, "UNKNOWN") == 0) { - clientname = client_addr(smbd_server_fd(),addr,sizeof(addr)); - } - ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "job-originating-host-name", NULL, - clientname); + pjob->clientmachine); ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "job-name", NULL, pjob->jobname); diff --git a/source3/printing/printing.c b/source3/printing/printing.c index 69191ef9a8..31b802d3fb 100644 --- a/source3/printing/printing.c +++ b/source3/printing/printing.c @@ -375,7 +375,7 @@ int unpack_pjob( uint8 *buf, int buflen, struct printjob *pjob ) if ( !buf || !pjob ) return -1; - len += tdb_unpack(buf+len, buflen-len, "dddddddddffff", + len += tdb_unpack(buf+len, buflen-len, "dddddddddfffff", &pjpid, &pjsysjob, &pjfd, @@ -388,6 +388,7 @@ int unpack_pjob( uint8 *buf, int buflen, struct printjob *pjob ) pjob->filename, pjob->jobname, pjob->user, + pjob->clientmachine, pjob->queuename); if ( len == -1 ) @@ -641,7 +642,7 @@ static bool pjob_store(struct tevent_context *ev, do { len = 0; buflen = newlen; - len += tdb_pack(buf+len, buflen-len, "dddddddddffff", + len += tdb_pack(buf+len, buflen-len, "dddddddddfffff", (uint32)pjob->pid, (uint32)pjob->sysjob, (uint32)pjob->fd, @@ -654,6 +655,7 @@ static bool pjob_store(struct tevent_context *ev, pjob->filename, pjob->jobname, pjob->user, + pjob->clientmachine, pjob->queuename); len += pack_devicemode(pjob->devmode, buf+len, buflen-len); @@ -2810,6 +2812,8 @@ 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; + const char *clientname; + char addr[INET6_ADDRSTRLEN]; pjob = print_job_find(sharename, jobid); @@ -2872,6 +2876,12 @@ NTSTATUS print_job_end(struct messaging_context *msg_ctx, int snum, return NT_STATUS_OK; } + clientname = client_name(smbd_server_fd()); + if (strcmp(clientname, "UNKNOWN") == 0) { + clientname = client_addr(smbd_server_fd(),addr,sizeof(addr)); + } + fstrcpy(pjob->clientmachine, clientname); + ret = (*(current_printif->job_submit))(snum, pjob); if (ret) { -- cgit