summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source3/include/printing.h2
-rw-r--r--source3/printing/printing.c12
-rw-r--r--source3/rpc_server/srv_spoolss_nt.c101
3 files changed, 68 insertions, 47 deletions
diff --git a/source3/include/printing.h b/source3/include/printing.h
index f347bd0dda..9002fea582 100644
--- a/source3/include/printing.h
+++ b/source3/include/printing.h
@@ -38,7 +38,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 qname; /* name of the print queue the job was sent to */
+ int snum; /* service number of printer for this job */
};
/* Information for print interfaces */
diff --git a/source3/printing/printing.c b/source3/printing/printing.c
index 10466cd5f2..f783f8d590 100644
--- a/source3/printing/printing.c
+++ b/source3/printing/printing.c
@@ -163,7 +163,7 @@ static void print_unix_job(int snum, print_queue_struct *q)
fstrcpy(pj.filename, "");
fstrcpy(pj.jobname, q->file);
fstrcpy(pj.user, q->user);
- fstrcpy(pj.qname, lp_servicename(snum));
+ pj.snum = snum;
print_job_store(jobid, &pj);
}
@@ -185,7 +185,7 @@ static int traverse_fn_delete(TDB_CONTEXT *t, TDB_DATA key, TDB_DATA data, void
memcpy(&jobid, key.dptr, sizeof(jobid));
memcpy(&pjob, data.dptr, sizeof(pjob));
- if (strcmp(lp_servicename(ts->snum), pjob.qname)) {
+ if (ts->snum != pjob.snum) {
/* this isn't for the queue we are looking at */
ts->total_jobs++;
return 0;
@@ -552,7 +552,7 @@ int print_job_snum(int jobid)
struct printjob *pjob = print_job_find(jobid);
if (!pjob) return -1;
- return lp_servicenumber(pjob->qname);
+ return pjob->snum;
}
/****************************************************************************
@@ -959,7 +959,7 @@ int print_job_start(struct current_user *user, int snum, char *jobname)
fstrcpy(pjob.user, uidtoname(user->uid));
}
- fstrcpy(pjob.qname, lp_servicename(snum));
+ pjob.snum = snum;
/* lock the database */
tdb_lock_bystring(tdb, "INFO/nextjob");
@@ -1113,7 +1113,7 @@ static int traverse_fn_queue(TDB_CONTEXT *t, TDB_DATA key, TDB_DATA data, void *
memcpy(&pjob, data.dptr, sizeof(pjob));
/* maybe it isn't for this queue */
- if (ts->snum != print_queue_snum(pjob.qname)) return 0;
+ if (ts->snum != pjob.snum) return 0;
if (ts->qcount >= ts->maxcount) return 0;
@@ -1148,7 +1148,7 @@ static int traverse_count_fn_queue(TDB_CONTEXT *t, TDB_DATA key, TDB_DATA data,
memcpy(&pjob, data.dptr, sizeof(pjob));
/* maybe it isn't for this queue */
- if (ts->snum != print_queue_snum(pjob.qname)) return 0;
+ if (ts->snum != pjob.snum) return 0;
ts->count++;
diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c
index cdddb8b564..6f46b4bc42 100644
--- a/source3/rpc_server/srv_spoolss_nt.c
+++ b/source3/rpc_server/srv_spoolss_nt.c
@@ -4868,7 +4868,8 @@ static void fill_job_info_1(JOB_INFO_1 *job_info, print_queue_struct *queue,
****************************************************************************/
static BOOL fill_job_info_2(JOB_INFO_2 *job_info, print_queue_struct *queue,
int position, int snum,
- NT_PRINTER_INFO_LEVEL *ntprinter)
+ NT_PRINTER_INFO_LEVEL *ntprinter,
+ DEVICEMODE *devmode)
{
pstring temp_name;
pstring chaine;
@@ -4906,9 +4907,7 @@ static BOOL fill_job_info_2(JOB_INFO_2 *job_info, print_queue_struct *queue,
job_info->timeelapsed=0;
job_info->pagesprinted=0;
- if((job_info->devmode = construct_dev_mode(snum)) == NULL) {
- return False;
- }
+ job_info->devmode = devmode;
return (True);
}
@@ -4967,24 +4966,33 @@ static WERROR enumjobs_level2(print_queue_struct *queue, int snum,
uint32 *needed, uint32 *returned)
{
NT_PRINTER_INFO_LEVEL *ntprinter = NULL;
- JOB_INFO_2 *info;
+ JOB_INFO_2 *info = NULL;
int i;
WERROR result;
+ DEVICEMODE *devmode = NULL;
info=(JOB_INFO_2 *)malloc(*returned*sizeof(JOB_INFO_2));
if (info==NULL) {
*returned=0;
- return WERR_NOMEM;
+ result = WERR_NOMEM;
+ goto done;
}
result = get_a_printer(&ntprinter, 2, lp_servicename(snum));
if (!W_ERROR_IS_OK(result)) {
*returned = 0;
- return result;
+ goto done;
}
-
+
+ if (!(devmode = construct_dev_mode(snum))) {
+ *returned = 0;
+ result = WERR_NOMEM;
+ goto done;
+ }
+
for (i=0; i<*returned; i++)
- fill_job_info_2(&(info[i]), &queue[i], i, snum, ntprinter);
+ fill_job_info_2(&(info[i]), &queue[i], i, snum, ntprinter,
+ devmode);
free_a_printer(&ntprinter, 2);
SAFE_FREE(queue);
@@ -4993,27 +5001,30 @@ static WERROR enumjobs_level2(print_queue_struct *queue, int snum,
for (i=0; i<*returned; i++)
(*needed) += spoolss_size_job_info_2(&info[i]);
+ if (*needed > offered) {
+ *returned=0;
+ result = WERR_INSUFFICIENT_BUFFER;
+ goto done;
+ }
+
if (!alloc_buffer_size(buffer, *needed)) {
- SAFE_FREE(info);
- return WERR_INSUFFICIENT_BUFFER;
+ result = WERR_INSUFFICIENT_BUFFER;
+ goto done;
}
/* fill the buffer with the structures */
for (i=0; i<*returned; i++)
smb_io_job_info_2("", buffer, &info[i], 0);
- /* clear memory */
- for (i = 0; i < *returned; i++)
- free_job_info_2(&info[i]);
+ result = WERR_OK;
+ done:
+ free_a_printer(&ntprinter, 2);
+ free_devmode(devmode);
+ SAFE_FREE(queue);
SAFE_FREE(info);
- if (*needed > offered) {
- *returned=0;
- return WERR_INSUFFICIENT_BUFFER;
- }
-
- return WERR_OK;
+ return result;
}
/****************************************************************************
@@ -6918,14 +6929,15 @@ static WERROR getjob_level_2(print_queue_struct *queue, int count, int snum, uin
JOB_INFO_2 *info_2;
NT_PRINTER_INFO_LEVEL *ntprinter = NULL;
WERROR ret;
+ DEVICEMODE *devmode = NULL;
info_2=(JOB_INFO_2 *)malloc(sizeof(JOB_INFO_2));
ZERO_STRUCTP(info_2);
if (info_2 == NULL) {
- SAFE_FREE(queue);
- return WERR_NOMEM;
+ ret = WERR_NOMEM;
+ goto done;
}
for (i=0; i<count && found==False; i++) {
@@ -6934,39 +6946,48 @@ static WERROR getjob_level_2(print_queue_struct *queue, int count, int snum, uin
}
if (found==False) {
- SAFE_FREE(queue);
- SAFE_FREE(info_2);
- /* NT treats not found as bad param... yet another bad choice */
- return WERR_INVALID_PARAM;
+ /* NT treats not found as bad param... yet another bad
+ choice */
+ ret = WERR_INVALID_PARAM;
+ goto done;
}
ret = get_a_printer(&ntprinter, 2, lp_servicename(snum));
- if (!W_ERROR_IS_OK(ret)) {
- SAFE_FREE(queue);
- return ret;
+ if (!W_ERROR_IS_OK(ret))
+ goto done;
+
+ if (construct_dev_mode(snum) == NULL) {
+ ret = WERR_NOMEM;
+ goto done;
}
- fill_job_info_2(info_2, &(queue[i-1]), i, snum, ntprinter);
-
- free_a_printer(&ntprinter, 2);
- SAFE_FREE(queue);
+ fill_job_info_2(info_2, &(queue[i-1]), i, snum, ntprinter, devmode);
*needed += spoolss_size_job_info_2(info_2);
if (!alloc_buffer_size(buffer, *needed)) {
- SAFE_FREE(info_2);
- return WERR_INSUFFICIENT_BUFFER;
+ ret = WERR_INSUFFICIENT_BUFFER;
+ goto done;
}
smb_io_job_info_2("", buffer, info_2, 0);
- free_job_info_2(info_2);
- SAFE_FREE(info_2);
+ if (*needed > offered) {
+ ret = WERR_INSUFFICIENT_BUFFER;
+ goto done;
+ }
- if (*needed > offered)
- return WERR_INSUFFICIENT_BUFFER;
+ ret = WERR_OK;
+
+ done:
+ /* Cleanup allocated memory */
- return WERR_OK;
+ SAFE_FREE(queue);
+ free_job_info_2(info_2); /* Also frees devmode */
+ SAFE_FREE(info_2);
+ free_a_printer(&ntprinter, 2);
+
+ return ret;
}
/****************************************************************************