diff options
author | Gerald Carter <jerry@samba.org> | 2005-11-22 15:52:22 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 11:05:31 -0500 |
commit | f2ecd4fed0ed11b73fa330588501a0ac37583174 (patch) | |
tree | 7e955817adb3f5910b12e3e2d15985e26c66ac9b /source3 | |
parent | 4826f9d41322649111be7495ede60a8939ad2995 (diff) | |
download | samba-f2ecd4fed0ed11b73fa330588501a0ac37583174.tar.gz samba-f2ecd4fed0ed11b73fa330588501a0ac37583174.tar.bz2 samba-f2ecd4fed0ed11b73fa330588501a0ac37583174.zip |
r11860: BUG 3156: don't use find_service() when explicitly looking for a printer as the username map might get in the way
(This used to be commit 46bf28c81c27dfdc412318a83bf565211a58a47d)
Diffstat (limited to 'source3')
-rw-r--r-- | source3/registry/reg_printing.c | 11 | ||||
-rw-r--r-- | source3/rpc_server/srv_spoolss_nt.c | 30 |
2 files changed, 26 insertions, 15 deletions
diff --git a/source3/registry/reg_printing.c b/source3/registry/reg_printing.c index b07c8e9644..592069052f 100644 --- a/source3/registry/reg_printing.c +++ b/source3/registry/reg_printing.c @@ -227,7 +227,16 @@ static int key_printers_fetch_keys( const char *key, REGSUBKEY_CTR *subkeys ) reg_split_path( printers_key, &printername, &printerdatakey ); - if ( find_service(printername) == -1 + /* validate the printer name */ + + for (snum=0; snum<n_services; snum++) { + if ( !lp_snum_ok(snum) || !lp_print_ok(snum) ) + continue; + if (strequal( lp_servicename(snum), printername ) ) + break; + } + + if ( snum>=n_services || !W_ERROR_IS_OK( get_a_printer(NULL, &printer, 2, printername) ) ) { return -1; diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index e5b3ca3947..f0ba863b4d 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -479,29 +479,30 @@ static BOOL set_printer_hnd_name(Printer_entry *Printer, char *handlename) DEBUGADD(5, ("searching for [%s]\n", aprinter )); /* Search all sharenames first as this is easier than pulling - the printer_info_2 off of disk */ + the printer_info_2 off of disk. Don't use find_service() since + that calls out to map_username() */ - snum = find_service(aprinter); - - if ( lp_snum_ok(snum) && lp_print_ok(snum) ) { - found = True; - fstrcpy( sname, aprinter ); - } - /* do another loop to look for printernames */ for (snum=0; !found && snum<n_services; snum++) { - /* no point in checking if this is not a printer or - we aren't allowing printername != sharename */ + /* no point going on if this is not a printer */ - if ( !(lp_snum_ok(snum) - && lp_print_ok(snum) - && !lp_force_printername(snum)) ) - { + if ( !(lp_snum_ok(snum) && lp_print_ok(snum)) ) continue; + + fstrcpy(sname, lp_servicename(snum)); + if ( strequal( aprinter, sname ) ) { + found = True; + break; } + + /* no point looking up the printer object if + we aren't allowing printername != sharename */ + if ( lp_force_printername(snum) ) + continue; + fstrcpy(sname, lp_servicename(snum)); printer = NULL; @@ -524,6 +525,7 @@ static BOOL set_printer_hnd_name(Printer_entry *Printer, char *handlename) if ( strequal(printername, aprinter) ) { found = True; + break; } DEBUGADD(10, ("printername: %s\n", printername)); |