mirror of
https://github.com/samba-team/samba.git
synced 2025-01-04 05:18:06 +03:00
AbortPrinter() fix merged from APP_HEAD.
This commit is contained in:
parent
a9112a1e4b
commit
97ede49e12
@ -1048,8 +1048,11 @@ static BOOL is_owner(struct current_user *user, int snum, uint32 jobid)
|
||||
|
||||
BOOL print_job_delete(struct current_user *user, int snum, uint32 jobid, WERROR *errcode)
|
||||
{
|
||||
BOOL owner;
|
||||
BOOL owner, deleted;
|
||||
char *fname;
|
||||
|
||||
*errcode = WERR_OK;
|
||||
|
||||
owner = is_owner(user, snum, jobid);
|
||||
|
||||
/* Check access against security descriptor or whether the user
|
||||
@ -1062,15 +1065,40 @@ BOOL print_job_delete(struct current_user *user, int snum, uint32 jobid, WERROR
|
||||
return False;
|
||||
}
|
||||
|
||||
if (!print_job_delete1(snum, jobid))
|
||||
/*
|
||||
* get the spooled filename of the print job
|
||||
* if this works, then the file has not been spooled
|
||||
* to the underlying print system. Just delete the
|
||||
* spool file & return.
|
||||
*/
|
||||
|
||||
if ( (fname = print_job_fname( snum, jobid )) != 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;
|
||||
}
|
||||
|
||||
return True;
|
||||
}
|
||||
|
||||
if (!print_job_delete1(snum, jobid)) {
|
||||
*errcode = WERR_ACCESS_DENIED;
|
||||
return False;
|
||||
}
|
||||
|
||||
/* force update the database and say the delete failed if the
|
||||
job still exists */
|
||||
|
||||
print_queue_update(snum);
|
||||
|
||||
deleted = !print_job_exists(snum, jobid);
|
||||
if ( !deleted )
|
||||
*errcode = WERR_ACCESS_DENIED;
|
||||
|
||||
return !print_job_exists(snum, jobid);
|
||||
return deleted;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
@ -5417,13 +5417,31 @@ static WERROR control_printer(POLICY_HND *handle, uint32 command,
|
||||
|
||||
/********************************************************************
|
||||
* api_spoolss_abortprinter
|
||||
* From MSDN: "Deletes printer's spool file if printer is configured
|
||||
* for spooling"
|
||||
********************************************************************/
|
||||
|
||||
WERROR _spoolss_abortprinter(pipes_struct *p, SPOOL_Q_ABORTPRINTER *q_u, SPOOL_R_ABORTPRINTER *r_u)
|
||||
{
|
||||
POLICY_HND *handle = &q_u->handle;
|
||||
|
||||
return control_printer(handle, PRINTER_CONTROL_PURGE, p);
|
||||
POLICY_HND *handle = &q_u->handle;
|
||||
Printer_entry *Printer = find_printer_index_by_hnd(p, handle);
|
||||
int snum;
|
||||
struct current_user user;
|
||||
WERROR errcode = WERR_OK;
|
||||
|
||||
if (!Printer) {
|
||||
DEBUG(2,("_spoolss_abortprinter: Invalid handle (%s:%u:%u)\n",OUR_HANDLE(handle)));
|
||||
return WERR_BADFID;
|
||||
}
|
||||
|
||||
if (!get_printer_snum(p, handle, &snum))
|
||||
return WERR_BADFID;
|
||||
|
||||
get_current_user( &user, p );
|
||||
|
||||
print_job_delete( &user, snum, Printer->jobid, &errcode );
|
||||
|
||||
return errcode;
|
||||
}
|
||||
|
||||
/********************************************************************
|
||||
|
Loading…
Reference in New Issue
Block a user