diff options
author | Simo Sorce <ssorce@redhat.com> | 2010-05-05 08:56:46 -0400 |
---|---|---|
committer | Simo Sorce <idra@samba.org> | 2010-07-27 10:27:13 -0400 |
commit | 628f9bee05b96b806225f3494c05c3a86acb1a1f (patch) | |
tree | 577abc6a45de29b7c1949382787c70b6f1819477 /source3 | |
parent | 95f587a565543678da3beeff46167001b92bea79 (diff) | |
download | samba-628f9bee05b96b806225f3494c05c3a86acb1a1f.tar.gz samba-628f9bee05b96b806225f3494c05c3a86acb1a1f.tar.bz2 samba-628f9bee05b96b806225f3494c05c3a86acb1a1f.zip |
s3-spoolss: Use WERROR for print_job_delete.
And also check for PJOB_SMBD_SPOOLING in print_job_write.
Signed-off-by: Jim McDonough <jmcd@samba.org>
Diffstat (limited to 'source3')
-rw-r--r-- | source3/include/proto.h | 4 | ||||
-rw-r--r-- | source3/printing/printing.c | 38 | ||||
-rw-r--r-- | source3/rpc_server/srv_spoolss_nt.c | 11 |
3 files changed, 31 insertions, 22 deletions
diff --git a/source3/include/proto.h b/source3/include/proto.h index a98274bcad..6420b15474 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -4743,8 +4743,8 @@ char *print_job_fname(const char* sharename, uint32 jobid); struct spoolss_DeviceMode *print_job_devmode(const char* sharename, uint32 jobid); 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); +WERROR print_job_delete(struct auth_serversupplied_info *server_info, + int snum, uint32 jobid); bool print_job_pause(struct auth_serversupplied_info *server_info, int snum, uint32 jobid, WERROR *errcode); bool print_job_resume(struct auth_serversupplied_info *server_info, int snum, diff --git a/source3/printing/printing.c b/source3/printing/printing.c index 5f537c5d03..3525f8dc3a 100644 --- a/source3/printing/printing.c +++ b/source3/printing/printing.c @@ -2040,16 +2040,14 @@ static bool is_owner(struct auth_serversupplied_info *server_info, Delete a print job. ****************************************************************************/ -bool print_job_delete(struct auth_serversupplied_info *server_info, int snum, - uint32 jobid, WERROR *errcode) +WERROR print_job_delete(struct auth_serversupplied_info *server_info, + int snum, uint32_t jobid) { - const char* sharename = lp_const_servicename( snum ); + const char* sharename = lp_const_servicename(snum); struct printjob *pjob; bool owner; char *fname; - *errcode = WERR_OK; - owner = is_owner(server_info, lp_const_servicename(snum), jobid); /* Check access against security descriptor or whether the user @@ -2058,7 +2056,6 @@ bool print_job_delete(struct auth_serversupplied_info *server_info, int snum, if (!owner && !print_access_check(server_info, snum, JOB_ACCESS_ADMINISTER)) { DEBUG(3, ("delete denied by security descriptor\n")); - *errcode = WERR_ACCESS_DENIED; /* BEGIN_ADMIN_LOG */ sys_adminlog( LOG_ERR, @@ -2068,7 +2065,7 @@ pause, or resume print job. User name: %s. Printer name: %s.", lp_printername(snum) ); /* END_ADMIN_LOG */ - return False; + return WERR_ACCESS_DENIED; } /* @@ -2078,19 +2075,18 @@ pause, or resume print job. User name: %s. Printer name: %s.", * spool file & return. */ - if ( (fname = print_job_fname( sharename, jobid )) != NULL ) - { + fname = print_job_fname(sharename, jobid); + if (fname != NULL) { /* remove the spool file */ - DEBUG(10,("print_job_delete: Removing spool file [%s]\n", fname )); - if ( unlink( fname ) == -1 ) { - *errcode = map_werror_from_unix(errno); - return False; + DEBUG(10, ("print_job_delete: " + "Removing spool file [%s]\n", fname)); + if (unlink(fname) == -1) { + return map_werror_from_unix(errno); } } if (!print_job_delete1(snum, jobid)) { - *errcode = WERR_ACCESS_DENIED; - return False; + return WERR_ACCESS_DENIED; } /* force update the database and say the delete failed if the @@ -2099,10 +2095,11 @@ pause, or resume print job. User name: %s. Printer name: %s.", print_queue_update(snum, True); pjob = print_job_find(sharename, jobid); - if ( pjob && (pjob->status != LPQ_DELETING) ) - *errcode = WERR_ACCESS_DENIED; + if (pjob && (pjob->status != LPQ_DELETING)) { + return WERR_ACCESS_DENIED; + } - return (pjob == NULL ); + return WERR_PRINTER_HAS_JOBS_QUEUED; } /**************************************************************************** @@ -2243,6 +2240,11 @@ ssize_t print_job_write(int snum, uint32 jobid, const char *buf, SMB_OFF_T pos, if (pjob->pid != sys_getpid()) return -1; + /* if SMBD is spooling this can't be allowed */ + if (pjob->status == PJOB_SMBD_SPOOLING) { + return -1; + } + return_code = write_data_at_offset(pjob->fd, buf, size, pos); if (return_code>0) { diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 1f0b36450f..5a33a34ca5 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -5234,6 +5234,7 @@ WERROR _spoolss_WritePrinter(pipes_struct *p, if (!get_printer_snum(p, r->in.handle, &snum, NULL)) return WERR_BADFID; + /* print_job_write takes care of checking for PJOB_SMBD_SPOOLING */ buffer_written = print_job_write(snum, Printer->jobid, (const char *)r->in.data.data, (SMB_OFF_T)-1, @@ -5314,7 +5315,11 @@ WERROR _spoolss_AbortPrinter(pipes_struct *p, if (!get_printer_snum(p, r->in.handle, &snum, NULL)) return WERR_BADFID; - print_job_delete(p->server_info, snum, Printer->jobid, &errcode ); + if (!Printer->document_started) { + return WERR_SPL_NO_STARTDOC; + } + + errcode = print_job_delete(p->server_info, snum, Printer->jobid); return errcode; } @@ -6573,7 +6578,9 @@ WERROR _spoolss_SetJob(pipes_struct *p, switch (r->in.command) { case SPOOLSS_JOB_CONTROL_CANCEL: case SPOOLSS_JOB_CONTROL_DELETE: - if (print_job_delete(p->server_info, snum, r->in.job_id, &errcode)) { + errcode = print_job_delete(p->server_info, + snum, r->in.job_id); + if (W_ERROR_EQUAL(errcode, WERR_PRINTER_HAS_JOBS_QUEUED)) { errcode = WERR_OK; } break; |