From dc2d1544b3718dce5b3d7d91989b3cc5abfdef6b Mon Sep 17 00:00:00 2001 From: Jean-François Micouleau Date: Wed, 5 Apr 2000 10:05:32 +0000 Subject: changed all the status code to ERROR_xxx instead of NT_STATUS_xx which are wrong in the spoolss case. fxed a bug in the job notify code (that's the polite answer), the truth is different: there is a bug in the NT spooler service, including SP6a and NT2K. changed the default lpcommand in the LPRNG case. J.F. (This used to be commit 396f73c11b29a47650b3243fef0825252a3cef9b) --- source3/include/smb.h | 3 + source3/param/loadparm.c | 9 ++ source3/rpc_parse/parse_spoolss.c | 2 +- source3/rpc_server/srv_spoolss_nt.c | 162 ++++++++++++++++-------------------- 4 files changed, 87 insertions(+), 89 deletions(-) (limited to 'source3') diff --git a/source3/include/smb.h b/source3/include/smb.h index ee70a0279b..819a5ec5c5 100644 --- a/source3/include/smb.h +++ b/source3/include/smb.h @@ -171,7 +171,10 @@ implemented */ #define ERRbaddirectory 267 /* Invalid directory name in a path. */ #define ERRunknownipc 2142 +#define ERROR_INVALID_FUNCTION (1) #define ERROR_ACCESS_DENIED (5) +#define ERROR_INVALID_HANDLE (6) +#define ERROR_NOT_ENOUGH_MEMORY (8) #define ERROR_INVALID_PARAMETER (87) #define ERROR_INSUFFICIENT_BUFFER (122) #define ERROR_INVALID_NAME (123) diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c index e0cf808b57..5f948f78a4 100644 --- a/source3/param/loadparm.c +++ b/source3/param/loadparm.c @@ -1090,11 +1090,20 @@ static void init_locals(void) { case PRINT_BSD: case PRINT_AIX: + string_set(&sDefault.szLpqcommand,"lpq -P%p"); + string_set(&sDefault.szLprmcommand,"lprm -P%p %j"); + string_set(&sDefault.szPrintcommand,"lpr -r -P%p %s"); + break; + case PRINT_LPRNG: case PRINT_PLP: string_set(&sDefault.szLpqcommand,"lpq -P%p"); string_set(&sDefault.szLprmcommand,"lprm -P%p %j"); string_set(&sDefault.szPrintcommand,"lpr -r -P%p %s"); + string_set(&sDefault.szQueuepausecommand, "lpc stop %p"); + string_set(&sDefault.szQueueresumecommand, "lpc start %p"); + string_set(&sDefault.szLppausecommand, "lpc hold %p %j"); + string_set(&sDefault.szLpresumecommand, "lpc release %p %j"); break; case PRINT_CUPS: diff --git a/source3/rpc_parse/parse_spoolss.c b/source3/rpc_parse/parse_spoolss.c index 0450ebd243..18e736e9af 100644 --- a/source3/rpc_parse/parse_spoolss.c +++ b/source3/rpc_parse/parse_spoolss.c @@ -379,7 +379,7 @@ BOOL smb_io_notify_info_data_strings(char *desc,SPOOL_NOTIFY_INFO_DATA *data, uint32 x; BOOL isvalue; - prs_debug(ps, depth, desc, "smb_io_notify_info_data"); + prs_debug(ps, depth, desc, "smb_io_notify_info_data_strings"); depth++; if(!prs_align(ps)) diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index e55f1fb305..79ad5197cd 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -564,7 +564,7 @@ static BOOL convert_devicemode(DEVICEMODE devmode, NT_DEVICEMODE *nt_devmode) uint32 _spoolss_closeprinter(POLICY_HND *handle) { if (!close_printer_handle(handle)) - return NT_STATUS_INVALID_HANDLE; + return ERROR_INVALID_HANDLE; return NT_STATUS_NO_PROBLEMO; } @@ -723,7 +723,7 @@ uint32 _spoolss_getprinterdata(const POLICY_HND *handle, UNISTR2 *valuename, if (!OPEN_HANDLE(Printer)) { *data=(uint8 *)malloc(4*sizeof(uint8)); - return NT_STATUS_INVALID_HANDLE; + return ERROR_INVALID_HANDLE; } unistr2_to_ascii(value, valuename, sizeof(value)-1); @@ -767,7 +767,7 @@ uint32 _spoolss_rffpcnex(const POLICY_HND *handle, uint32 flags, uint32 options, Printer_entry *Printer=find_printer_index_by_hnd(handle); if (!OPEN_HANDLE(Printer)) - return NT_STATUS_INVALID_HANDLE; + return ERROR_INVALID_HANDLE; Printer->notify.flags=flags; Printer->notify.options=options; @@ -1411,7 +1411,7 @@ static uint32 printer_notify_info(const POLICY_HND *hnd, SPOOL_NOTIFY_INFO *info DEBUG(4,("printer_notify_info\n")); option=Printer->notify.option; - id=1; + id=0xffffffff; info->version=2; info->data=NULL; info->count=0; @@ -1425,15 +1425,14 @@ static uint32 printer_notify_info(const POLICY_HND *hnd, SPOOL_NOTIFY_INFO *info switch ( option_type->type ) { case PRINTER_NOTIFY_TYPE: if(construct_notify_printer_info(info, snum, option_type, id)) - id++; + id--; break; case JOB_NOTIFY_TYPE: memset(&status, 0, sizeof(status)); count=get_printqueue(snum, NULL, &queue, &status); for (j=0; jprinter_type)); @@ -1496,7 +1495,7 @@ uint32 _spoolss_rfnpcnex( const POLICY_HND *handle, uint32 change, break; } - return NT_STATUS_INVALID_INFO_CLASS; + return ERROR_INVALID_HANDLE; } /******************************************************************** @@ -1577,7 +1576,7 @@ static BOOL construct_printer_info_0(PRINTER_INFO_0 *printer, int snum, pstring printer->build_version = 0x0565; /* build 1381 */ printer->unknown7 = 0x1; printer->unknown8 = 0x0; - printer->unknown9 = 0x2; + printer->unknown9 = 0x0; printer->session_counter = session_counter->counter; printer->unknown11 = 0x0; printer->printer_errors = 0x0; /* number of print failure */ @@ -2083,7 +2082,7 @@ uint32 _spoolss_enumprinters( uint32 flags, const UNISTR2 *servername, uint32 le case 3: case 4: default: - return NT_STATUS_INVALID_LEVEL; + return ERROR_INVALID_LEVEL; break; } } @@ -2198,7 +2197,7 @@ uint32 _spoolss_getprinter(POLICY_HND *handle, uint32 level, pstrcpy(servername, global_myname); if (!get_printer_snum(handle, &snum)) - return NT_STATUS_INVALID_HANDLE; + return ERROR_INVALID_HANDLE; switch (level) { case 0: @@ -2361,7 +2360,7 @@ static void fill_printer_driver_info_3(DRIVER_INFO_3 *info, snprintf(temp_helpfile, sizeof(temp_helpfile)-1, "%s%s", where, driver.info_3->helpfile); init_unistr( &(info->helpfile), temp_helpfile ); - init_unistr( &(info->monitorname), driver.info_3->monitorname ); + init_unistr( &(info->monitorname), driver.info_3->monitorname ); init_unistr( &(info->defaultdatatype), driver.info_3->defaultdatatype ); info->dependentfiles=NULL; @@ -2499,7 +2498,7 @@ uint32 _spoolss_getprinterdriver2(const POLICY_HND *handle, const UNISTR2 *uni_a unistr2_to_ascii(architecture, uni_arch, sizeof(architecture)-1); if (!get_printer_snum(handle, &snum)) - return NT_STATUS_INVALID_HANDLE; + return ERROR_INVALID_HANDLE; switch (level) { case 1: @@ -2512,7 +2511,7 @@ uint32 _spoolss_getprinterdriver2(const POLICY_HND *handle, const UNISTR2 *uni_a return getprinterdriver2_level3(servername, architecture, snum, buffer, offered, needed); break; default: - return NT_STATUS_INVALID_LEVEL; + return ERROR_INVALID_LEVEL; break; } } @@ -2530,7 +2529,7 @@ uint32 _spoolss_startpageprinter(const POLICY_HND *handle) } DEBUG(3,("Error in startpageprinter printer handle\n")); - return NT_STATUS_INVALID_HANDLE; + return ERROR_INVALID_HANDLE; } /**************************************************************************** @@ -2542,7 +2541,7 @@ uint32 _spoolss_endpageprinter(const POLICY_HND *handle) if (!OPEN_HANDLE(Printer)) { DEBUG(3,("Error in endpageprinter printer handle\n")); - return NT_STATUS_INVALID_HANDLE; + return ERROR_INVALID_HANDLE; } Printer->page_started=False; @@ -2570,7 +2569,7 @@ uint32 _spoolss_startdocprinter( const POLICY_HND *handle, uint32 level, if (!OPEN_HANDLE(Printer)) { - return NT_STATUS_INVALID_HANDLE; + return ERROR_INVALID_HANDLE; } /* @@ -2598,7 +2597,7 @@ uint32 _spoolss_startdocprinter( const POLICY_HND *handle, uint32 level, /* get the share number of the printer */ if (!get_printer_snum(handle, &snum)) { - return NT_STATUS_INVALID_HANDLE; + return ERROR_INVALID_HANDLE; } /* Create a temporary file in the printer spool directory @@ -2643,7 +2642,7 @@ uint32 _spoolss_enddocprinter(const POLICY_HND *handle) if (!OPEN_HANDLE(Printer)) { DEBUG(3,("Error in enddocprinter handle\n")); - return NT_STATUS_INVALID_HANDLE; + return ERROR_INVALID_HANDLE; } Printer->document_started=False; @@ -2655,7 +2654,7 @@ uint32 _spoolss_enddocprinter(const POLICY_HND *handle) if (!get_printer_snum(handle,&snum)) { - return NT_STATUS_INVALID_HANDLE; + return ERROR_INVALID_HANDLE; } /* copy the command into the buffer for extensive meddling. */ @@ -2681,8 +2680,7 @@ uint32 _spoolss_enddocprinter(const POLICY_HND *handle) */ tstr = lp_printername(snum); - if (tstr == NULL || tstr[0] == '\0') - { + if (tstr == NULL || tstr[0] == '\0') { DEBUG(3,( "No printer name - using %s.\n", SERVICE(snum))); tstr = SERVICE(snum); } @@ -2692,22 +2690,19 @@ uint32 _spoolss_enddocprinter(const POLICY_HND *handle) /* If the lpr command support the 'Job' option replace here */ pstring_sub(syscmd, "%j", job_name); - if ( *syscmd != '\0') - { - int ret = smbrun(syscmd, NULL, False); - DEBUG(3,("Running the command `%s' gave %d\n", syscmd, ret)); - if (ret < 0) - { + if ( *syscmd != '\0') { + int ret = smbrun(syscmd, NULL, False); + DEBUG(3,("Running the command `%s' gave %d\n", syscmd, ret)); + if (ret < 0) { lpq_reset(snum); - return NT_STATUS_ACCESS_DENIED; + return ERROR_ACCESS_DENIED; } } - else - { - DEBUG(0,("Null print command?\n")); - lpq_reset(snum); - return NT_STATUS_ACCESS_DENIED; - } + else { + DEBUG(0,("Null print command?\n")); + lpq_reset(snum); + return ERROR_ACCESS_DENIED; + } lpq_reset(snum); @@ -2727,7 +2722,7 @@ uint32 _spoolss_writeprinter( const POLICY_HND *handle, if (!OPEN_HANDLE(Printer)) { DEBUG(3,("Error in writeprinter handle\n")); - return NT_STATUS_INVALID_HANDLE; + return ERROR_INVALID_HANDLE; } fd = Printer->document_fd; @@ -2748,10 +2743,10 @@ static uint32 control_printer(const POLICY_HND *handle, uint32 command) Printer_entry *Printer = find_printer_index_by_hnd(handle); if (!OPEN_HANDLE(Printer)) - return NT_STATUS_INVALID_HANDLE; + return ERROR_INVALID_HANDLE; if (!get_printer_snum(handle, &snum) ) - return NT_STATUS_INVALID_HANDLE; + return ERROR_INVALID_HANDLE; switch (command) { case PRINTER_CONTROL_PAUSE: @@ -2777,7 +2772,7 @@ static uint32 control_printer(const POLICY_HND *handle, uint32 command) break; } - return NT_STATUS_INVALID_INFO_CLASS; + return ERROR_INVALID_FUNCTION; } /******************************************************************** @@ -2800,14 +2795,14 @@ static uint32 update_printer(const POLICY_HND *handle, uint32 level, if (level!=2) { DEBUG(0,("Send a mail to jfm@samba.org\n")); DEBUGADD(0,("with the following message: update_printer: level!=2\n")); - return NT_STATUS_INVALID_INFO_CLASS; + return ERROR_INVALID_LEVEL; } if (!OPEN_HANDLE(Printer)) - return NT_STATUS_INVALID_HANDLE; + return ERROR_INVALID_HANDLE; if (!get_printer_snum(handle, &snum) ) - return NT_STATUS_INVALID_HANDLE; + return ERROR_INVALID_HANDLE; get_a_printer(&printer, 2, lp_servicename(snum)); @@ -2840,7 +2835,7 @@ static uint32 update_printer(const POLICY_HND *handle, uint32 level, free_a_printer(printer, 2); /* I don't really know what to return here !!! */ - return NT_STATUS_INVALID_INFO_CLASS; + return ERROR_ACCESS_DENIED; } free_a_printer(printer, 2); @@ -2858,7 +2853,7 @@ uint32 _spoolss_setprinter(const POLICY_HND *handle, uint32 level, Printer_entry *Printer = find_printer_index_by_hnd(handle); if (!OPEN_HANDLE(Printer)) - return NT_STATUS_INVALID_HANDLE; + return ERROR_INVALID_HANDLE; /* check the level */ switch (level) { @@ -2881,7 +2876,7 @@ uint32 _spoolss_fcpn(const POLICY_HND *handle) Printer_entry *Printer= find_printer_index_by_hnd(handle); if (!OPEN_HANDLE(Printer)) - return NT_STATUS_INVALID_HANDLE; + return ERROR_INVALID_HANDLE; Printer->notify.flags=0; Printer->notify.options=0; @@ -3087,7 +3082,7 @@ uint32 _spoolss_enumjobs( POLICY_HND *handle, uint32 firstjob, uint32 numofjobs, if (!get_printer_snum(handle, &snum)) { - return NT_STATUS_INVALID_HANDLE; + return ERROR_INVALID_HANDLE; } *returned = get_printqueue(snum, NULL, &queue, &prt_status); @@ -3101,7 +3096,7 @@ uint32 _spoolss_enumjobs( POLICY_HND *handle, uint32 firstjob, uint32 numofjobs, return enumjobs_level2(queue, snum, buffer, offered, needed, returned); break; default: - return NT_STATUS_INVALID_LEVEL; + return ERROR_INVALID_LEVEL; break; } } @@ -3133,26 +3128,21 @@ uint32 _spoolss_setjob( const POLICY_HND *handle, memset(&prt_status, 0, sizeof(prt_status)); - if (!get_printer_snum(handle, &snum)) - { - return NT_STATUS_INVALID_HANDLE; + if (!get_printer_snum(handle, &snum)) { + return ERROR_INVALID_HANDLE; } count=get_printqueue(snum, NULL, &queue, &prt_status); - while ( (i