summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source3/include/proto.h3
-rw-r--r--source3/printing/printing.c24
-rw-r--r--source3/rpc_server/srv_spoolss_nt.c49
3 files changed, 74 insertions, 2 deletions
diff --git a/source3/include/proto.h b/source3/include/proto.h
index 1f35808d92..f5e9ec4e06 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -4976,7 +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_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 a6b1ad3484..e67c5d41a3 100644
--- a/source3/printing/printing.c
+++ b/source3/printing/printing.c
@@ -1857,7 +1857,7 @@ NT_DEVICEMODE *print_job_devmode(const char* sharename, uint32 jobid)
Set the name of a job. Only possible for owner.
****************************************************************************/
-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)
{
struct printjob *pjob;
@@ -1869,6 +1869,28 @@ bool print_job_set_name(const char *sharename, uint32 jobid, char *name)
return pjob_store(sharename, jobid, pjob);
}
+/****************************************************************************
+ Get the name of a job. Only possible for owner.
+****************************************************************************/
+
+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;
+ }
+
+ *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 28e8a7d5e7..db6a6d784a 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;
}