WERROR(*fn) (NT_USER_TOKEN *token, RPC_BUFFER *in, RPC_BUFFER *out, uint32 *needed);
};
+/********************************************************************
+ * Canonicalize servername.
+ ********************************************************************/
+
+static const char *canon_servername(const char *servername)
+{
+ const char *pservername = servername;
+ while (*pservername == '\\') {
+ pservername++;
+ }
+ return pservername;
+}
/* translate between internal status numbers and NT status numbers */
static int nt_printj_status(int v)
aprinter = handlename;
if ( *handlename == '\\' ) {
- servername = handlename + 2;
- if ( (aprinter = strchr_m( handlename+2, '\\' )) != NULL ) {
+ servername = canon_servername(handlename);
+ if ( (aprinter = strchr_m( servername, '\\' )) != NULL ) {
*aprinter = '\0';
aprinter++;
}
- }
- else {
+ } else {
servername = "";
}
* handle enumeration of printers at level 2
********************************************************************/
-static WERROR enumprinters_level2( uint32 flags, fstring servername,
+static WERROR enumprinters_level2( uint32 flags, const char *servername,
RPC_BUFFER *buffer, uint32 offered,
uint32 *needed, uint32 *returned)
{
- char *s = servername;
-
if (flags & PRINTER_ENUM_LOCAL) {
return enum_all_printers_info_2(buffer, offered, needed, returned);
}
if (flags & PRINTER_ENUM_NAME) {
- if ((servername[0] == '\\') && (servername[1] == '\\'))
- s = servername + 2;
- if (is_myname_or_ipaddr(s))
+ if (is_myname_or_ipaddr(canon_servername(servername)))
return enum_all_printers_info_2(buffer, offered, needed, returned);
else
return WERR_INVALID_NAME;
* handle enumeration of printers at level 5
********************************************************************/
-static WERROR enumprinters_level5( uint32 flags, fstring servername,
+static WERROR enumprinters_level5( uint32 flags, const char *servername,
RPC_BUFFER *buffer, uint32 offered,
uint32 *needed, uint32 *returned)
{
* fill a DRIVER_INFO_1 struct
********************************************************************/
-static void fill_printer_driver_info_1(DRIVER_INFO_1 *info, NT_PRINTER_DRIVER_INFO_LEVEL driver, fstring servername, fstring architecture)
+static void fill_printer_driver_info_1(DRIVER_INFO_1 *info, NT_PRINTER_DRIVER_INFO_LEVEL driver, const char *servername, fstring architecture)
{
init_unistr( &info->name, driver.info_3->name);
}
* construct_printer_driver_info_1
********************************************************************/
-static WERROR construct_printer_driver_info_1(DRIVER_INFO_1 *info, int snum, fstring servername, fstring architecture, uint32 version)
+static WERROR construct_printer_driver_info_1(DRIVER_INFO_1 *info, int snum, const char *servername, fstring architecture, uint32 version)
{
NT_PRINTER_INFO_LEVEL *printer = NULL;
NT_PRINTER_DRIVER_INFO_LEVEL driver;
* fill a printer_info_2 struct
********************************************************************/
-static void fill_printer_driver_info_2(DRIVER_INFO_2 *info, NT_PRINTER_DRIVER_INFO_LEVEL driver, fstring servername)
+static void fill_printer_driver_info_2(DRIVER_INFO_2 *info, NT_PRINTER_DRIVER_INFO_LEVEL driver, const char *servername)
{
TALLOC_CTX *ctx = talloc_tos();
char *temp = NULL;
+ const char *cservername = canon_servername(servername);
info->version=driver.info_3->cversion;
init_unistr( &info->name, driver.info_3->name );
init_unistr( &info->architecture, driver.info_3->environment );
-
if (strlen(driver.info_3->driverpath)) {
temp = talloc_asprintf(ctx,
"\\\\%s%s",
- servername,
+ cservername,
driver.info_3->driverpath);
init_unistr( &info->driverpath, temp );
} else {
if (strlen(driver.info_3->datafile)) {
temp = talloc_asprintf(ctx,
"\\\\%s%s",
- servername,
+ cservername,
driver.info_3->datafile);
init_unistr( &info->datafile, temp );
} else
if (strlen(driver.info_3->configfile)) {
temp = talloc_asprintf(ctx,
"\\\\%s%s",
- servername,
+ cservername,
driver.info_3->configfile);
init_unistr( &info->configfile, temp );
} else
* fill a printer_info_2 struct
********************************************************************/
-static WERROR construct_printer_driver_info_2(DRIVER_INFO_2 *info, int snum, fstring servername, fstring architecture, uint32 version)
+static WERROR construct_printer_driver_info_2(DRIVER_INFO_2 *info, int snum, const char *servername, fstring architecture, uint32 version)
{
NT_PRINTER_INFO_LEVEL *printer = NULL;
NT_PRINTER_DRIVER_INFO_LEVEL driver;
if ( servername ) {
line = talloc_asprintf(ctx,
"\\\\%s%s",
- servername,
+ canon_servername(servername),
v);
} else {
line = talloc_strdup(ctx, v);
* fill a printer_info_3 struct
********************************************************************/
-static void fill_printer_driver_info_3(DRIVER_INFO_3 *info, NT_PRINTER_DRIVER_INFO_LEVEL driver, fstring servername)
+static void fill_printer_driver_info_3(DRIVER_INFO_3 *info, NT_PRINTER_DRIVER_INFO_LEVEL driver, const char *servername)
{
char *temp = NULL;
TALLOC_CTX *ctx = talloc_tos();
+ const char *cservername = canon_servername(servername);
ZERO_STRUCTP(info);
if (strlen(driver.info_3->driverpath)) {
temp = talloc_asprintf(ctx,
"\\\\%s%s",
- servername,
+ cservername,
driver.info_3->driverpath);
init_unistr( &info->driverpath, temp );
} else
if (strlen(driver.info_3->datafile)) {
temp = talloc_asprintf(ctx,
"\\\\%s%s",
- servername,
+ cservername,
driver.info_3->datafile);
init_unistr( &info->datafile, temp );
} else
if (strlen(driver.info_3->configfile)) {
temp = talloc_asprintf(ctx,
"\\\\%s%s",
- servername,
+ cservername,
driver.info_3->configfile);
init_unistr( &info->configfile, temp );
} else
if (strlen(driver.info_3->helpfile)) {
temp = talloc_asprintf(ctx,
"\\\\%s%s",
- servername,
+ cservername,
driver.info_3->helpfile);
init_unistr( &info->helpfile, temp );
} else
init_unistr( &info->defaultdatatype, driver.info_3->defaultdatatype );
info->dependentfiles=NULL;
- init_unistr_array(&info->dependentfiles, driver.info_3->dependentfiles, servername);
+ init_unistr_array(&info->dependentfiles, driver.info_3->dependentfiles, cservername);
}
/********************************************************************
* fill a printer_info_3 struct
********************************************************************/
-static WERROR construct_printer_driver_info_3(DRIVER_INFO_3 *info, int snum, fstring servername, fstring architecture, uint32 version)
+static WERROR construct_printer_driver_info_3(DRIVER_INFO_3 *info, int snum, const char *servername, fstring architecture, uint32 version)
{
NT_PRINTER_INFO_LEVEL *printer = NULL;
NT_PRINTER_DRIVER_INFO_LEVEL driver;
* fill a printer_info_6 struct - we know that driver is really level 3. This sucks. JRA.
********************************************************************/
-static void fill_printer_driver_info_6(DRIVER_INFO_6 *info, NT_PRINTER_DRIVER_INFO_LEVEL driver, fstring servername)
+static void fill_printer_driver_info_6(DRIVER_INFO_6 *info, NT_PRINTER_DRIVER_INFO_LEVEL driver, const char *servername)
{
char *temp = NULL;
fstring nullstr;
TALLOC_CTX *ctx = talloc_tos();
+ const char *cservername = canon_servername(servername);
ZERO_STRUCTP(info);
memset(&nullstr, '\0', sizeof(fstring));
if (strlen(driver.info_3->driverpath)) {
temp = talloc_asprintf(ctx,
"\\\\%s%s",
- servername,
+ cservername,
driver.info_3->driverpath);
init_unistr( &info->driverpath, temp );
} else
if (strlen(driver.info_3->datafile)) {
temp = talloc_asprintf(ctx,
"\\\\%s%s",
- servername,
+ cservername,
driver.info_3->datafile);
init_unistr( &info->datafile, temp );
} else
if (strlen(driver.info_3->configfile)) {
temp = talloc_asprintf(ctx,
"\\\\%s%s",
- servername,
+ cservername,
driver.info_3->configfile);
init_unistr( &info->configfile, temp );
} else
if (strlen(driver.info_3->helpfile)) {
temp = talloc_asprintf(ctx,
"\\\\%s%s",
- servername,
+ cservername,
driver.info_3->helpfile);
init_unistr( &info->helpfile, temp );
} else
********************************************************************/
static WERROR construct_printer_driver_info_6(DRIVER_INFO_6 *info, int snum,
- fstring servername, fstring architecture, uint32 version)
+ const char *servername, fstring architecture, uint32 version)
{
NT_PRINTER_INFO_LEVEL *printer = NULL;
NT_PRINTER_DRIVER_INFO_LEVEL driver;
/****************************************************************************
****************************************************************************/
-static WERROR getprinterdriver2_level1(fstring servername, fstring architecture, uint32 version, int snum, RPC_BUFFER *buffer, uint32 offered, uint32 *needed)
+static WERROR getprinterdriver2_level1(const char *servername, fstring architecture, uint32 version, int snum, RPC_BUFFER *buffer, uint32 offered, uint32 *needed)
{
DRIVER_INFO_1 *info=NULL;
WERROR result;
/****************************************************************************
****************************************************************************/
-static WERROR getprinterdriver2_level2(fstring servername, fstring architecture, uint32 version, int snum, RPC_BUFFER *buffer, uint32 offered, uint32 *needed)
+static WERROR getprinterdriver2_level2(const char *servername, fstring architecture, uint32 version, int snum, RPC_BUFFER *buffer, uint32 offered, uint32 *needed)
{
DRIVER_INFO_2 *info=NULL;
WERROR result;
/****************************************************************************
****************************************************************************/
-static WERROR getprinterdriver2_level3(fstring servername, fstring architecture, uint32 version, int snum, RPC_BUFFER *buffer, uint32 offered, uint32 *needed)
+static WERROR getprinterdriver2_level3(const char *servername, fstring architecture, uint32 version, int snum, RPC_BUFFER *buffer, uint32 offered, uint32 *needed)
{
DRIVER_INFO_3 info;
WERROR result;
/****************************************************************************
****************************************************************************/
-static WERROR getprinterdriver2_level6(fstring servername, fstring architecture, uint32 version, int snum, RPC_BUFFER *buffer, uint32 offered, uint32 *needed)
+static WERROR getprinterdriver2_level6(const char *servername, fstring architecture, uint32 version, int snum, RPC_BUFFER *buffer, uint32 offered, uint32 *needed)
{
DRIVER_INFO_6 info;
WERROR result;
Enumerates all printer drivers at level 1.
****************************************************************************/
-static WERROR enumprinterdrivers_level1(fstring servername, fstring architecture, RPC_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned)
+static WERROR enumprinterdrivers_level1(const char *servername, fstring architecture, RPC_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned)
{
int i;
int ndrivers;
Enumerates all printer drivers at level 2.
****************************************************************************/
-static WERROR enumprinterdrivers_level2(fstring servername, fstring architecture, RPC_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned)
+static WERROR enumprinterdrivers_level2(const char *servername, fstring architecture, RPC_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned)
{
int i;
int ndrivers;
Enumerates all printer drivers at level 3.
****************************************************************************/
-static WERROR enumprinterdrivers_level3(fstring servername, fstring architecture, RPC_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned)
+static WERROR enumprinterdrivers_level3(const char *servername, fstring architecture, RPC_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned)
{
int i;
int ndrivers;
uint32 offered = q_u->offered;
uint32 *needed = &r_u->needed;
uint32 *returned = &r_u->returned;
-
+ const char *cservername;
fstring servername;
fstring architecture;
unistr2_to_ascii(architecture, &q_u->environment, sizeof(architecture));
unistr2_to_ascii(servername, &q_u->name, sizeof(servername));
- if ( !is_myname_or_ipaddr( servername ) )
+ cservername = canon_servername(servername);
+
+ if (!is_myname_or_ipaddr(cservername))
return WERR_UNKNOWN_PRINTER_DRIVER;
switch (level) {
case 1:
- return enumprinterdrivers_level1(servername, architecture, buffer, offered, needed, returned);
+ return enumprinterdrivers_level1(cservername, architecture, buffer, offered, needed, returned);
case 2:
- return enumprinterdrivers_level2(servername, architecture, buffer, offered, needed, returned);
+ return enumprinterdrivers_level2(cservername, architecture, buffer, offered, needed, returned);
case 3:
- return enumprinterdrivers_level3(servername, architecture, buffer, offered, needed, returned);
+ return enumprinterdrivers_level3(cservername, architecture, buffer, offered, needed, returned);
default:
return WERR_UNKNOWN_LEVEL;
}
char *path = NULL;
char *long_archi = NULL;
char *servername = NULL;
- char *pservername = NULL;
+ const char *pservername = NULL;
const char *short_archi;
DRIVER_DIRECTORY_1 *info=NULL;
WERROR result = WERR_OK;
return WERR_NOMEM;
}
- /* check for beginning double '\'s and that the server
- long enough */
-
- pservername = servername;
- if ( *pservername == '\\' && strlen(servername)>2 ) {
- pservername += 2;
- }
+ pservername = canon_servername(servername);
- if ( !is_myname_or_ipaddr( pservername ) )
+ if ( !is_myname_or_ipaddr(pservername))
return WERR_INVALID_PARAM;
if (!(short_archi = get_short_archi(long_archi)))