mirror of
https://github.com/samba-team/samba.git
synced 2025-08-03 04:22:09 +03:00
Fixed open handle code in printers - 3 functions were always being done
in order - moved them into open_printer_hnd(). Added saving of comment field. Jeremy.
This commit is contained in:
@ -239,6 +239,7 @@ typedef struct nt_printer_info_level_2
|
|||||||
fstring sharename;
|
fstring sharename;
|
||||||
fstring portname;
|
fstring portname;
|
||||||
fstring drivername;
|
fstring drivername;
|
||||||
|
fstring comment;
|
||||||
fstring location;
|
fstring location;
|
||||||
NT_DEVICEMODE *devmode;
|
NT_DEVICEMODE *devmode;
|
||||||
fstring sepfile;
|
fstring sepfile;
|
||||||
|
@ -1671,7 +1671,7 @@ void update_a_form(nt_forms_struct **list, const FORM *form, int count);
|
|||||||
int get_ntdrivers(fstring **list, char *architecture);
|
int get_ntdrivers(fstring **list, char *architecture);
|
||||||
void get_short_archi(char *short_archi, char *long_archi);
|
void get_short_archi(char *short_archi, char *long_archi);
|
||||||
uint32 get_a_printer_driver_9x_compatible(pstring line, fstring model);
|
uint32 get_a_printer_driver_9x_compatible(pstring line, fstring model);
|
||||||
uint32 del_a_printer(char *portname);
|
uint32 del_a_printer(char *sharename);
|
||||||
BOOL add_a_specific_param(NT_PRINTER_INFO_LEVEL_2 *info_2, NT_PRINTER_PARAM *param);
|
BOOL add_a_specific_param(NT_PRINTER_INFO_LEVEL_2 *info_2, NT_PRINTER_PARAM *param);
|
||||||
BOOL unlink_specific_param_if_exist(NT_PRINTER_INFO_LEVEL_2 *info_2, NT_PRINTER_PARAM *param);
|
BOOL unlink_specific_param_if_exist(NT_PRINTER_INFO_LEVEL_2 *info_2, NT_PRINTER_PARAM *param);
|
||||||
NT_DEVICEMODE *construct_nt_devicemode(const fstring default_devicename);
|
NT_DEVICEMODE *construct_nt_devicemode(const fstring default_devicename);
|
||||||
@ -3050,49 +3050,49 @@ uint32 _spoolss_open_printer_ex( const UNISTR2 *printername,
|
|||||||
POLICY_HND *handle);
|
POLICY_HND *handle);
|
||||||
uint32 _spoolss_closeprinter(POLICY_HND *handle);
|
uint32 _spoolss_closeprinter(POLICY_HND *handle);
|
||||||
uint32 _spoolss_deleteprinter(POLICY_HND *handle);
|
uint32 _spoolss_deleteprinter(POLICY_HND *handle);
|
||||||
uint32 _spoolss_getprinterdata(const POLICY_HND *handle, UNISTR2 *valuename,
|
uint32 _spoolss_getprinterdata(POLICY_HND *handle, UNISTR2 *valuename,
|
||||||
uint32 in_size,
|
uint32 in_size,
|
||||||
uint32 *type,
|
uint32 *type,
|
||||||
uint32 *out_size,
|
uint32 *out_size,
|
||||||
uint8 **data,
|
uint8 **data,
|
||||||
uint32 *needed);
|
uint32 *needed);
|
||||||
uint32 _spoolss_rffpcnex(const POLICY_HND *handle, uint32 flags, uint32 options,
|
uint32 _spoolss_rffpcnex(POLICY_HND *handle, uint32 flags, uint32 options,
|
||||||
const UNISTR2 *localmachine, uint32 printerlocal,
|
const UNISTR2 *localmachine, uint32 printerlocal,
|
||||||
SPOOL_NOTIFY_OPTION *option);
|
SPOOL_NOTIFY_OPTION *option);
|
||||||
uint32 _spoolss_rfnpcnex( const POLICY_HND *handle, uint32 change,
|
uint32 _spoolss_rfnpcnex( POLICY_HND *handle, uint32 change,
|
||||||
SPOOL_NOTIFY_OPTION *option, SPOOL_NOTIFY_INFO *info);
|
SPOOL_NOTIFY_OPTION *option, SPOOL_NOTIFY_INFO *info);
|
||||||
uint32 _spoolss_enumprinters( uint32 flags, const UNISTR2 *servername, uint32 level,
|
uint32 _spoolss_enumprinters( uint32 flags, const UNISTR2 *servername, uint32 level,
|
||||||
NEW_BUFFER *buffer, uint32 offered,
|
NEW_BUFFER *buffer, uint32 offered,
|
||||||
uint32 *needed, uint32 *returned);
|
uint32 *needed, uint32 *returned);
|
||||||
uint32 _spoolss_getprinter(POLICY_HND *handle, uint32 level,
|
uint32 _spoolss_getprinter(POLICY_HND *handle, uint32 level,
|
||||||
NEW_BUFFER *buffer, uint32 offered, uint32 *needed);
|
NEW_BUFFER *buffer, uint32 offered, uint32 *needed);
|
||||||
uint32 _spoolss_getprinterdriver2(const POLICY_HND *handle, const UNISTR2 *uni_arch, uint32 level,
|
uint32 _spoolss_getprinterdriver2(POLICY_HND *handle, const UNISTR2 *uni_arch, uint32 level,
|
||||||
uint32 clientmajorversion, uint32 clientminorversion,
|
uint32 clientmajorversion, uint32 clientminorversion,
|
||||||
NEW_BUFFER *buffer, uint32 offered,
|
NEW_BUFFER *buffer, uint32 offered,
|
||||||
uint32 *needed, uint32 *servermajorversion, uint32 *serverminorversion);
|
uint32 *needed, uint32 *servermajorversion, uint32 *serverminorversion);
|
||||||
uint32 _spoolss_startpageprinter(const POLICY_HND *handle);
|
uint32 _spoolss_startpageprinter(POLICY_HND *handle);
|
||||||
uint32 _spoolss_endpageprinter(const POLICY_HND *handle);
|
uint32 _spoolss_endpageprinter(POLICY_HND *handle);
|
||||||
uint32 _spoolss_startdocprinter(const POLICY_HND *handle, uint32 level,
|
uint32 _spoolss_startdocprinter(POLICY_HND *handle, uint32 level,
|
||||||
pipes_struct *p, DOC_INFO *docinfo,
|
pipes_struct *p, DOC_INFO *docinfo,
|
||||||
uint32 *jobid);
|
uint32 *jobid);
|
||||||
uint32 _spoolss_enddocprinter(const POLICY_HND *handle);
|
uint32 _spoolss_enddocprinter(POLICY_HND *handle);
|
||||||
uint32 _spoolss_writeprinter( const POLICY_HND *handle,
|
uint32 _spoolss_writeprinter( POLICY_HND *handle,
|
||||||
uint32 buffer_size,
|
uint32 buffer_size,
|
||||||
const uint8 *buffer,
|
uint8 *buffer,
|
||||||
uint32 *buffer_written);
|
uint32 *buffer_written);
|
||||||
uint32 _spoolss_setprinter(const POLICY_HND *handle, uint32 level,
|
uint32 _spoolss_setprinter(POLICY_HND *handle, uint32 level,
|
||||||
const SPOOL_PRINTER_INFO_LEVEL *info,
|
const SPOOL_PRINTER_INFO_LEVEL *info,
|
||||||
DEVMODE_CTR devmode_ctr,
|
DEVMODE_CTR devmode_ctr,
|
||||||
SEC_DESC_BUF *secdesc_ctr,
|
SEC_DESC_BUF *secdesc_ctr,
|
||||||
uint32 command, pipes_struct *p);
|
uint32 command, pipes_struct *p);
|
||||||
uint32 _spoolss_fcpn(const POLICY_HND *handle);
|
uint32 _spoolss_fcpn(POLICY_HND *handle);
|
||||||
uint32 _spoolss_addjob(const POLICY_HND *handle, uint32 level,
|
uint32 _spoolss_addjob(POLICY_HND *handle, uint32 level,
|
||||||
NEW_BUFFER *buffer, uint32 offered);
|
NEW_BUFFER *buffer, uint32 offered);
|
||||||
uint32 _spoolss_enumjobs( POLICY_HND *handle, uint32 firstjob, uint32 numofjobs, uint32 level,
|
uint32 _spoolss_enumjobs( POLICY_HND *handle, uint32 firstjob, uint32 numofjobs, uint32 level,
|
||||||
NEW_BUFFER *buffer, uint32 offered,
|
NEW_BUFFER *buffer, uint32 offered,
|
||||||
uint32 *needed, uint32 *returned);
|
uint32 *needed, uint32 *returned);
|
||||||
uint32 _spoolss_schedulejob( const POLICY_HND *handle, uint32 jobid);
|
uint32 _spoolss_schedulejob( POLICY_HND *handle, uint32 jobid);
|
||||||
uint32 _spoolss_setjob( const POLICY_HND *handle,
|
uint32 _spoolss_setjob( POLICY_HND *handle,
|
||||||
uint32 jobid,
|
uint32 jobid,
|
||||||
uint32 level,
|
uint32 level,
|
||||||
pipes_struct *p,
|
pipes_struct *p,
|
||||||
@ -3101,7 +3101,7 @@ uint32 _spoolss_setjob( const POLICY_HND *handle,
|
|||||||
uint32 _spoolss_enumprinterdrivers( UNISTR2 *name, UNISTR2 *environment, uint32 level,
|
uint32 _spoolss_enumprinterdrivers( UNISTR2 *name, UNISTR2 *environment, uint32 level,
|
||||||
NEW_BUFFER *buffer, uint32 offered,
|
NEW_BUFFER *buffer, uint32 offered,
|
||||||
uint32 *needed, uint32 *returned);
|
uint32 *needed, uint32 *returned);
|
||||||
uint32 _new_spoolss_enumforms( const POLICY_HND *handle, uint32 level,
|
uint32 _new_spoolss_enumforms( POLICY_HND *handle, uint32 level,
|
||||||
NEW_BUFFER *buffer, uint32 offered,
|
NEW_BUFFER *buffer, uint32 offered,
|
||||||
uint32 *needed, uint32 *numofforms);
|
uint32 *needed, uint32 *numofforms);
|
||||||
uint32 _spoolss_enumports( UNISTR2 *name, uint32 level,
|
uint32 _spoolss_enumports( UNISTR2 *name, uint32 level,
|
||||||
@ -3118,22 +3118,22 @@ uint32 _spoolss_addprinterdriver( const UNISTR2 *server_name,
|
|||||||
uint32 _spoolss_getprinterdriverdirectory(UNISTR2 *name, UNISTR2 *uni_environment, uint32 level,
|
uint32 _spoolss_getprinterdriverdirectory(UNISTR2 *name, UNISTR2 *uni_environment, uint32 level,
|
||||||
NEW_BUFFER *buffer, uint32 offered,
|
NEW_BUFFER *buffer, uint32 offered,
|
||||||
uint32 *needed);
|
uint32 *needed);
|
||||||
uint32 _spoolss_enumprinterdata(const POLICY_HND *handle, uint32 idx,
|
uint32 _spoolss_enumprinterdata(POLICY_HND *handle, uint32 idx,
|
||||||
uint32 in_value_len, uint32 in_data_len,
|
uint32 in_value_len, uint32 in_data_len,
|
||||||
uint32 *out_max_value_len, uint16 **out_value, uint32 *out_value_len,
|
uint32 *out_max_value_len, uint16 **out_value, uint32 *out_value_len,
|
||||||
uint32 *out_type,
|
uint32 *out_type,
|
||||||
uint32 *out_max_data_len, uint8 **data_out, uint32 *out_data_len);
|
uint32 *out_max_data_len, uint8 **data_out, uint32 *out_data_len);
|
||||||
uint32 _spoolss_setprinterdata( const POLICY_HND *handle,
|
uint32 _spoolss_setprinterdata( POLICY_HND *handle,
|
||||||
const UNISTR2 *value,
|
const UNISTR2 *value,
|
||||||
uint32 type,
|
uint32 type,
|
||||||
uint32 max_len,
|
uint32 max_len,
|
||||||
const uint8 *data,
|
const uint8 *data,
|
||||||
uint32 real_len,
|
uint32 real_len,
|
||||||
uint32 numeric_data);
|
uint32 numeric_data);
|
||||||
uint32 _spoolss_addform( const POLICY_HND *handle,
|
uint32 _spoolss_addform( POLICY_HND *handle,
|
||||||
uint32 level,
|
uint32 level,
|
||||||
const FORM *form);
|
const FORM *form);
|
||||||
uint32 _spoolss_setform( const POLICY_HND *handle,
|
uint32 _spoolss_setform( POLICY_HND *handle,
|
||||||
const UNISTR2 *uni_name,
|
const UNISTR2 *uni_name,
|
||||||
uint32 level,
|
uint32 level,
|
||||||
const FORM *form);
|
const FORM *form);
|
||||||
|
@ -644,13 +644,13 @@ static int pack_specifics(NT_PRINTER_PARAM *param, char *buf, int buflen)
|
|||||||
delete a printer - this just deletes the printer info file, any open
|
delete a printer - this just deletes the printer info file, any open
|
||||||
handles are not affected
|
handles are not affected
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
uint32 del_a_printer(char *portname)
|
uint32 del_a_printer(char *sharename)
|
||||||
{
|
{
|
||||||
pstring key;
|
pstring key;
|
||||||
TDB_DATA kbuf;
|
TDB_DATA kbuf;
|
||||||
|
|
||||||
slprintf(key, sizeof(key), "%s%s",
|
slprintf(key, sizeof(key), "%s%s",
|
||||||
PRINTERS_PREFIX, portname);
|
PRINTERS_PREFIX, sharename);
|
||||||
|
|
||||||
kbuf.dptr=key;
|
kbuf.dptr=key;
|
||||||
kbuf.dsize=strlen(key)+1;
|
kbuf.dsize=strlen(key)+1;
|
||||||
@ -678,8 +678,8 @@ static uint32 add_a_printer_2(NT_PRINTER_INFO_LEVEL_2 *info)
|
|||||||
* Samba manages only local printers.
|
* Samba manages only local printers.
|
||||||
* we currently don't support things like path=\\other_server\printer
|
* we currently don't support things like path=\\other_server\printer
|
||||||
*/
|
*/
|
||||||
if (info->servername[0]!='\0')
|
|
||||||
{
|
if (info->servername[0]!='\0') {
|
||||||
trim_string(info->printername, info->servername, NULL);
|
trim_string(info->printername, info->servername, NULL);
|
||||||
trim_string(info->printername, "\\", NULL);
|
trim_string(info->printername, "\\", NULL);
|
||||||
info->servername[0]='\0';
|
info->servername[0]='\0';
|
||||||
@ -704,7 +704,7 @@ static uint32 add_a_printer_2(NT_PRINTER_INFO_LEVEL_2 *info)
|
|||||||
|
|
||||||
again:
|
again:
|
||||||
len = 0;
|
len = 0;
|
||||||
len += tdb_pack(buf+len, buflen-len, "dddddddddddffffffffff",
|
len += tdb_pack(buf+len, buflen-len, "dddddddddddfffffffffff",
|
||||||
info->attributes,
|
info->attributes,
|
||||||
info->priority,
|
info->priority,
|
||||||
info->default_priority,
|
info->default_priority,
|
||||||
@ -721,6 +721,7 @@ static uint32 add_a_printer_2(NT_PRINTER_INFO_LEVEL_2 *info)
|
|||||||
info->sharename,
|
info->sharename,
|
||||||
info->portname,
|
info->portname,
|
||||||
info->drivername,
|
info->drivername,
|
||||||
|
info->comment,
|
||||||
info->location,
|
info->location,
|
||||||
info->sepfile,
|
info->sepfile,
|
||||||
info->printprocessor,
|
info->printprocessor,
|
||||||
@ -1093,6 +1094,7 @@ static uint32 get_a_printer_2_default(NT_PRINTER_INFO_LEVEL_2 **info_ptr, fstrin
|
|||||||
fstrcpy(info.printername, sharename);
|
fstrcpy(info.printername, sharename);
|
||||||
fstrcpy(info.portname, sharename);
|
fstrcpy(info.portname, sharename);
|
||||||
fstrcpy(info.drivername, lp_printerdriver(snum));
|
fstrcpy(info.drivername, lp_printerdriver(snum));
|
||||||
|
fstrcpy(info.comment, "");
|
||||||
fstrcpy(info.printprocessor, "winprint");
|
fstrcpy(info.printprocessor, "winprint");
|
||||||
fstrcpy(info.datatype, "RAW");
|
fstrcpy(info.datatype, "RAW");
|
||||||
|
|
||||||
@ -1152,7 +1154,7 @@ static uint32 get_a_printer_2(NT_PRINTER_INFO_LEVEL_2 **info_ptr, fstring sharen
|
|||||||
if (!dbuf.dptr) return 1;
|
if (!dbuf.dptr) return 1;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
len += tdb_unpack(dbuf.dptr+len, dbuf.dsize-len, "dddddddddddffffffffff",
|
len += tdb_unpack(dbuf.dptr+len, dbuf.dsize-len, "dddddddddddfffffffffff",
|
||||||
&info.attributes,
|
&info.attributes,
|
||||||
&info.priority,
|
&info.priority,
|
||||||
&info.default_priority,
|
&info.default_priority,
|
||||||
@ -1169,27 +1171,25 @@ static uint32 get_a_printer_2(NT_PRINTER_INFO_LEVEL_2 **info_ptr, fstring sharen
|
|||||||
info.sharename,
|
info.sharename,
|
||||||
info.portname,
|
info.portname,
|
||||||
info.drivername,
|
info.drivername,
|
||||||
|
info.comment,
|
||||||
info.location,
|
info.location,
|
||||||
info.sepfile,
|
info.sepfile,
|
||||||
info.printprocessor,
|
info.printprocessor,
|
||||||
info.datatype,
|
info.datatype,
|
||||||
info.parameters);
|
info.parameters);
|
||||||
|
|
||||||
info.attributes |= PRINTER_ATTRIBUTE_RAW_ONLY; /* Samba has to have raw drivers. */
|
/* Samba has to have shared raw drivers. */
|
||||||
|
info.attributes |= (PRINTER_ATTRIBUTE_SHARED|PRINTER_ATTRIBUTE_RAW_ONLY);
|
||||||
|
|
||||||
len += unpack_devicemode(&info.devmode,dbuf.dptr+len, dbuf.dsize-len);
|
len += unpack_devicemode(&info.devmode,dbuf.dptr+len, dbuf.dsize-len);
|
||||||
len += unpack_specifics(&info.specific,dbuf.dptr+len, dbuf.dsize-len);
|
len += unpack_specifics(&info.specific,dbuf.dptr+len, dbuf.dsize-len);
|
||||||
|
|
||||||
#if 1 /* JRATEST */
|
|
||||||
nt_printing_getsec(sharename, &info.secdesc_buf);
|
nt_printing_getsec(sharename, &info.secdesc_buf);
|
||||||
#endif /* JRATEST */
|
|
||||||
|
|
||||||
fstrcpy(info.sharename, "");
|
|
||||||
|
|
||||||
safe_free(dbuf.dptr);
|
safe_free(dbuf.dptr);
|
||||||
*info_ptr=memdup(&info, sizeof(info));
|
*info_ptr=memdup(&info, sizeof(info));
|
||||||
|
|
||||||
DEBUG(9,("Unpacked printer [%s] running drier [%s]\n",
|
DEBUG(9,("Unpacked printer [%s] running driver [%s]\n",
|
||||||
sharename, info.drivername));
|
sharename, info.drivername));
|
||||||
|
|
||||||
|
|
||||||
@ -1233,6 +1233,7 @@ static uint32 dump_a_printer(NT_PRINTER_INFO_LEVEL printer, uint32 level)
|
|||||||
DEBUGADD(106,("sharename:[%s]\n", info2->sharename));
|
DEBUGADD(106,("sharename:[%s]\n", info2->sharename));
|
||||||
DEBUGADD(106,("portname:[%s]\n", info2->portname));
|
DEBUGADD(106,("portname:[%s]\n", info2->portname));
|
||||||
DEBUGADD(106,("drivername:[%s]\n", info2->drivername));
|
DEBUGADD(106,("drivername:[%s]\n", info2->drivername));
|
||||||
|
DEBUGADD(106,("comment:[%s]\n", info2->comment));
|
||||||
DEBUGADD(106,("location:[%s]\n", info2->location));
|
DEBUGADD(106,("location:[%s]\n", info2->location));
|
||||||
DEBUGADD(106,("sepfile:[%s]\n", info2->sepfile));
|
DEBUGADD(106,("sepfile:[%s]\n", info2->sepfile));
|
||||||
DEBUGADD(106,("printprocessor:[%s]\n", info2->printprocessor));
|
DEBUGADD(106,("printprocessor:[%s]\n", info2->printprocessor));
|
||||||
|
@ -4236,8 +4236,7 @@ BOOL uni_2_asc_printer_info_2(const SPOOL_PRINTER_INFO_LEVEL_2 *uni,
|
|||||||
DEBUG(7,("Converting from UNICODE to ASCII\n"));
|
DEBUG(7,("Converting from UNICODE to ASCII\n"));
|
||||||
time_unix=time(NULL);
|
time_unix=time(NULL);
|
||||||
|
|
||||||
if (*asc==NULL)
|
if (*asc==NULL) {
|
||||||
{
|
|
||||||
DEBUGADD(8,("allocating memory\n"));
|
DEBUGADD(8,("allocating memory\n"));
|
||||||
|
|
||||||
*asc=(NT_PRINTER_INFO_LEVEL_2 *)malloc(sizeof(NT_PRINTER_INFO_LEVEL_2));
|
*asc=(NT_PRINTER_INFO_LEVEL_2 *)malloc(sizeof(NT_PRINTER_INFO_LEVEL_2));
|
||||||
@ -4268,6 +4267,7 @@ BOOL uni_2_asc_printer_info_2(const SPOOL_PRINTER_INFO_LEVEL_2 *uni,
|
|||||||
unistr2_to_ascii(d->sharename, &uni->sharename, sizeof(d->sharename)-1);
|
unistr2_to_ascii(d->sharename, &uni->sharename, sizeof(d->sharename)-1);
|
||||||
unistr2_to_ascii(d->portname, &uni->portname, sizeof(d->portname)-1);
|
unistr2_to_ascii(d->portname, &uni->portname, sizeof(d->portname)-1);
|
||||||
unistr2_to_ascii(d->drivername, &uni->drivername, sizeof(d->drivername)-1);
|
unistr2_to_ascii(d->drivername, &uni->drivername, sizeof(d->drivername)-1);
|
||||||
|
unistr2_to_ascii(d->comment, &uni->comment, sizeof(d->comment)-1);
|
||||||
unistr2_to_ascii(d->location, &uni->location, sizeof(d->location)-1);
|
unistr2_to_ascii(d->location, &uni->location, sizeof(d->location)-1);
|
||||||
unistr2_to_ascii(d->sepfile, &uni->sepfile, sizeof(d->sepfile)-1);
|
unistr2_to_ascii(d->sepfile, &uni->sepfile, sizeof(d->sepfile)-1);
|
||||||
unistr2_to_ascii(d->printprocessor, &uni->printprocessor, sizeof(d->printprocessor)-1);
|
unistr2_to_ascii(d->printprocessor, &uni->printprocessor, sizeof(d->printprocessor)-1);
|
||||||
|
@ -54,7 +54,7 @@ typedef struct _Printer{
|
|||||||
POLICY_HND printer_hnd;
|
POLICY_HND printer_hnd;
|
||||||
BOOL printer_type;
|
BOOL printer_type;
|
||||||
union {
|
union {
|
||||||
fstring printername;
|
fstring handlename;
|
||||||
fstring printerservername;
|
fstring printerservername;
|
||||||
} dev;
|
} dev;
|
||||||
uint32 type;
|
uint32 type;
|
||||||
@ -216,8 +216,8 @@ static BOOL delete_printer_handle(POLICY_HND *hnd)
|
|||||||
return False;
|
return False;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (del_a_printer(Printer->dev.printername) != 0) {
|
if (del_a_printer(Printer->dev.handlename) != 0) {
|
||||||
DEBUG(3,("Error deleting printer %s\n", Printer->dev.printername));
|
DEBUG(3,("Error deleting printer %s\n", Printer->dev.handlename));
|
||||||
return False;
|
return False;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -227,7 +227,7 @@ static BOOL delete_printer_handle(POLICY_HND *hnd)
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
return the snum of a printer corresponding to an handle
|
return the snum of a printer corresponding to an handle
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
static BOOL get_printer_snum(const POLICY_HND *hnd, int *number)
|
static BOOL get_printer_snum(POLICY_HND *hnd, int *number)
|
||||||
{
|
{
|
||||||
Printer_entry *Printer = find_printer_index_by_hnd(hnd);
|
Printer_entry *Printer = find_printer_index_by_hnd(hnd);
|
||||||
|
|
||||||
@ -238,8 +238,8 @@ static BOOL get_printer_snum(const POLICY_HND *hnd, int *number)
|
|||||||
|
|
||||||
switch (Printer->printer_type) {
|
switch (Printer->printer_type) {
|
||||||
case PRINTER_HANDLE_IS_PRINTER:
|
case PRINTER_HANDLE_IS_PRINTER:
|
||||||
DEBUG(4,("short name:%s\n", Printer->dev.printername));
|
DEBUG(4,("short name:%s\n", Printer->dev.handlename));
|
||||||
*number = print_queue_snum(Printer->dev.printername);
|
*number = print_queue_snum(Printer->dev.handlename);
|
||||||
return (*number != -1);
|
return (*number != -1);
|
||||||
case PRINTER_HANDLE_IS_PRINTSERVER:
|
case PRINTER_HANDLE_IS_PRINTSERVER:
|
||||||
return False;
|
return False;
|
||||||
@ -250,28 +250,6 @@ static BOOL get_printer_snum(const POLICY_HND *hnd, int *number)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
find first available printer slot. creates a printer handle for you.
|
|
||||||
****************************************************************************/
|
|
||||||
static BOOL open_printer_hnd(POLICY_HND *hnd)
|
|
||||||
{
|
|
||||||
Printer_entry *new_printer;
|
|
||||||
|
|
||||||
if((new_printer=(Printer_entry *)malloc(sizeof(Printer_entry))) == NULL)
|
|
||||||
return False;
|
|
||||||
|
|
||||||
ZERO_STRUCTP(new_printer);
|
|
||||||
|
|
||||||
new_printer->open = True;
|
|
||||||
new_printer->notify.option=NULL;
|
|
||||||
|
|
||||||
memcpy(&new_printer->printer_hnd, hnd, sizeof(*hnd));
|
|
||||||
|
|
||||||
ubi_dlAddHead( &Printer_list, (ubi_dlNode *)new_printer);
|
|
||||||
|
|
||||||
return True;
|
|
||||||
}
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
set printer handle type.
|
set printer handle type.
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@ -290,27 +268,21 @@ static BOOL set_printer_hnd_accesstype(POLICY_HND *hnd, uint32 access_required)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
set printer handle type.
|
Set printer handle type.
|
||||||
check if it's \\server or \\server\printer
|
Check if it's \\server or \\server\printer
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
static BOOL set_printer_hnd_printertype(POLICY_HND *hnd, char *printername)
|
|
||||||
{
|
|
||||||
Printer_entry *Printer = find_printer_index_by_hnd(hnd);
|
|
||||||
|
|
||||||
if (!OPEN_HANDLE(Printer)) {
|
|
||||||
DEBUG(0,("set_printer_hnd_printertype: Invalid handle (%s)", OUR_HANDLE(hnd)));
|
|
||||||
return False;
|
|
||||||
}
|
|
||||||
|
|
||||||
DEBUG(3,("Setting printer type=%s\n", printername));
|
|
||||||
|
|
||||||
if ( strlen(printername) < 3 ) {
|
static BOOL set_printer_hnd_printertype(Printer_entry *Printer, char *handlename)
|
||||||
DEBUGADD(4,("A print server must have at least 1 char ! %s\n", printername));
|
{
|
||||||
|
DEBUG(3,("Setting printer type=%s\n", handlename));
|
||||||
|
|
||||||
|
if ( strlen(handlename) < 3 ) {
|
||||||
|
DEBUGADD(4,("A print server must have at least 1 char ! %s\n", handlename));
|
||||||
return False;
|
return False;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* it's a print server */
|
/* it's a print server */
|
||||||
if (!strchr(printername+2, '\\')) {
|
if (!strchr(handlename+2, '\\')) {
|
||||||
DEBUGADD(4,("Printer is a print server\n"));
|
DEBUGADD(4,("Printer is a print server\n"));
|
||||||
Printer->printer_type = PRINTER_HANDLE_IS_PRINTSERVER;
|
Printer->printer_type = PRINTER_HANDLE_IS_PRINTSERVER;
|
||||||
return True;
|
return True;
|
||||||
@ -326,34 +298,29 @@ static BOOL set_printer_hnd_printertype(POLICY_HND *hnd, char *printername)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
set printer handle printername.
|
Set printer handle name.
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
static BOOL set_printer_hnd_printername(POLICY_HND *hnd, char *printername)
|
|
||||||
|
static BOOL set_printer_hnd_name(Printer_entry *Printer, char *handlename)
|
||||||
{
|
{
|
||||||
Printer_entry *Printer = find_printer_index_by_hnd(hnd);
|
|
||||||
NT_PRINTER_INFO_LEVEL *printer = NULL;
|
NT_PRINTER_INFO_LEVEL *printer = NULL;
|
||||||
int snum;
|
int snum;
|
||||||
int n_services=lp_numservices();
|
int n_services=lp_numservices();
|
||||||
char *aprinter;
|
char *aprinter;
|
||||||
BOOL found=False;
|
BOOL found=False;
|
||||||
|
|
||||||
if (!OPEN_HANDLE(Printer)) {
|
DEBUG(4,("Setting printer name=%s (len=%d)\n", handlename, strlen(handlename)));
|
||||||
DEBUG(0,("set_printer_hnd_printername: Invalid handle (%s)\n", OUR_HANDLE(hnd)));
|
|
||||||
return False;
|
|
||||||
}
|
|
||||||
|
|
||||||
DEBUG(4,("Setting printer name=%s (len=%d)\n", printername, strlen(printername)));
|
|
||||||
|
|
||||||
if (Printer->printer_type==PRINTER_HANDLE_IS_PRINTSERVER) {
|
if (Printer->printer_type==PRINTER_HANDLE_IS_PRINTSERVER) {
|
||||||
ZERO_STRUCT(Printer->dev.printerservername);
|
ZERO_STRUCT(Printer->dev.printerservername);
|
||||||
strncpy(Printer->dev.printerservername, printername, strlen(printername));
|
strncpy(Printer->dev.printerservername, handlename, strlen(handlename));
|
||||||
return True;
|
return True;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Printer->printer_type!=PRINTER_HANDLE_IS_PRINTER)
|
if (Printer->printer_type!=PRINTER_HANDLE_IS_PRINTER)
|
||||||
return False;
|
return False;
|
||||||
|
|
||||||
aprinter=strchr(printername+2, '\\');
|
aprinter=strchr(handlename+2, '\\');
|
||||||
aprinter++;
|
aprinter++;
|
||||||
|
|
||||||
DEBUGADD(5,("searching for [%s] (len=%d)\n", aprinter, strlen(aprinter)));
|
DEBUGADD(5,("searching for [%s] (len=%d)\n", aprinter, strlen(aprinter)));
|
||||||
@ -376,7 +343,7 @@ static BOOL set_printer_hnd_printername(POLICY_HND *hnd, char *printername)
|
|||||||
if (get_a_printer(&printer, 2, lp_servicename(snum))!=0)
|
if (get_a_printer(&printer, 2, lp_servicename(snum))!=0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
DEBUG(10,("set_printer_hnd_printername: printername [%s], aprinter [%s]\n",
|
DEBUG(10,("set_printer_hnd_name: name [%s], aprinter [%s]\n",
|
||||||
printer->info_2->printername, aprinter ));
|
printer->info_2->printername, aprinter ));
|
||||||
|
|
||||||
if ( strlen(printer->info_2->printername) != strlen(aprinter) ) {
|
if ( strlen(printer->info_2->printername) != strlen(aprinter) ) {
|
||||||
@ -393,7 +360,7 @@ static BOOL set_printer_hnd_printername(POLICY_HND *hnd, char *printername)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* if we haven't found a printer with the given printername
|
* if we haven't found a printer with the given handlename
|
||||||
* then it can be a share name as you can open both \\server\printer and
|
* then it can be a share name as you can open both \\server\printer and
|
||||||
* \\server\share
|
* \\server\share
|
||||||
*/
|
*/
|
||||||
@ -411,12 +378,12 @@ static BOOL set_printer_hnd_printername(POLICY_HND *hnd, char *printername)
|
|||||||
if ( !(lp_snum_ok(snum) && lp_print_ok(snum) ) )
|
if ( !(lp_snum_ok(snum) && lp_print_ok(snum) ) )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
DEBUGADD(5,("set_printer_hnd_printername: share:%s\n",lp_servicename(snum)));
|
DEBUGADD(5,("set_printer_hnd_name: share:%s\n",lp_servicename(snum)));
|
||||||
|
|
||||||
if (get_a_printer(&printer, 2, lp_servicename(snum))!=0)
|
if (get_a_printer(&printer, 2, lp_servicename(snum))!=0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
DEBUG(10,("set_printer_hnd_printername: printername [%s], aprinter [%s]\n",
|
DEBUG(10,("set_printer_hnd_name: printername [%s], aprinter [%s]\n",
|
||||||
printer->info_2->printername, aprinter ));
|
printer->info_2->printername, aprinter ));
|
||||||
|
|
||||||
if ( strlen(lp_servicename(snum)) != strlen(aprinter) ) {
|
if ( strlen(lp_servicename(snum)) != strlen(aprinter) ) {
|
||||||
@ -439,17 +406,53 @@ static BOOL set_printer_hnd_printername(POLICY_HND *hnd, char *printername)
|
|||||||
}
|
}
|
||||||
|
|
||||||
snum--;
|
snum--;
|
||||||
DEBUGADD(4,("set_printer_hnd_printername: Printer found: %s -> %s[%x]\n",
|
DEBUGADD(4,("set_printer_hnd_name: Printer found: %s -> %s[%x]\n",
|
||||||
printer->info_2->printername, lp_servicename(snum),snum));
|
printer->info_2->printername, lp_servicename(snum),snum));
|
||||||
|
|
||||||
ZERO_STRUCT(Printer->dev.printername);
|
ZERO_STRUCT(Printer->dev.handlename);
|
||||||
strncpy(Printer->dev.printername, lp_servicename(snum), strlen(lp_servicename(snum)));
|
strncpy(Printer->dev.handlename, lp_servicename(snum), strlen(lp_servicename(snum)));
|
||||||
|
|
||||||
free_a_printer(&printer, 2);
|
free_a_printer(&printer, 2);
|
||||||
|
|
||||||
return True;
|
return True;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
find first available printer slot. creates a printer handle for you.
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
static BOOL open_printer_hnd(POLICY_HND *hnd, char *name)
|
||||||
|
{
|
||||||
|
Printer_entry *new_printer;
|
||||||
|
|
||||||
|
clear_handle(hnd);
|
||||||
|
create_printer_hnd(hnd);
|
||||||
|
|
||||||
|
if((new_printer=(Printer_entry *)malloc(sizeof(Printer_entry))) == NULL)
|
||||||
|
return False;
|
||||||
|
|
||||||
|
ZERO_STRUCTP(new_printer);
|
||||||
|
|
||||||
|
new_printer->open = True;
|
||||||
|
new_printer->notify.option=NULL;
|
||||||
|
|
||||||
|
memcpy(&new_printer->printer_hnd, hnd, sizeof(*hnd));
|
||||||
|
|
||||||
|
ubi_dlAddHead( &Printer_list, (ubi_dlNode *)new_printer);
|
||||||
|
|
||||||
|
if (!set_printer_hnd_printertype(new_printer, name)) {
|
||||||
|
close_printer_handle(hnd);
|
||||||
|
return False;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!set_printer_hnd_name(new_printer, name)) {
|
||||||
|
close_printer_handle(hnd);
|
||||||
|
return False;
|
||||||
|
}
|
||||||
|
|
||||||
|
return True;
|
||||||
|
}
|
||||||
|
|
||||||
/********************************************************************
|
/********************************************************************
|
||||||
Return True is the handle is a print server.
|
Return True is the handle is a print server.
|
||||||
********************************************************************/
|
********************************************************************/
|
||||||
@ -516,8 +519,6 @@ uint32 _spoolss_open_printer_ex( const UNISTR2 *printername,
|
|||||||
{
|
{
|
||||||
fstring name;
|
fstring name;
|
||||||
|
|
||||||
clear_handle(handle);
|
|
||||||
|
|
||||||
if (printername == NULL)
|
if (printername == NULL)
|
||||||
return ERROR_INVALID_PRINTER_NAME;
|
return ERROR_INVALID_PRINTER_NAME;
|
||||||
|
|
||||||
@ -527,20 +528,9 @@ uint32 _spoolss_open_printer_ex( const UNISTR2 *printername,
|
|||||||
|
|
||||||
DEBUGADD(3,("checking name: %s\n",name));
|
DEBUGADD(3,("checking name: %s\n",name));
|
||||||
|
|
||||||
create_printer_hnd(handle);
|
if (!open_printer_hnd(handle, name))
|
||||||
|
|
||||||
open_printer_hnd(handle);
|
|
||||||
|
|
||||||
if (!set_printer_hnd_printertype(handle, name)) {
|
|
||||||
close_printer_handle(handle);
|
|
||||||
return ERROR_INVALID_PRINTER_NAME;
|
return ERROR_INVALID_PRINTER_NAME;
|
||||||
}
|
|
||||||
|
|
||||||
if (!set_printer_hnd_printername(handle, name)) {
|
|
||||||
close_printer_handle(handle);
|
|
||||||
return ERROR_INVALID_PRINTER_NAME;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
if (printer_default->datatype_ptr != NULL)
|
if (printer_default->datatype_ptr != NULL)
|
||||||
{
|
{
|
||||||
@ -747,7 +737,7 @@ static BOOL getprinterdata_printer_server(fstring value, uint32 *type, uint8 **d
|
|||||||
/********************************************************************
|
/********************************************************************
|
||||||
GetPrinterData on a printer Handle.
|
GetPrinterData on a printer Handle.
|
||||||
********************************************************************/
|
********************************************************************/
|
||||||
static BOOL getprinterdata_printer(const POLICY_HND *handle,
|
static BOOL getprinterdata_printer(POLICY_HND *handle,
|
||||||
fstring value, uint32 *type,
|
fstring value, uint32 *type,
|
||||||
uint8 **data, uint32 *needed, uint32 in_size )
|
uint8 **data, uint32 *needed, uint32 in_size )
|
||||||
{
|
{
|
||||||
@ -803,7 +793,7 @@ static BOOL getprinterdata_printer(const POLICY_HND *handle,
|
|||||||
/********************************************************************
|
/********************************************************************
|
||||||
* spoolss_getprinterdata
|
* spoolss_getprinterdata
|
||||||
********************************************************************/
|
********************************************************************/
|
||||||
uint32 _spoolss_getprinterdata(const POLICY_HND *handle, UNISTR2 *valuename,
|
uint32 _spoolss_getprinterdata(POLICY_HND *handle, UNISTR2 *valuename,
|
||||||
uint32 in_size,
|
uint32 in_size,
|
||||||
uint32 *type,
|
uint32 *type,
|
||||||
uint32 *out_size,
|
uint32 *out_size,
|
||||||
@ -874,7 +864,7 @@ uint32 _spoolss_getprinterdata(const POLICY_HND *handle, UNISTR2 *valuename,
|
|||||||
* in fact ReplyOpenPrinter is the changenotify equivalent on the spoolss pipe
|
* in fact ReplyOpenPrinter is the changenotify equivalent on the spoolss pipe
|
||||||
* called from api_spoolss_rffpcnex
|
* called from api_spoolss_rffpcnex
|
||||||
********************************************************************/
|
********************************************************************/
|
||||||
uint32 _spoolss_rffpcnex(const POLICY_HND *handle, uint32 flags, uint32 options,
|
uint32 _spoolss_rffpcnex(POLICY_HND *handle, uint32 flags, uint32 options,
|
||||||
const UNISTR2 *localmachine, uint32 printerlocal,
|
const UNISTR2 *localmachine, uint32 printerlocal,
|
||||||
SPOOL_NOTIFY_OPTION *option)
|
SPOOL_NOTIFY_OPTION *option)
|
||||||
{
|
{
|
||||||
@ -1518,7 +1508,7 @@ static uint32 printserver_notify_info(const POLICY_HND *hnd, SPOOL_NOTIFY_INFO *
|
|||||||
* fill a notify_info struct with info asked
|
* fill a notify_info struct with info asked
|
||||||
*
|
*
|
||||||
********************************************************************/
|
********************************************************************/
|
||||||
static uint32 printer_notify_info(const POLICY_HND *hnd, SPOOL_NOTIFY_INFO *info)
|
static uint32 printer_notify_info(POLICY_HND *hnd, SPOOL_NOTIFY_INFO *info)
|
||||||
{
|
{
|
||||||
int snum;
|
int snum;
|
||||||
Printer_entry *Printer=find_printer_index_by_hnd(hnd);
|
Printer_entry *Printer=find_printer_index_by_hnd(hnd);
|
||||||
@ -1579,7 +1569,7 @@ static uint32 printer_notify_info(const POLICY_HND *hnd, SPOOL_NOTIFY_INFO *info
|
|||||||
/********************************************************************
|
/********************************************************************
|
||||||
* spoolss_rfnpcnex
|
* spoolss_rfnpcnex
|
||||||
********************************************************************/
|
********************************************************************/
|
||||||
uint32 _spoolss_rfnpcnex( const POLICY_HND *handle, uint32 change,
|
uint32 _spoolss_rfnpcnex( POLICY_HND *handle, uint32 change,
|
||||||
SPOOL_NOTIFY_OPTION *option, SPOOL_NOTIFY_INFO *info)
|
SPOOL_NOTIFY_OPTION *option, SPOOL_NOTIFY_INFO *info)
|
||||||
{
|
{
|
||||||
Printer_entry *Printer=find_printer_index_by_hnd(handle);
|
Printer_entry *Printer=find_printer_index_by_hnd(handle);
|
||||||
@ -1902,7 +1892,12 @@ static BOOL construct_printer_info_2(fstring servername, PRINTER_INFO_2 *printer
|
|||||||
init_unistr(&printer->portname, lp_servicename(snum)); /* port */
|
init_unistr(&printer->portname, lp_servicename(snum)); /* port */
|
||||||
#endif
|
#endif
|
||||||
init_unistr(&printer->drivername, ntprinter->info_2->drivername); /* drivername */
|
init_unistr(&printer->drivername, ntprinter->info_2->drivername); /* drivername */
|
||||||
init_unistr(&printer->comment, lp_comment(snum)); /* comment */
|
|
||||||
|
if (*ntprinter->info_2->comment == '\0')
|
||||||
|
init_unistr(&printer->comment, lp_comment(snum)); /* comment */
|
||||||
|
else
|
||||||
|
init_unistr(&printer->comment, ntprinter->info_2->comment); /* saved comment. */
|
||||||
|
|
||||||
init_unistr(&printer->location, ntprinter->info_2->location); /* location */
|
init_unistr(&printer->location, ntprinter->info_2->location); /* location */
|
||||||
init_unistr(&printer->sepfile, ntprinter->info_2->sepfile); /* separator file */
|
init_unistr(&printer->sepfile, ntprinter->info_2->sepfile); /* separator file */
|
||||||
init_unistr(&printer->printprocessor, ntprinter->info_2->printprocessor);/* print processor */
|
init_unistr(&printer->printprocessor, ntprinter->info_2->printprocessor);/* print processor */
|
||||||
@ -2774,7 +2769,7 @@ static uint32 getprinterdriver2_level3(fstring servername, fstring architecture,
|
|||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
uint32 _spoolss_getprinterdriver2(const POLICY_HND *handle, const UNISTR2 *uni_arch, uint32 level,
|
uint32 _spoolss_getprinterdriver2(POLICY_HND *handle, const UNISTR2 *uni_arch, uint32 level,
|
||||||
uint32 clientmajorversion, uint32 clientminorversion,
|
uint32 clientmajorversion, uint32 clientminorversion,
|
||||||
NEW_BUFFER *buffer, uint32 offered,
|
NEW_BUFFER *buffer, uint32 offered,
|
||||||
uint32 *needed, uint32 *servermajorversion, uint32 *serverminorversion)
|
uint32 *needed, uint32 *servermajorversion, uint32 *serverminorversion)
|
||||||
@ -2813,7 +2808,7 @@ uint32 _spoolss_getprinterdriver2(const POLICY_HND *handle, const UNISTR2 *uni_a
|
|||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
uint32 _spoolss_startpageprinter(const POLICY_HND *handle)
|
uint32 _spoolss_startpageprinter(POLICY_HND *handle)
|
||||||
{
|
{
|
||||||
Printer_entry *Printer = find_printer_index_by_hnd(handle);
|
Printer_entry *Printer = find_printer_index_by_hnd(handle);
|
||||||
|
|
||||||
@ -2828,7 +2823,7 @@ uint32 _spoolss_startpageprinter(const POLICY_HND *handle)
|
|||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
uint32 _spoolss_endpageprinter(const POLICY_HND *handle)
|
uint32 _spoolss_endpageprinter(POLICY_HND *handle)
|
||||||
{
|
{
|
||||||
Printer_entry *Printer = find_printer_index_by_hnd(handle);
|
Printer_entry *Printer = find_printer_index_by_hnd(handle);
|
||||||
|
|
||||||
@ -2848,7 +2843,7 @@ uint32 _spoolss_endpageprinter(const POLICY_HND *handle)
|
|||||||
* called from the spoolss dispatcher
|
* called from the spoolss dispatcher
|
||||||
*
|
*
|
||||||
********************************************************************/
|
********************************************************************/
|
||||||
uint32 _spoolss_startdocprinter(const POLICY_HND *handle, uint32 level,
|
uint32 _spoolss_startdocprinter(POLICY_HND *handle, uint32 level,
|
||||||
pipes_struct *p, DOC_INFO *docinfo,
|
pipes_struct *p, DOC_INFO *docinfo,
|
||||||
uint32 *jobid)
|
uint32 *jobid)
|
||||||
{
|
{
|
||||||
@ -2920,7 +2915,7 @@ uint32 _spoolss_startdocprinter(const POLICY_HND *handle, uint32 level,
|
|||||||
* called from the spoolss dispatcher
|
* called from the spoolss dispatcher
|
||||||
*
|
*
|
||||||
********************************************************************/
|
********************************************************************/
|
||||||
uint32 _spoolss_enddocprinter(const POLICY_HND *handle)
|
uint32 _spoolss_enddocprinter(POLICY_HND *handle)
|
||||||
{
|
{
|
||||||
Printer_entry *Printer=find_printer_index_by_hnd(handle);
|
Printer_entry *Printer=find_printer_index_by_hnd(handle);
|
||||||
|
|
||||||
@ -2938,9 +2933,9 @@ uint32 _spoolss_enddocprinter(const POLICY_HND *handle)
|
|||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
uint32 _spoolss_writeprinter( const POLICY_HND *handle,
|
uint32 _spoolss_writeprinter( POLICY_HND *handle,
|
||||||
uint32 buffer_size,
|
uint32 buffer_size,
|
||||||
const uint8 *buffer,
|
uint8 *buffer,
|
||||||
uint32 *buffer_written)
|
uint32 *buffer_written)
|
||||||
{
|
{
|
||||||
Printer_entry *Printer = find_printer_index_by_hnd(handle);
|
Printer_entry *Printer = find_printer_index_by_hnd(handle);
|
||||||
@ -2961,7 +2956,7 @@ uint32 _spoolss_writeprinter( const POLICY_HND *handle,
|
|||||||
* called from the spoolss dispatcher
|
* called from the spoolss dispatcher
|
||||||
*
|
*
|
||||||
********************************************************************/
|
********************************************************************/
|
||||||
static uint32 control_printer(const POLICY_HND *handle, uint32 command,
|
static uint32 control_printer(POLICY_HND *handle, uint32 command,
|
||||||
pipes_struct *p)
|
pipes_struct *p)
|
||||||
{
|
{
|
||||||
struct current_user user;
|
struct current_user user;
|
||||||
@ -3009,7 +3004,7 @@ static uint32 control_printer(const POLICY_HND *handle, uint32 command,
|
|||||||
* called by spoolss_api_setprinter
|
* called by spoolss_api_setprinter
|
||||||
* when updating a printer description
|
* when updating a printer description
|
||||||
********************************************************************/
|
********************************************************************/
|
||||||
static uint32 update_printer_sec(const POLICY_HND *handle, uint32 level,
|
static uint32 update_printer_sec(POLICY_HND *handle, uint32 level,
|
||||||
const SPOOL_PRINTER_INFO_LEVEL *info,
|
const SPOOL_PRINTER_INFO_LEVEL *info,
|
||||||
pipes_struct *p, SEC_DESC_BUF *secdesc_ctr)
|
pipes_struct *p, SEC_DESC_BUF *secdesc_ctr)
|
||||||
{
|
{
|
||||||
@ -3035,9 +3030,9 @@ static uint32 update_printer_sec(const POLICY_HND *handle, uint32 level,
|
|||||||
|
|
||||||
/* Get old security descriptor */
|
/* Get old security descriptor */
|
||||||
|
|
||||||
if (!nt_printing_getsec(Printer->dev.printername, &old_secdesc_ctr)) {
|
if (!nt_printing_getsec(Printer->dev.handlename, &old_secdesc_ctr)) {
|
||||||
DEBUG(3, ("could not get old security descriptor for "
|
DEBUG(3, ("could not get old security descriptor for "
|
||||||
"printer %s", Printer->dev.printername));
|
"printer %s", Printer->dev.handlename));
|
||||||
return ERROR_INVALID_FUNCTION;
|
return ERROR_INVALID_FUNCTION;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3055,19 +3050,42 @@ static uint32 update_printer_sec(const POLICY_HND *handle, uint32 level,
|
|||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
result = nt_printing_setsec(Printer->dev.printername, secdesc_ctr);
|
result = nt_printing_setsec(Printer->dev.handlename, secdesc_ctr);
|
||||||
|
|
||||||
done:
|
done:
|
||||||
free_sec_desc_buf(&old_secdesc_ctr);
|
free_sec_desc_buf(&old_secdesc_ctr);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/********************************************************************
|
||||||
|
Do Samba sanity checks on a printer info struct.
|
||||||
|
********************************************************************/
|
||||||
|
|
||||||
|
static BOOL check_printer_ok(NT_PRINTER_INFO_LEVEL_2 *info, int snum)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* Ensure that this printer is shared under the correct name
|
||||||
|
* as this is what Samba insists upon.
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (!(info->attributes & PRINTER_ATTRIBUTE_SHARED))
|
||||||
|
return False;
|
||||||
|
|
||||||
|
if (!(info->attributes & PRINTER_ATTRIBUTE_RAW_ONLY))
|
||||||
|
return False;
|
||||||
|
|
||||||
|
if (!strequal(info->sharename, lp_servicename(snum)))
|
||||||
|
return False;
|
||||||
|
|
||||||
|
return True;
|
||||||
|
}
|
||||||
|
|
||||||
/********************************************************************
|
/********************************************************************
|
||||||
* called by spoolss_api_setprinter
|
* called by spoolss_api_setprinter
|
||||||
* when updating a printer description
|
* when updating a printer description
|
||||||
********************************************************************/
|
********************************************************************/
|
||||||
|
|
||||||
static uint32 update_printer(const POLICY_HND *handle, uint32 level,
|
static uint32 update_printer(POLICY_HND *handle, uint32 level,
|
||||||
const SPOOL_PRINTER_INFO_LEVEL *info,
|
const SPOOL_PRINTER_INFO_LEVEL *info,
|
||||||
DEVICEMODE *devmode)
|
DEVICEMODE *devmode)
|
||||||
{
|
{
|
||||||
@ -3085,9 +3103,9 @@ static uint32 update_printer(const POLICY_HND *handle, uint32 level,
|
|||||||
/* Check calling user has permission to update printer description */
|
/* Check calling user has permission to update printer description */
|
||||||
|
|
||||||
#if 1 /* JFMTEST */
|
#if 1 /* JFMTEST */
|
||||||
if (!nt_printing_getsec(Printer->dev.printername, &sd)) {
|
if (!nt_printing_getsec(Printer->dev.handlename, &sd)) {
|
||||||
DEBUG(3, ("Could not get security descriptor for printer %s",
|
DEBUG(3, ("Could not get security descriptor for printer %s",
|
||||||
Printer->dev.printername));
|
Printer->dev.handlename));
|
||||||
result = ERROR_INVALID_FUNCTION;
|
result = ERROR_INVALID_FUNCTION;
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
@ -3152,7 +3170,16 @@ static uint32 update_printer(const POLICY_HND *handle, uint32 level,
|
|||||||
free_nt_devicemode(&printer->info_2->devmode);
|
free_nt_devicemode(&printer->info_2->devmode);
|
||||||
printer->info_2->devmode=NULL;
|
printer->info_2->devmode=NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Do sanity check on the requested changes for Samba.
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (!check_printer_ok(printer->info_2, snum)) {
|
||||||
|
result = ERROR_ACCESS_DENIED;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
|
||||||
if (add_a_printer(*printer, 2)!=0) {
|
if (add_a_printer(*printer, 2)!=0) {
|
||||||
/* I don't really know what to return here !!! */
|
/* I don't really know what to return here !!! */
|
||||||
result = ERROR_ACCESS_DENIED;
|
result = ERROR_ACCESS_DENIED;
|
||||||
@ -3168,7 +3195,7 @@ static uint32 update_printer(const POLICY_HND *handle, uint32 level,
|
|||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
uint32 _spoolss_setprinter(const POLICY_HND *handle, uint32 level,
|
uint32 _spoolss_setprinter(POLICY_HND *handle, uint32 level,
|
||||||
const SPOOL_PRINTER_INFO_LEVEL *info,
|
const SPOOL_PRINTER_INFO_LEVEL *info,
|
||||||
DEVMODE_CTR devmode_ctr,
|
DEVMODE_CTR devmode_ctr,
|
||||||
SEC_DESC_BUF *secdesc_ctr,
|
SEC_DESC_BUF *secdesc_ctr,
|
||||||
@ -3201,7 +3228,7 @@ uint32 _spoolss_setprinter(const POLICY_HND *handle, uint32 level,
|
|||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
uint32 _spoolss_fcpn(const POLICY_HND *handle)
|
uint32 _spoolss_fcpn(POLICY_HND *handle)
|
||||||
{
|
{
|
||||||
Printer_entry *Printer= find_printer_index_by_hnd(handle);
|
Printer_entry *Printer= find_printer_index_by_hnd(handle);
|
||||||
|
|
||||||
@ -3224,7 +3251,7 @@ uint32 _spoolss_fcpn(const POLICY_HND *handle)
|
|||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
uint32 _spoolss_addjob(const POLICY_HND *handle, uint32 level,
|
uint32 _spoolss_addjob(POLICY_HND *handle, uint32 level,
|
||||||
NEW_BUFFER *buffer, uint32 offered)
|
NEW_BUFFER *buffer, uint32 offered)
|
||||||
{
|
{
|
||||||
return NT_STATUS_NO_PROBLEMO;
|
return NT_STATUS_NO_PROBLEMO;
|
||||||
@ -3448,14 +3475,14 @@ uint32 _spoolss_enumjobs( POLICY_HND *handle, uint32 firstjob, uint32 numofjobs,
|
|||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
uint32 _spoolss_schedulejob( const POLICY_HND *handle, uint32 jobid)
|
uint32 _spoolss_schedulejob( POLICY_HND *handle, uint32 jobid)
|
||||||
{
|
{
|
||||||
return 0x0;
|
return 0x0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
uint32 _spoolss_setjob( const POLICY_HND *handle,
|
uint32 _spoolss_setjob( POLICY_HND *handle,
|
||||||
uint32 jobid,
|
uint32 jobid,
|
||||||
uint32 level,
|
uint32 level,
|
||||||
pipes_struct *p,
|
pipes_struct *p,
|
||||||
@ -3713,7 +3740,7 @@ static void fill_form_1(FORM_1 *form, nt_forms_struct *list, int position)
|
|||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
uint32 _new_spoolss_enumforms( const POLICY_HND *handle, uint32 level,
|
uint32 _new_spoolss_enumforms( POLICY_HND *handle, uint32 level,
|
||||||
NEW_BUFFER *buffer, uint32 offered,
|
NEW_BUFFER *buffer, uint32 offered,
|
||||||
uint32 *needed, uint32 *numofforms)
|
uint32 *needed, uint32 *numofforms)
|
||||||
{
|
{
|
||||||
@ -3991,8 +4018,6 @@ static uint32 spoolss_addprinterex_level_2( const UNISTR2 *uni_srv_name,
|
|||||||
|
|
||||||
ZERO_STRUCTP(printer);
|
ZERO_STRUCTP(printer);
|
||||||
|
|
||||||
clear_handle(handle);
|
|
||||||
|
|
||||||
/* convert from UNICODE to ASCII - this allocates the info_2 struct inside *printer.*/
|
/* convert from UNICODE to ASCII - this allocates the info_2 struct inside *printer.*/
|
||||||
convert_printer_info(info, printer, 2);
|
convert_printer_info(info, printer, 2);
|
||||||
|
|
||||||
@ -4006,19 +4031,8 @@ static uint32 spoolss_addprinterex_level_2( const UNISTR2 *uni_srv_name,
|
|||||||
return ERROR_ACCESS_DENIED;
|
return ERROR_ACCESS_DENIED;
|
||||||
}
|
}
|
||||||
|
|
||||||
create_printer_hnd(handle);
|
if (!open_printer_hnd(handle, name)) {
|
||||||
|
|
||||||
open_printer_hnd(handle);
|
|
||||||
|
|
||||||
if (!set_printer_hnd_printertype(handle, name)) {
|
|
||||||
free_a_printer(&printer,2);
|
free_a_printer(&printer,2);
|
||||||
close_printer_handle(handle);
|
|
||||||
return ERROR_ACCESS_DENIED;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!set_printer_hnd_printername(handle, name)) {
|
|
||||||
free_a_printer(&printer,2);
|
|
||||||
close_printer_handle(handle);
|
|
||||||
return ERROR_ACCESS_DENIED;
|
return ERROR_ACCESS_DENIED;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4200,7 +4214,7 @@ uint32 _spoolss_getprinterdriverdirectory(UNISTR2 *name, UNISTR2 *uni_environmen
|
|||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
uint32 _spoolss_enumprinterdata(const POLICY_HND *handle, uint32 idx,
|
uint32 _spoolss_enumprinterdata(POLICY_HND *handle, uint32 idx,
|
||||||
uint32 in_value_len, uint32 in_data_len,
|
uint32 in_value_len, uint32 in_data_len,
|
||||||
uint32 *out_max_value_len, uint16 **out_value, uint32 *out_value_len,
|
uint32 *out_max_value_len, uint16 **out_value, uint32 *out_value_len,
|
||||||
uint32 *out_type,
|
uint32 *out_type,
|
||||||
@ -4327,7 +4341,7 @@ uint32 _spoolss_enumprinterdata(const POLICY_HND *handle, uint32 idx,
|
|||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
uint32 _spoolss_setprinterdata( const POLICY_HND *handle,
|
uint32 _spoolss_setprinterdata( POLICY_HND *handle,
|
||||||
const UNISTR2 *value,
|
const UNISTR2 *value,
|
||||||
uint32 type,
|
uint32 type,
|
||||||
uint32 max_len,
|
uint32 max_len,
|
||||||
@ -4371,7 +4385,7 @@ uint32 _spoolss_setprinterdata( const POLICY_HND *handle,
|
|||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
uint32 _spoolss_addform( const POLICY_HND *handle,
|
uint32 _spoolss_addform( POLICY_HND *handle,
|
||||||
uint32 level,
|
uint32 level,
|
||||||
const FORM *form)
|
const FORM *form)
|
||||||
{
|
{
|
||||||
@ -4398,7 +4412,7 @@ uint32 _spoolss_addform( const POLICY_HND *handle,
|
|||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
uint32 _spoolss_setform( const POLICY_HND *handle,
|
uint32 _spoolss_setform( POLICY_HND *handle,
|
||||||
const UNISTR2 *uni_name,
|
const UNISTR2 *uni_name,
|
||||||
uint32 level,
|
uint32 level,
|
||||||
const FORM *form)
|
const FORM *form)
|
||||||
|
Reference in New Issue
Block a user