diff options
author | Andrew Tridgell <tridge@samba.org> | 2000-11-08 03:12:16 +0000 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 2000-11-08 03:12:16 +0000 |
commit | 3adc0e7a4ee71d255d2181a928d6e632664b7f4c (patch) | |
tree | bb125e8375b463161191df44b4f67be42e77efa0 /source3/rpc_server/srv_spoolss_nt.c | |
parent | 1d3747e7f296c062854fe66fffa60c4ff83a2200 (diff) | |
download | samba-3adc0e7a4ee71d255d2181a928d6e632664b7f4c.tar.gz samba-3adc0e7a4ee71d255d2181a928d6e632664b7f4c.tar.bz2 samba-3adc0e7a4ee71d255d2181a928d6e632664b7f4c.zip |
an attempt to get the handling of fields in printer info structures
consistent. Still working with Jeremy on this, there is probably more
to be done
(This used to be commit c4bb9c598cf9781d48bc123a8cbbed9c2049bf89)
Diffstat (limited to 'source3/rpc_server/srv_spoolss_nt.c')
-rw-r--r-- | source3/rpc_server/srv_spoolss_nt.c | 67 |
1 files changed, 24 insertions, 43 deletions
diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 67b29bdbcf..86c97b33ef 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -1103,12 +1103,19 @@ static void spoolss_notify_server_name(int snum, SPOOL_NOTIFY_INFO_DATA *data, p static void spoolss_notify_printer_name(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) { + /* the notify name should not contain the \\server\ part */ + char *p = strrchr(printer->info_2->printername, '\\'); + if (!p) { + p = printer->info_2->printername; + } else { + p++; + } /* data->notify_data.data.length=strlen(lp_servicename(snum)); dos_PutUniCode(data->notify_data.data.string, lp_servicename(snum), sizeof(data->notify_data.data.string), True); */ data->notify_data.data.length=(uint32)((dos_PutUniCode((char *)data->notify_data.data.string, - printer->info_2->printername, sizeof(data->notify_data.data.string), True) - sizeof(uint16))/sizeof(uint16)); + p, sizeof(data->notify_data.data.string), True) - sizeof(uint16))/sizeof(uint16)); } /******************************************************************* @@ -1871,8 +1878,7 @@ static BOOL construct_printer_info_0(PRINTER_INFO_0 *printer, int snum, fstring */ global_counter=session_counter->counter; - /* the description and the name are of the form \\server\share */ - slprintf(chaine,sizeof(chaine)-1,"\\\\%s\\%s",servername, ntprinter->info_2->printername); + pstrcpy(chaine,ntprinter->info_2->printername); init_unistr(&printer->printername, chaine); @@ -2013,7 +2019,7 @@ static DEVICEMODE *construct_dev_mode(int snum, char *servername) DEBUGADD(8,("loading DEVICEMODE\n")); - snprintf(adevice, sizeof(adevice), "\\\\%s\\%s", global_myname, printer->info_2->printername); + safe_strcpy(adevice, printer->info_2->printername, sizeof(adevice)); init_unistr(&devmode->devicename, adevice); snprintf(aform, sizeof(aform), ntdevmode->formname); @@ -3433,50 +3439,25 @@ static uint32 update_printer_sec(POLICY_HND *handle, uint32 level, /******************************************************************** Do Samba sanity checks on a printer info struct. + this has changed purpose: it now "canonicalises" printer + info from a client rather than just checking it is correct ********************************************************************/ 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|PRINTER_ATTRIBUTE_NETWORK))) { - DEBUG(10,("check_printer_ok: SHARED/NETWORK check failed (%x).\n", - (unsigned int)info->attributes )); - return False; - } - - if (!(info->attributes & PRINTER_ATTRIBUTE_RAW_ONLY)) { - /* NT forgets to set the raw attribute but sends the correct type. */ - if (strequal(info->datatype, "RAW")) - info->attributes |= PRINTER_ATTRIBUTE_RAW_ONLY; - else { - DEBUG(10,("check_printer_ok: RAW check failed (%x).\n", (unsigned int)info->attributes )); - return False; - } - } - - /* - * Sometimes the NT client doesn't set the sharename, but - * includes the sharename in the printername. This could - * cause SETPRINTER to fail which causes problems with the - * client getting confused between local/remote printers... - */ - - if (*info->sharename == '\0') { - char *p = strrchr(info->printername, '\\'); - if (p) - fstrcpy(info->sharename, p+1); - } - - if (!strequal(info->sharename, lp_servicename(snum))) { - DEBUG(10,("check_printer_ok: NAME check failed (%s) (%s).\n", - info->sharename, lp_servicename(snum))); - return False; - } + DEBUG(5,("check_printer_ok: servername=%s printername=%s sharename=%s portname=%s drivername=%s comment=%s location=%s\n", + info->servername, info->printername, info->sharename, info->portname, info->drivername, info->comment, info->location)); + /* we force some elements to "correct" values */ + slprintf(info->servername, sizeof(info->servername), "\\\\%s", global_myname); + slprintf(info->printername, sizeof(info->printername), "\\\\%s\\%s", + global_myname, lp_servicename(snum)); + fstrcpy(info->sharename, lp_servicename(snum)); + info->attributes = PRINTER_ATTRIBUTE_SHARED \ + | PRINTER_ATTRIBUTE_LOCAL \ + | PRINTER_ATTRIBUTE_RAW_ONLY \ + | PRINTER_ATTRIBUTE_QUEUED ; + return True; } |