Show
Ignore:
Timestamp:
07/11/08 01:13:42 (5 months ago)
Author:
psmedley
Message:

Update branch to 3.0.31 release

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • branches/samba-3.0/source/rpc_server/srv_spoolss_nt.c

    r134 r140  
    7474}; 
    7575 
     76/******************************************************************** 
     77 * Canonicalize servername. 
     78 ********************************************************************/ 
     79 
     80static const char *canon_servername(const char *servername) 
     81{ 
     82        const char *pservername = servername; 
     83        while (*pservername == '\\') { 
     84                pservername++; 
     85        } 
     86        return pservername; 
     87} 
    7688 
    7789/* translate between internal status numbers and NT status numbers */ 
     
    445457        aprinter = handlename; 
    446458        if ( *handlename == '\\' ) { 
    447                 servername = handlename + 2; 
    448                 if ( (aprinter = strchr_m( handlename+2, '\\' )) != NULL ) { 
     459                servername = canon_servername(handlename); 
     460                if ( (aprinter = strchr_m( servername, '\\' )) != NULL ) { 
    449461                        *aprinter = '\0'; 
    450462                        aprinter++; 
    451463                } 
    452         } 
    453         else { 
     464        } else { 
    454465                servername = ""; 
    455466        } 
     
    46404651 ********************************************************************/ 
    46414652 
    4642 static WERROR enumprinters_level2( uint32 flags, fstring servername, 
     4653static WERROR enumprinters_level2( uint32 flags, const char *servername, 
    46434654                                 RPC_BUFFER *buffer, uint32 offered, 
    46444655                                 uint32 *needed, uint32 *returned) 
    46454656{ 
    4646         char *s = servername; 
    4647  
    46484657        if (flags & PRINTER_ENUM_LOCAL) { 
    46494658                        return enum_all_printers_info_2(buffer, offered, needed, returned); 
     
    46514660 
    46524661        if (flags & PRINTER_ENUM_NAME) { 
    4653                 if ((servername[0] == '\\') && (servername[1] == '\\')) 
    4654                         s = servername + 2; 
    4655                 if (is_myname_or_ipaddr(s)) 
     4662                if (is_myname_or_ipaddr(canon_servername(servername))) 
    46564663                        return enum_all_printers_info_2(buffer, offered, needed, returned); 
    46574664                else 
     
    46694676 ********************************************************************/ 
    46704677 
    4671 static WERROR enumprinters_level5( uint32 flags, fstring servername, 
     4678static WERROR enumprinters_level5( uint32 flags, const char *servername, 
    46724679                                 RPC_BUFFER *buffer, uint32 offered, 
    46734680                                 uint32 *needed, uint32 *returned) 
     
    50475054 ********************************************************************/ 
    50485055 
    5049 static void fill_printer_driver_info_1(DRIVER_INFO_1 *info, NT_PRINTER_DRIVER_INFO_LEVEL driver, fstring servername, fstring architecture) 
     5056static void fill_printer_driver_info_1(DRIVER_INFO_1 *info, NT_PRINTER_DRIVER_INFO_LEVEL driver, const char *servername, fstring architecture) 
    50505057{ 
    50515058        init_unistr( &info->name, driver.info_3->name); 
     
    50565063 ********************************************************************/ 
    50575064 
    5058 static WERROR construct_printer_driver_info_1(DRIVER_INFO_1 *info, int snum, fstring servername, fstring architecture, uint32 version) 
     5065static WERROR construct_printer_driver_info_1(DRIVER_INFO_1 *info, int snum, const char *servername, fstring architecture, uint32 version) 
    50595066{        
    50605067        NT_PRINTER_INFO_LEVEL *printer = NULL; 
     
    50835090 ********************************************************************/ 
    50845091 
    5085 static void fill_printer_driver_info_2(DRIVER_INFO_2 *info, NT_PRINTER_DRIVER_INFO_LEVEL driver, fstring servername) 
     5092static void fill_printer_driver_info_2(DRIVER_INFO_2 *info, NT_PRINTER_DRIVER_INFO_LEVEL driver, const char *servername) 
    50865093{ 
    50875094        pstring temp; 
     5095        const char *cservername = canon_servername(servername); 
    50885096 
    50895097        info->version=driver.info_3->cversion; 
     
    50945102 
    50955103    if (strlen(driver.info_3->driverpath)) { 
    5096                 slprintf(temp, sizeof(temp)-1, "\\\\%s%s", servername, driver.info_3->driverpath); 
     5104                slprintf(temp, sizeof(temp)-1, "\\\\%s%s", cservername, driver.info_3->driverpath); 
    50975105                init_unistr( &info->driverpath, temp ); 
    50985106    } else 
     
    51005108 
    51015109        if (strlen(driver.info_3->datafile)) { 
    5102                 slprintf(temp, sizeof(temp)-1, "\\\\%s%s", servername, driver.info_3->datafile); 
     5110                slprintf(temp, sizeof(temp)-1, "\\\\%s%s", cservername, driver.info_3->datafile); 
    51035111                init_unistr( &info->datafile, temp ); 
    51045112        } else 
     
    51065114         
    51075115        if (strlen(driver.info_3->configfile)) { 
    5108                 slprintf(temp, sizeof(temp)-1, "\\\\%s%s", servername, driver.info_3->configfile); 
     5116                slprintf(temp, sizeof(temp)-1, "\\\\%s%s", cservername, driver.info_3->configfile); 
    51095117                init_unistr( &info->configfile, temp );  
    51105118        } else 
     
    51175125 ********************************************************************/ 
    51185126 
    5119 static WERROR construct_printer_driver_info_2(DRIVER_INFO_2 *info, int snum, fstring servername, fstring architecture, uint32 version) 
     5127static WERROR construct_printer_driver_info_2(DRIVER_INFO_2 *info, int snum, const char *servername, fstring architecture, uint32 version) 
    51205128{ 
    51215129        NT_PRINTER_INFO_LEVEL *printer = NULL; 
     
    51715179                    
    51725180                if ( servername ) 
    5173                         slprintf( line, sizeof(line)-1, "\\\\%s%s", servername, v ); 
     5181                        slprintf( line, sizeof(line)-1, "\\\\%s%s", canon_servername(servername), v ); 
    51745182                else 
    51755183                        pstrcpy( line, v ); 
     
    52105218 ********************************************************************/ 
    52115219 
    5212 static void fill_printer_driver_info_3(DRIVER_INFO_3 *info, NT_PRINTER_DRIVER_INFO_LEVEL driver, fstring servername) 
     5220static void fill_printer_driver_info_3(DRIVER_INFO_3 *info, NT_PRINTER_DRIVER_INFO_LEVEL driver, const char *servername) 
    52135221{ 
    52145222        pstring temp; 
     5223        const char *cservername = canon_servername(servername); 
    52155224 
    52165225        ZERO_STRUCTP(info); 
     
    52225231 
    52235232        if (strlen(driver.info_3->driverpath)) { 
    5224                 slprintf(temp, sizeof(temp)-1, "\\\\%s%s", servername, driver.info_3->driverpath);               
     5233                slprintf(temp, sizeof(temp)-1, "\\\\%s%s", cservername, driver.info_3->driverpath);              
    52255234                init_unistr( &info->driverpath, temp ); 
    52265235        } else 
     
    52285237     
    52295238        if (strlen(driver.info_3->datafile)) { 
    5230                 slprintf(temp, sizeof(temp)-1, "\\\\%s%s", servername, driver.info_3->datafile); 
     5239                slprintf(temp, sizeof(temp)-1, "\\\\%s%s", cservername, driver.info_3->datafile); 
    52315240                init_unistr( &info->datafile, temp ); 
    52325241        } else 
     
    52345243 
    52355244        if (strlen(driver.info_3->configfile)) { 
    5236                 slprintf(temp, sizeof(temp)-1, "\\\\%s%s", servername, driver.info_3->configfile); 
     5245                slprintf(temp, sizeof(temp)-1, "\\\\%s%s", cservername, driver.info_3->configfile); 
    52375246                init_unistr( &info->configfile, temp );  
    52385247        } else 
     
    52405249 
    52415250        if (strlen(driver.info_3->helpfile)) { 
    5242                 slprintf(temp, sizeof(temp)-1, "\\\\%s%s", servername, driver.info_3->helpfile); 
     5251                slprintf(temp, sizeof(temp)-1, "\\\\%s%s", cservername, driver.info_3->helpfile); 
    52435252                init_unistr( &info->helpfile, temp ); 
    52445253        } else 
     
    52495258 
    52505259        info->dependentfiles=NULL; 
    5251         init_unistr_array(&info->dependentfiles, driver.info_3->dependentfiles, servername); 
     5260        init_unistr_array(&info->dependentfiles, driver.info_3->dependentfiles, cservername); 
    52525261} 
    52535262 
     
    52575266 ********************************************************************/ 
    52585267 
    5259 static WERROR construct_printer_driver_info_3(DRIVER_INFO_3 *info, int snum, fstring servername, fstring architecture, uint32 version) 
     5268static WERROR construct_printer_driver_info_3(DRIVER_INFO_3 *info, int snum, const char *servername, fstring architecture, uint32 version) 
    52605269{        
    52615270        NT_PRINTER_INFO_LEVEL *printer = NULL; 
     
    53165325 ********************************************************************/ 
    53175326 
    5318 static void fill_printer_driver_info_6(DRIVER_INFO_6 *info, NT_PRINTER_DRIVER_INFO_LEVEL driver, fstring servername) 
     5327static void fill_printer_driver_info_6(DRIVER_INFO_6 *info, NT_PRINTER_DRIVER_INFO_LEVEL driver, const char *servername) 
    53195328{ 
    53205329        pstring temp; 
    53215330        fstring nullstr; 
     5331        const char *cservername = canon_servername(servername); 
    53225332 
    53235333        ZERO_STRUCTP(info); 
     
    53305340 
    53315341        if (strlen(driver.info_3->driverpath)) { 
    5332                 slprintf(temp, sizeof(temp)-1, "\\\\%s%s", servername, driver.info_3->driverpath);               
     5342                slprintf(temp, sizeof(temp)-1, "\\\\%s%s", cservername, driver.info_3->driverpath);              
    53335343                init_unistr( &info->driverpath, temp ); 
    53345344        } else 
     
    53365346 
    53375347        if (strlen(driver.info_3->datafile)) { 
    5338                 slprintf(temp, sizeof(temp)-1, "\\\\%s%s", servername, driver.info_3->datafile); 
     5348                slprintf(temp, sizeof(temp)-1, "\\\\%s%s", cservername, driver.info_3->datafile); 
    53395349                init_unistr( &info->datafile, temp ); 
    53405350        } else 
     
    53425352 
    53435353        if (strlen(driver.info_3->configfile)) { 
    5344                 slprintf(temp, sizeof(temp)-1, "\\\\%s%s", servername, driver.info_3->configfile); 
     5354                slprintf(temp, sizeof(temp)-1, "\\\\%s%s", cservername, driver.info_3->configfile); 
    53455355                init_unistr( &info->configfile, temp );  
    53465356        } else 
     
    53485358 
    53495359        if (strlen(driver.info_3->helpfile)) { 
    5350                 slprintf(temp, sizeof(temp)-1, "\\\\%s%s", servername, driver.info_3->helpfile); 
     5360                slprintf(temp, sizeof(temp)-1, "\\\\%s%s", cservername, driver.info_3->helpfile); 
    53515361                init_unistr( &info->helpfile, temp ); 
    53525362        } else 
     
    53805390 
    53815391static WERROR construct_printer_driver_info_6(DRIVER_INFO_6 *info, int snum,  
    5382               fstring servername, fstring architecture, uint32 version) 
     5392              const char *servername, fstring architecture, uint32 version) 
    53835393{        
    53845394        NT_PRINTER_INFO_LEVEL           *printer = NULL; 
     
    54475457****************************************************************************/ 
    54485458 
    5449 static WERROR getprinterdriver2_level1(fstring servername, fstring architecture, uint32 version, int snum, RPC_BUFFER *buffer, uint32 offered, uint32 *needed) 
     5459static WERROR getprinterdriver2_level1(const char *servername, fstring architecture, uint32 version, int snum, RPC_BUFFER *buffer, uint32 offered, uint32 *needed) 
    54505460{ 
    54515461        DRIVER_INFO_1 *info=NULL; 
     
    54855495****************************************************************************/ 
    54865496 
    5487 static WERROR getprinterdriver2_level2(fstring servername, fstring architecture, uint32 version, int snum, RPC_BUFFER *buffer, uint32 offered, uint32 *needed) 
     5497static WERROR getprinterdriver2_level2(const char *servername, fstring architecture, uint32 version, int snum, RPC_BUFFER *buffer, uint32 offered, uint32 *needed) 
    54885498{ 
    54895499        DRIVER_INFO_2 *info=NULL; 
     
    55235533****************************************************************************/ 
    55245534 
    5525 static WERROR getprinterdriver2_level3(fstring servername, fstring architecture, uint32 version, int snum, RPC_BUFFER *buffer, uint32 offered, uint32 *needed) 
     5535static WERROR getprinterdriver2_level3(const char *servername, fstring architecture, uint32 version, int snum, RPC_BUFFER *buffer, uint32 offered, uint32 *needed) 
    55265536{ 
    55275537        DRIVER_INFO_3 info; 
     
    55595569****************************************************************************/ 
    55605570 
    5561 static WERROR getprinterdriver2_level6(fstring servername, fstring architecture, uint32 version, int snum, RPC_BUFFER *buffer, uint32 offered, uint32 *needed) 
     5571static WERROR getprinterdriver2_level6(const char *servername, fstring architecture, uint32 version, int snum, RPC_BUFFER *buffer, uint32 offered, uint32 *needed) 
    55625572{ 
    55635573        DRIVER_INFO_6 info; 
     
    67886798****************************************************************************/ 
    67896799 
    6790 static WERROR enumprinterdrivers_level1(fstring servername, fstring architecture, RPC_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) 
     6800static WERROR enumprinterdrivers_level1(const char *servername, fstring architecture, RPC_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) 
    67916801{ 
    67926802        int i; 
     
    68726882****************************************************************************/ 
    68736883 
    6874 static WERROR enumprinterdrivers_level2(fstring servername, fstring architecture, RPC_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) 
     6884static WERROR enumprinterdrivers_level2(const char *servername, fstring architecture, RPC_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) 
    68756885{ 
    68766886        int i; 
     
    69576967****************************************************************************/ 
    69586968 
    6959 static WERROR enumprinterdrivers_level3(fstring servername, fstring architecture, RPC_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) 
     6969static WERROR enumprinterdrivers_level3(const char *servername, fstring architecture, RPC_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) 
    69606970{ 
    69616971        int i; 
     
    70537063        uint32 *needed = &r_u->needed; 
    70547064        uint32 *returned = &r_u->returned; 
    7055  
     7065        const char *cservername; 
    70567066        fstring servername; 
    70577067        fstring architecture; 
     
    70747084        unistr2_to_ascii(servername, &q_u->name, sizeof(servername)-1); 
    70757085 
    7076         if ( !is_myname_or_ipaddr( servername ) ) 
     7086        cservername = canon_servername(servername); 
     7087 
     7088        if (!is_myname_or_ipaddr(cservername)) 
    70777089                return WERR_UNKNOWN_PRINTER_DRIVER; 
    70787090 
    70797091        switch (level) { 
    70807092        case 1: 
    7081                 return enumprinterdrivers_level1(servername, architecture, buffer, offered, needed, returned); 
     7093                return enumprinterdrivers_level1(cservername, architecture, buffer, offered, needed, returned); 
    70827094        case 2: 
    7083                 return enumprinterdrivers_level2(servername, architecture, buffer, offered, needed, returned); 
     7095                return enumprinterdrivers_level2(cservername, architecture, buffer, offered, needed, returned); 
    70847096        case 3: 
    7085                 return enumprinterdrivers_level3(servername, architecture, buffer, offered, needed, returned); 
     7097                return enumprinterdrivers_level3(cservername, architecture, buffer, offered, needed, returned); 
    70867098        default: 
    70877099                return WERR_UNKNOWN_LEVEL; 
     
    78537865        pstring long_archi; 
    78547866        fstring servername; 
    7855         char *pservername;  
     7867        const char *pservername;  
    78567868        const char *short_archi; 
    78577869        DRIVER_DIRECTORY_1 *info=NULL; 
     
    78617873        unistr2_to_ascii(long_archi, uni_environment, sizeof(long_archi)-1); 
    78627874 
    7863         /* check for beginning double '\'s and that the server 
    7864            long enough */ 
    7865  
    7866         pservername = servername; 
    7867         if ( *pservername == '\\' && strlen(servername)>2 ) { 
    7868                 pservername += 2; 
    7869         }  
     7875        pservername = canon_servername(servername); 
    78707876         
    78717877        if ( !is_myname_or_ipaddr( pservername ) )