The branch, v3-2-stable has been updated via 1ad74f1906fa4e78c95ea3f7ac9de7a34539f83d (commit) via f82da34e92790ea90adac7f488083da5e4b4238c (commit) from b493a13c16b7f1c3211f3bb277759683c3f9363d (commit)
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v3-2-stable - Log ----------------------------------------------------------------- commit 1ad74f1906fa4e78c95ea3f7ac9de7a34539f83d Author: Jeremy Allison <[EMAIL PROTECTED]> Date: Fri Apr 4 11:14:09 2008 -0700 Fix bug #5372. With a large CUPS installation with a remote server, contacting the server when searching for a name for the location and comment fields can take so much time the client times out. When searching for a name we don't use these fields anyway, so add a function get_a_printer_search() which doesn't contact the CUPS server. Jeremy. (cherry picked from commit 92d9f20852d5384e92a93dd0b051034718840ca8) commit f82da34e92790ea90adac7f488083da5e4b4238c Author: Jeremy Allison <[EMAIL PROTECTED]> Date: Fri Apr 4 15:28:14 2008 -0700 When using plaintext ucs2 passwords clistr_push calls ucs2_align, which causes the space taken by the unicode password to be one byte too long (as we're on an odd byte boundary here). Reduce the count by 1 to cope with this. Fixes smbclient against NetApp servers which can't cope. Fix from [EMAIL PROTECTED] in bug #3840. Jeremy. (cherry picked from commit 1e7e7d86a1ae1cd2c3cc3de9f36b7326ad249b82) ----------------------------------------------------------------------- Summary of changes: source/libsmb/cliconnect.c | 12 ++++++-- source/printing/nt_printing.c | 49 +++++++++++++++++++++++++++-------- source/rpc_server/srv_spoolss_nt.c | 8 +++++- 3 files changed, 54 insertions(+), 15 deletions(-) Changeset truncated at 500 lines: diff --git a/source/libsmb/cliconnect.c b/source/libsmb/cliconnect.c index 30d6ace..3953a49 100644 --- a/source/libsmb/cliconnect.c +++ b/source/libsmb/cliconnect.c @@ -247,9 +247,16 @@ static NTSTATUS cli_session_setup_plaintext(struct cli_state *cli, p += clistr_push(cli, p, pass, -1, STR_TERMINATE); /* password */ SSVAL(cli->outbuf,smb_vwv7,PTR_DIFF(p, smb_buf(cli->outbuf))); } - else { + else { + /* For ucs2 passwords clistr_push calls ucs2_align, which causes + * the space taken by the unicode password to be one byte too + * long (as we're on an odd byte boundary here). Reduce the + * count by 1 to cope with this. Fixes smbclient against NetApp + * servers which can't cope. Fix from + * [EMAIL PROTECTED] in bug #3840. + */ p += clistr_push(cli, p, pass, -1, STR_UNICODE|STR_TERMINATE); /* unicode password */ - SSVAL(cli->outbuf,smb_vwv8,PTR_DIFF(p, smb_buf(cli->outbuf))); + SSVAL(cli->outbuf,smb_vwv8,PTR_DIFF(p, smb_buf(cli->outbuf))-1); } p += clistr_push(cli, p, user, -1, STR_TERMINATE); /* username */ @@ -1033,7 +1040,6 @@ NTSTATUS cli_session_setup(struct cli_state *cli, } return NT_STATUS_OK; - } /**************************************************************************** diff --git a/source/printing/nt_printing.c b/source/printing/nt_printing.c index 68b0359..7b03a32 100644 --- a/source/printing/nt_printing.c +++ b/source/printing/nt_printing.c @@ -3973,7 +3973,11 @@ static void map_to_os2_driver(fstring drivername) /**************************************************************************** Get a default printer info 2 struct. ****************************************************************************/ -static WERROR get_a_printer_2_default(NT_PRINTER_INFO_LEVEL_2 *info, const char *servername, const char* sharename) + +static WERROR get_a_printer_2_default(NT_PRINTER_INFO_LEVEL_2 *info, + const char *servername, + const char* sharename, + bool get_loc_com) { int snum = lp_servicenumber(sharename); @@ -4000,7 +4004,7 @@ static WERROR get_a_printer_2_default(NT_PRINTER_INFO_LEVEL_2 *info, const char fstrcpy(info->datatype, "RAW"); #ifdef HAVE_CUPS - if ( (enum printing_types)lp_printing(snum) == PRINT_CUPS ) { + if (get_loc_com && (enum printing_types)lp_printing(snum) == PRINT_CUPS ) { /* Pull the location and comment strings from cups if we don't already have one */ if ( !strlen(info->location) || !strlen(info->comment) ) @@ -4049,7 +4053,11 @@ fail: /**************************************************************************** ****************************************************************************/ -static WERROR get_a_printer_2(NT_PRINTER_INFO_LEVEL_2 *info, const char *servername, const char *sharename) + +static WERROR get_a_printer_2(NT_PRINTER_INFO_LEVEL_2 *info, + const char *servername, + const char *sharename, + bool get_loc_com) { int len = 0; int snum = lp_servicenumber(sharename); @@ -4062,7 +4070,8 @@ static WERROR get_a_printer_2(NT_PRINTER_INFO_LEVEL_2 *info, const char *servern dbuf = tdb_fetch(tdb_printers, kbuf); if (!dbuf.dptr) { - return get_a_printer_2_default(info, servername, sharename); + return get_a_printer_2_default(info, servername, + sharename, get_loc_com); } len += tdb_unpack(dbuf.dptr+len, dbuf.dsize-len, "dddddddddddfffffPfffff", @@ -4110,7 +4119,7 @@ static WERROR get_a_printer_2(NT_PRINTER_INFO_LEVEL_2 *info, const char *servern fstrcpy(info->printername, printername); #ifdef HAVE_CUPS - if ( (enum printing_types)lp_printing(snum) == PRINT_CUPS ) { + if (get_loc_com && (enum printing_types)lp_printing(snum) == PRINT_CUPS ) { /* Pull the location and comment strings from cups if we don't already have one */ if ( !strlen(info->location) || !strlen(info->comment) ) @@ -4694,8 +4703,8 @@ WERROR save_driver_init(NT_PRINTER_INFO_LEVEL *printer, uint32 level, uint8 *dat ****************************************************************************/ -WERROR get_a_printer( Printer_entry *print_hnd, NT_PRINTER_INFO_LEVEL **pp_printer, uint32 level, - const char *sharename) +static WERROR get_a_printer_internal( Printer_entry *print_hnd, NT_PRINTER_INFO_LEVEL **pp_printer, uint32 level, + const char *sharename, bool get_loc_com) { WERROR result; fstring servername; @@ -4723,11 +4732,11 @@ WERROR get_a_printer( Printer_entry *print_hnd, NT_PRINTER_INFO_LEVEL **pp_print sizeof(servername)-1 ); } - result = get_a_printer_2( (*pp_printer)->info_2, servername, sharename ); - - + result = get_a_printer_2( (*pp_printer)->info_2, + servername, sharename, get_loc_com); + /* we have a new printer now. Save it with this handle */ - + if ( !W_ERROR_IS_OK(result) ) { TALLOC_FREE( *pp_printer ); DEBUG(10,("get_a_printer: [%s] level %u returning %s\n", @@ -4747,6 +4756,24 @@ WERROR get_a_printer( Printer_entry *print_hnd, NT_PRINTER_INFO_LEVEL **pp_print return WERR_OK; } +WERROR get_a_printer( Printer_entry *print_hnd, + NT_PRINTER_INFO_LEVEL **pp_printer, + uint32 level, + const char *sharename) +{ + return get_a_printer_internal(print_hnd, pp_printer, level, + sharename, true); +} + +WERROR get_a_printer_search( Printer_entry *print_hnd, + NT_PRINTER_INFO_LEVEL **pp_printer, + uint32 level, + const char *sharename) +{ + return get_a_printer_internal(print_hnd, pp_printer, level, + sharename, false); +} + /**************************************************************************** Deletes a NT_PRINTER_INFO_LEVEL struct. ****************************************************************************/ diff --git a/source/rpc_server/srv_spoolss_nt.c b/source/rpc_server/srv_spoolss_nt.c index 403beb6..7788e76 100644 --- a/source/rpc_server/srv_spoolss_nt.c +++ b/source/rpc_server/srv_spoolss_nt.c @@ -521,7 +521,13 @@ static bool set_printer_hnd_name(Printer_entry *Printer, char *handlename) fstrcpy(sname, lp_servicename(snum)); printer = NULL; - result = get_a_printer( NULL, &printer, 2, sname ); + + /* This call doesn't fill in the location or comment from + * a CUPS server for efficiency with large numbers of printers. + * JRA. + */ + + result = get_a_printer_search( NULL, &printer, 2, sname ); if ( !W_ERROR_IS_OK(result) ) { DEBUG(0,("set_printer_hnd_name: failed to lookup printer [%s] -- result [%s]\n", sname, dos_errstr(result))); -- Samba Shared Repository