diff options
-rw-r--r-- | source3/printing/nt_printing.c | 14 | ||||
-rw-r--r-- | source3/rpc_server/srv_spoolss_nt.c | 44 |
2 files changed, 38 insertions, 20 deletions
diff --git a/source3/printing/nt_printing.c b/source3/printing/nt_printing.c index 72e4c47f28..7826212ae9 100644 --- a/source3/printing/nt_printing.c +++ b/source3/printing/nt_printing.c @@ -2485,8 +2485,11 @@ static WERROR get_a_printer_2_default(NT_PRINTER_INFO_LEVEL_2 **info_ptr, fstrin snum = lp_servicenumber(sharename); slprintf(info.servername, sizeof(info.servername)-1, "\\\\%s", get_called_name()); - slprintf(info.printername, sizeof(info.printername)-1, "\\\\%s\\%s", - get_called_name(), sharename); + strupper(info.servername); + slprintf(info.printername, sizeof(info.printername)-1, "\\\\%s\\", + get_called_name()); + strupper(info.printername); + fstrcat(info.printername, sharename); fstrcpy(info.sharename, sharename); fstrcpy(info.portname, SAMBA_PRINTER_PORT_NAME); fstrcpy(info.drivername, lp_printerdriver(snum)); @@ -2602,10 +2605,9 @@ static WERROR get_a_printer_2(NT_PRINTER_INFO_LEVEL_2 **info_ptr, fstring sharen info.attributes |= (PRINTER_ATTRIBUTE_SHARED | PRINTER_ATTRIBUTE_NETWORK); /* Restore the stripped strings. */ - slprintf(info.servername, sizeof(info.servername)-1, "\\\\%s", get_called_name()); - slprintf(printername, sizeof(printername)-1, "\\\\%s\\%s", get_called_name(), - info.printername); - fstrcpy(info.printername, printername); + slprintf(info.servername, sizeof(info.servername)-1, "\\\\%s", + get_called_name()); + strupper(info.servername); len += unpack_devicemode(&info.devmode,dbuf.dptr+len, dbuf.dsize-len); diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index f489802f77..f0ea088dc3 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -4,9 +4,10 @@ * RPC Pipe client / server routines * Copyright (C) Andrew Tridgell 1992-2000, * Copyright (C) Luke Kenneth Casson Leighton 1996-2000, - * Copyright (C) Jean François Micouleau 1998-2000. - * Copyright (C) Jeremy Allison 2001. - * Copyright (C) Gerald Carter 2000-2001. + * Copyright (C) Jean François Micouleau 1998-2000, + * Copyright (C) Jeremy Allison 2001, + * Copyright (C) Gerald Carter 2000-2001, + * Copyright (C) Tim Potter 2001-2002. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -2617,9 +2618,13 @@ static BOOL construct_printer_info_0(PRINTER_INFO_0 *printer, int snum) /******************************************************************** * construct_printer_info_1 * fill a printer_info_1 struct + * + * The is_enum parameter says whether the PRINTER_INFO_1 returned is + * to be used in an enumprinters call. This affects whether the netbios + * name of the server is prefixed to the printer and server names. ********************************************************************/ - -static BOOL construct_printer_info_1(uint32 flags, PRINTER_INFO_1 *printer, int snum) +static BOOL construct_printer_info_1(uint32 flags, PRINTER_INFO_1 *printer, + int snum, BOOL is_enum) { pstring chaine; pstring chaine2; @@ -2632,13 +2637,23 @@ static BOOL construct_printer_info_1(uint32 flags, PRINTER_INFO_1 *printer, int if (*ntprinter->info_2->comment == '\0') { init_unistr(&printer->comment, lp_comment(snum)); - slprintf(chaine,sizeof(chaine)-1,"%s%s,%s,%s",get_called_name(), ntprinter->info_2->printername, - ntprinter->info_2->drivername, lp_comment(snum)); - } - else { + if (is_enum) { + char *p; + + p = strchr(ntprinter->info_2->printername + 2, '\\'); + + if (p) + fstrcpy(ntprinter->info_2->printername, p + 1); + } + slprintf(chaine,sizeof(chaine)-1,"%s,%s,%s", + ntprinter->info_2->printername, + ntprinter->info_2->drivername, lp_comment(snum)); + } else { init_unistr(&printer->comment, ntprinter->info_2->comment); /* saved comment. */ - slprintf(chaine,sizeof(chaine)-1,"%s%s,%s,%s",get_called_name(), ntprinter->info_2->printername, - ntprinter->info_2->drivername, ntprinter->info_2->comment); + slprintf(chaine,sizeof(chaine)-1,"%s,%s,%s", + ntprinter->info_2->printername, + ntprinter->info_2->drivername, + ntprinter->info_2->comment); } slprintf(chaine2,sizeof(chaine)-1,"%s", ntprinter->info_2->printername); @@ -2926,8 +2941,8 @@ static WERROR enum_all_printers_info_1(uint32 flags, NEW_BUFFER *buffer, uint32 for (snum=0; snum<n_services; snum++) { if (lp_browseable(snum) && lp_snum_ok(snum) && lp_print_ok(snum) ) { DEBUG(4,("Found a printer in smb.conf: %s[%x]\n", lp_servicename(snum), snum)); - - if (construct_printer_info_1(flags, ¤t_prt, snum)) { + + if (construct_printer_info_1(flags, ¤t_prt, snum, True)) { if((tp=Realloc(printers, (*returned +1)*sizeof(PRINTER_INFO_1))) == NULL) { DEBUG(2,("enum_all_printers_info_1: failed to enlarge printers buffer!\n")); SAFE_FREE(printers); @@ -2936,6 +2951,7 @@ static WERROR enum_all_printers_info_1(uint32 flags, NEW_BUFFER *buffer, uint32 } else printers = tp; DEBUG(4,("ReAlloced memory for [%d] PRINTER_INFO_1\n", *returned)); + memcpy(&printers[*returned], ¤t_prt, sizeof(PRINTER_INFO_1)); (*returned)++; } @@ -3290,7 +3306,7 @@ static WERROR getprinter_level_1(int snum, NEW_BUFFER *buffer, uint32 offered, u if((printer=(PRINTER_INFO_1*)malloc(sizeof(PRINTER_INFO_1))) == NULL) return WERR_NOMEM; - construct_printer_info_1(PRINTER_ENUM_ICON8, printer, snum); + construct_printer_info_1(PRINTER_ENUM_ICON8, printer, snum, False); /* check the required size. */ *needed += spoolss_size_printer_info_1(printer); |