diff options
author | Günther Deschner <gd@samba.org> | 2010-04-27 19:57:47 +0200 |
---|---|---|
committer | Günther Deschner <gd@samba.org> | 2010-04-28 00:10:40 +0200 |
commit | 1691eb73da62f3a50c12031d0a76cc6d4deed955 (patch) | |
tree | 3e984189132f6bdc077f6d97e906d14b664a44d7 | |
parent | 2b7002f38571a920244d9ad309c606caaf2c0411 (diff) | |
download | samba-1691eb73da62f3a50c12031d0a76cc6d4deed955.tar.gz samba-1691eb73da62f3a50c12031d0a76cc6d4deed955.tar.bz2 samba-1691eb73da62f3a50c12031d0a76cc6d4deed955.zip |
s3-spoolss: add support for SetJobInfo level 1 (for jobfile rename).
Guenther
-rw-r--r-- | source3/include/proto.h | 3 | ||||
-rw-r--r-- | source3/printing/printing.c | 24 | ||||
-rw-r--r-- | source3/rpc_server/srv_spoolss_nt.c | 49 |
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; } |