summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2000-11-10 19:36:34 +0000
committerJeremy Allison <jra@samba.org>2000-11-10 19:36:34 +0000
commitc1900772ce6fdedc5c380d88f3640107d52e2096 (patch)
tree2751cd4bb9ffd370f8651f941c83b4a488e1787d /source3
parent3c330068adb081499285d20c8d299d7f70aaf603 (diff)
downloadsamba-c1900772ce6fdedc5c380d88f3640107d52e2096.tar.gz
samba-c1900772ce6fdedc5c380d88f3640107d52e2096.tar.bz2
samba-c1900772ce6fdedc5c380d88f3640107d52e2096.zip
printing/nt_printing.c: use getpwuid not smbgetpwuid. Canonicalize printernames.
printing/printing.c: Insure fix for malloc of zero. rpc_parse/parse_misc.c: Enusre UNISTR's are zero filled. rpc_parse/parse_spoolss.c: Correct INFO_6 - differs between pre-releases of W2K and shipping build. rpc_server/srv_spoolss_nt.c: Canonicalize printernames. Jeremy. (This used to be commit b17e23a8ff2b44540726968355a4b7e26f244f3b)
Diffstat (limited to 'source3')
-rw-r--r--source3/printing/nt_printing.c21
-rw-r--r--source3/printing/printing.c5
-rw-r--r--source3/rpc_parse/parse_misc.c2
-rw-r--r--source3/rpc_parse/parse_spoolss.c11
-rw-r--r--source3/rpc_server/srv_spoolss_nt.c150
5 files changed, 97 insertions, 92 deletions
diff --git a/source3/printing/nt_printing.c b/source3/printing/nt_printing.c
index 3712cfbb14..18652d8c92 100644
--- a/source3/printing/nt_printing.c
+++ b/source3/printing/nt_printing.c
@@ -640,7 +640,7 @@ BOOL move_driver_to_download_area(NT_PRINTER_DRIVER_INFO_LEVEL driver_abstract,
connection_struct *conn;
pstring inbuf;
pstring outbuf;
- struct smb_passwd *smb_pass;
+ struct passwd *pass;
int ecode;
int outsize = 0;
int i;
@@ -662,9 +662,9 @@ BOOL move_driver_to_download_area(NT_PRINTER_DRIVER_INFO_LEVEL driver_abstract,
get_short_archi(architecture, driver->environment);
become_root();
- smb_pass = getsmbpwuid(user->uid);
- if(smb_pass == NULL) {
- DEBUG(0,("move_driver_to_download_area: Unable to get smbpasswd entry for uid %u\n",
+ pass = getpwuid(user->uid);
+ if(pass == NULL) {
+ DEBUG(0,("move_driver_to_download_area: Unable to get passwd entry for uid %u\n",
(unsigned int)user->uid ));
unbecome_root();
return False;
@@ -672,7 +672,7 @@ BOOL move_driver_to_download_area(NT_PRINTER_DRIVER_INFO_LEVEL driver_abstract,
unbecome_root();
/* connect to the print$ share under the same account as the user connected to the rpc pipe */
- fstrcpy(user_name, smb_pass->smb_name );
+ fstrcpy(user_name, pass->pw_name );
DEBUG(10,("move_driver_to_download_area: uid %d -> user %s\n", (int)user->uid, user_name));
/* Null password is ok - we are already an authenticated user... */
@@ -1714,6 +1714,7 @@ static uint32 get_a_printer_2(NT_PRINTER_INFO_LEVEL_2 **info_ptr, fstring sharen
NT_PRINTER_INFO_LEVEL_2 info;
int len = 0;
TDB_DATA kbuf, dbuf;
+ fstring printername;
ZERO_STRUCT(info);
@@ -1753,6 +1754,12 @@ static uint32 get_a_printer_2(NT_PRINTER_INFO_LEVEL_2 **info_ptr, fstring sharen
/* Samba has to have shared raw drivers. */
info.attributes |= (PRINTER_ATTRIBUTE_SHARED|PRINTER_ATTRIBUTE_RAW_ONLY);
+ /* Restore the stripped strings. */
+ slprintf(info.servername, sizeof(info.servername), "\\\\%s", global_myname);
+ slprintf(printername, sizeof(printername), "\\\\%s\\%s", global_myname,
+ info.printername);
+ fstrcpy(info.printername, printername);
+
len += unpack_devicemode(&info.devmode,dbuf.dptr+len, dbuf.dsize-len);
len += unpack_specifics(&info.specific,dbuf.dptr+len, dbuf.dsize-len);
@@ -1761,8 +1768,8 @@ static uint32 get_a_printer_2(NT_PRINTER_INFO_LEVEL_2 **info_ptr, fstring sharen
safe_free(dbuf.dptr);
*info_ptr=memdup(&info, sizeof(info));
- DEBUG(9,("Unpacked printer [%s] running driver [%s]\n",
- sharename, info.drivername));
+ DEBUG(9,("Unpacked printer [%s] name [%s] running driver [%s]\n",
+ sharename, info.printername, info.drivername));
return 0;
diff --git a/source3/printing/printing.c b/source3/printing/printing.c
index 9fa4b9b8c6..77e32d5bf0 100644
--- a/source3/printing/printing.c
+++ b/source3/printing/printing.c
@@ -1003,6 +1003,8 @@ int print_queue_status(int snum,
/* make sure the database is up to date */
if (print_cache_expired(snum)) print_queue_update(snum);
+
+ *queue = NULL;
/*
* Count the number of entries.
@@ -1011,6 +1013,9 @@ int print_queue_status(int snum,
tsc.snum = snum;
tdb_traverse(tdb, traverse_count_fn_queue, (void *)&tsc);
+ if (tsc.count == 0)
+ return 0;
+
/* Allocate the queue size. */
if (( tstruct.queue = (print_queue_struct *)malloc(sizeof(print_queue_struct)*tsc.count))
== NULL)
diff --git a/source3/rpc_parse/parse_misc.c b/source3/rpc_parse/parse_misc.c
index 93f47bbc7a..859a800771 100644
--- a/source3/rpc_parse/parse_misc.c
+++ b/source3/rpc_parse/parse_misc.c
@@ -494,6 +494,8 @@ void init_unistr(UNISTR *str, const char *buf)
if (str->buffer == NULL)
smb_panic("init_unistr: malloc fail\n");
+ memset(str->buffer, '\0', len);
+
/* store the string (null-terminated copy) */
dos_struni2((char *)str->buffer, buf, len);
}
diff --git a/source3/rpc_parse/parse_spoolss.c b/source3/rpc_parse/parse_spoolss.c
index eaacb52f5b..d77cd938a8 100644
--- a/source3/rpc_parse/parse_spoolss.c
+++ b/source3/rpc_parse/parse_spoolss.c
@@ -4340,6 +4340,10 @@ BOOL spool_io_printer_driver_info_level_6(char *desc, SPOOL_PRINTER_DRIVER_INFO_
if(!prs_uint32("version", ps, depth, &il->version))
return False;
+#if 0
+ if(!prs_uint32("dummy4", ps, depth, &il->dummy4))
+ return False;
+#endif
if(!prs_uint32("name_ptr", ps, depth, &il->name_ptr))
return False;
if(!prs_uint32("environment_ptr", ps, depth, &il->environment_ptr))
@@ -4385,30 +4389,37 @@ BOOL spool_io_printer_driver_info_level_6(char *desc, SPOOL_PRINTER_DRIVER_INFO_
return False;
if(!prs_align(ps))
return False;
+
if(!smb_io_unistr2("environment", &il->environment, il->environment_ptr, ps, depth))
return False;
if(!prs_align(ps))
return False;
+
if(!smb_io_unistr2("driverpath", &il->driverpath, il->driverpath_ptr, ps, depth))
return False;
if(!prs_align(ps))
return False;
+
if(!smb_io_unistr2("datafile", &il->datafile, il->datafile_ptr, ps, depth))
return False;
if(!prs_align(ps))
return False;
+
if(!smb_io_unistr2("configfile", &il->configfile, il->configfile_ptr, ps, depth))
return False;
if(!prs_align(ps))
return False;
+
if(!smb_io_unistr2("helpfile", &il->helpfile, il->helpfile_ptr, ps, depth))
return False;
if(!prs_align(ps))
return False;
+
if(!smb_io_unistr2("monitorname", &il->monitorname, il->monitorname_ptr, ps, depth))
return False;
if(!prs_align(ps))
return False;
+
if(!smb_io_unistr2("defaultdatatype", &il->defaultdatatype, il->defaultdatatype_ptr, ps, depth))
return False;
if(!prs_align(ps))
diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c
index 86c97b33ef..42f9d29d9c 100644
--- a/source3/rpc_server/srv_spoolss_nt.c
+++ b/source3/rpc_server/srv_spoolss_nt.c
@@ -1588,6 +1588,10 @@ static BOOL construct_notify_printer_info(SPOOL_NOTIFY_INFO *info, int snum, SPO
current_data=&info->data[info->count];
construct_info_data(current_data, type, field, id);
+
+ DEBUG(10,("construct_notify_printer_info: calling %s\n",
+ notify_info_data_table[j].name ));
+
notify_info_data_table[j].fn(snum, current_data, queue, printer);
info->count++;
@@ -1827,9 +1831,9 @@ uint32 _spoolss_rfnpcnex( POLICY_HND *handle, uint32 change,
/********************************************************************
* construct_printer_info_0
- * fill a printer_info_1 struct
+ * fill a printer_info_0 struct
********************************************************************/
-static BOOL construct_printer_info_0(PRINTER_INFO_0 *printer, int snum, fstring servername)
+static BOOL construct_printer_info_0(PRINTER_INFO_0 *printer, int snum)
{
pstring chaine;
int count;
@@ -1882,7 +1886,7 @@ static BOOL construct_printer_info_0(PRINTER_INFO_0 *printer, int snum, fstring
init_unistr(&printer->printername, chaine);
- slprintf(chaine,sizeof(chaine)-1,"\\\\%s", servername);
+ slprintf(chaine,sizeof(chaine)-1,"\\\\%s", global_myname);
init_unistr(&printer->servername, chaine);
printer->cjobs = count;
@@ -1938,7 +1942,7 @@ static BOOL construct_printer_info_0(PRINTER_INFO_0 *printer, int snum, fstring
* construct_printer_info_1
* fill a printer_info_1 struct
********************************************************************/
-static BOOL construct_printer_info_1(fstring server, uint32 flags, PRINTER_INFO_1 *printer, int snum)
+static BOOL construct_printer_info_1(uint32 flags, PRINTER_INFO_1 *printer, int snum)
{
pstring chaine;
pstring chaine2;
@@ -1951,16 +1955,16 @@ static BOOL construct_printer_info_1(fstring server, uint32 flags, PRINTER_INFO_
if (*ntprinter->info_2->comment == '\0') {
init_unistr(&printer->comment, lp_comment(snum));
- snprintf(chaine,sizeof(chaine)-1,"%s%s,%s,%s",server, ntprinter->info_2->printername,
+ snprintf(chaine,sizeof(chaine)-1,"%s%s,%s,%s",global_myname, ntprinter->info_2->printername,
ntprinter->info_2->drivername, lp_comment(snum));
}
else {
init_unistr(&printer->comment, ntprinter->info_2->comment); /* saved comment. */
- snprintf(chaine,sizeof(chaine)-1,"%s%s,%s,%s",server, ntprinter->info_2->printername,
+ snprintf(chaine,sizeof(chaine)-1,"%s%s,%s,%s",global_myname, ntprinter->info_2->printername,
ntprinter->info_2->drivername, ntprinter->info_2->comment);
}
- snprintf(chaine2,sizeof(chaine)-1,"%s%s", server, ntprinter->info_2->printername);
+ snprintf(chaine2,sizeof(chaine)-1,"%s", ntprinter->info_2->printername);
init_unistr(&printer->description, chaine);
init_unistr(&printer->name, chaine2);
@@ -1989,7 +1993,7 @@ static void free_dev_mode(DEVICEMODE *dev)
Create a DEVMODE struct. Returns malloced memory.
****************************************************************************/
-static DEVICEMODE *construct_dev_mode(int snum, char *servername)
+static DEVICEMODE *construct_dev_mode(int snum)
{
char adevice[32];
char aform[32];
@@ -2075,11 +2079,8 @@ static DEVICEMODE *construct_dev_mode(int snum, char *servername)
* fill a printer_info_2 struct
********************************************************************/
-static BOOL construct_printer_info_2(fstring servername, PRINTER_INFO_2 *printer, int snum)
+static BOOL construct_printer_info_2(PRINTER_INFO_2 *printer, int snum)
{
- pstring chaine;
- pstring chaine2;
- pstring sl;
int count;
NT_PRINTER_INFO_LEVEL *ntprinter = NULL;
@@ -2093,21 +2094,8 @@ static BOOL construct_printer_info_2(fstring servername, PRINTER_INFO_2 *printer
memset(&status, 0, sizeof(status));
count = print_queue_status(snum, &queue, &status);
- snprintf(chaine, sizeof(chaine)-1, "%s", servername);
-
- if (strlen(servername)!=0)
- fstrcpy(sl, "\\");
- else
- fstrcpy(sl, '\0');
-
- if (!strchr(ntprinter->info_2->printername, '\\')) {
- snprintf(chaine2, sizeof(chaine)-1, "%s%s%s", servername, sl, ntprinter->info_2->printername);
- } else {
- pstrcpy(chaine2, ntprinter->info_2->printername);
- }
-
- init_unistr(&printer->servername, chaine); /* servername*/
- init_unistr(&printer->printername, chaine2); /* printername*/
+ init_unistr(&printer->servername, ntprinter->info_2->servername); /* servername*/
+ init_unistr(&printer->printername, ntprinter->info_2->printername); /* printername*/
init_unistr(&printer->sharename, lp_servicename(snum)); /* sharename */
init_unistr(&printer->portname, ntprinter->info_2->portname); /* port */
init_unistr(&printer->drivername, ntprinter->info_2->drivername); /* drivername */
@@ -2133,7 +2121,7 @@ static BOOL construct_printer_info_2(fstring servername, PRINTER_INFO_2 *printer
printer->cjobs = count; /* jobs */
printer->averageppm = ntprinter->info_2->averageppm; /* average pages per minute */
- if((printer->devmode = construct_dev_mode(snum, servername)) == NULL) {
+ if((printer->devmode = construct_dev_mode(snum)) == NULL) {
DEBUG(8, ("Returning NULL Devicemode!\n"));
}
@@ -2157,8 +2145,7 @@ static BOOL construct_printer_info_2(fstring servername, PRINTER_INFO_2 *printer
* construct_printer_info_3
* fill a printer_info_3 struct
********************************************************************/
-static BOOL construct_printer_info_3(fstring servername,
- PRINTER_INFO_3 **pp_printer, int snum)
+static BOOL construct_printer_info_3(PRINTER_INFO_3 **pp_printer, int snum)
{
NT_PRINTER_INFO_LEVEL *ntprinter = NULL;
PRINTER_INFO_3 *printer = NULL;
@@ -2211,7 +2198,7 @@ static BOOL construct_printer_info_3(fstring servername,
/********************************************************************
Spoolss_enumprinters.
********************************************************************/
-static BOOL enum_all_printers_info_1(fstring server, uint32 flags, NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned)
+static BOOL enum_all_printers_info_1(uint32 flags, NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned)
{
int snum;
int i;
@@ -2225,7 +2212,7 @@ static BOOL enum_all_printers_info_1(fstring server, uint32 flags, NEW_BUFFER *b
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(server, flags, &current_prt, snum)) {
+ if (construct_printer_info_1(flags, &current_prt, snum)) {
if((printers=Realloc(printers, (*returned +1)*sizeof(PRINTER_INFO_1))) == NULL) {
*returned=0;
return ERROR_NOT_ENOUGH_MEMORY;
@@ -2262,20 +2249,11 @@ static BOOL enum_all_printers_info_1(fstring server, uint32 flags, NEW_BUFFER *b
/********************************************************************
enum_all_printers_info_1_local.
*********************************************************************/
-static BOOL enum_all_printers_info_1_local(fstring name, NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned)
+static BOOL enum_all_printers_info_1_local(NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned)
{
- fstring temp;
DEBUG(4,("enum_all_printers_info_1_local\n"));
- fstrcpy(temp, "\\\\");
- fstrcat(temp, global_myname);
-
- if (!strcmp(name, temp)) {
- fstrcat(temp, "\\");
- return enum_all_printers_info_1(temp, PRINTER_ENUM_ICON8, buffer, offered, needed, returned);
- }
- else
- return enum_all_printers_info_1("", PRINTER_ENUM_ICON8, buffer, offered, needed, returned);
+ return enum_all_printers_info_1(PRINTER_ENUM_ICON8, buffer, offered, needed, returned);
}
/********************************************************************
@@ -2289,9 +2267,8 @@ static BOOL enum_all_printers_info_1_name(fstring name, NEW_BUFFER *buffer, uint
fstrcpy(temp, "\\\\");
fstrcat(temp, global_myname);
- if (!strcmp(name, temp)) {
- fstrcat(temp, "\\");
- return enum_all_printers_info_1(temp, PRINTER_ENUM_ICON8, buffer, offered, needed, returned);
+ if (strequal(name, temp)) {
+ return enum_all_printers_info_1(PRINTER_ENUM_ICON8, buffer, offered, needed, returned);
}
else
return ERROR_INVALID_NAME;
@@ -2354,15 +2331,11 @@ static BOOL enum_all_printers_info_1_remote(fstring name, NEW_BUFFER *buffer, ui
/********************************************************************
enum_all_printers_info_1_network.
*********************************************************************/
-static BOOL enum_all_printers_info_1_network(fstring name, NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned)
+static BOOL enum_all_printers_info_1_network(NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned)
{
- fstring temp;
DEBUG(4,("enum_all_printers_info_1_network\n"));
- fstrcpy(temp, "\\\\");
- fstrcat(temp, global_myname);
- fstrcat(temp, "\\");
- return enum_all_printers_info_1(temp, PRINTER_ENUM_UNKNOWN_8, buffer, offered, needed, returned);
+ return enum_all_printers_info_1(PRINTER_ENUM_UNKNOWN_8, buffer, offered, needed, returned);
}
/********************************************************************
@@ -2370,7 +2343,7 @@ static BOOL enum_all_printers_info_1_network(fstring name, NEW_BUFFER *buffer, u
*
* called from api_spoolss_enumprinters (see this to understand)
********************************************************************/
-static BOOL enum_all_printers_info_2(fstring servername, NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned)
+static BOOL enum_all_printers_info_2(NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned)
{
int snum;
int i;
@@ -2382,7 +2355,7 @@ static BOOL enum_all_printers_info_2(fstring servername, NEW_BUFFER *buffer, uin
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_2(servername, &current_prt, snum)) {
+ if (construct_printer_info_2(&current_prt, snum)) {
if((printers=Realloc(printers, (*returned +1)*sizeof(PRINTER_INFO_2))) == NULL)
return ERROR_NOT_ENOUGH_MEMORY;
DEBUG(4,("ReAlloced memory for [%d] PRINTER_INFO_2\n", *returned));
@@ -2434,7 +2407,7 @@ static uint32 enumprinters_level1( uint32 flags, fstring name,
/* Not all the flags are equals */
if (flags & PRINTER_ENUM_LOCAL)
- return enum_all_printers_info_1_local(name, buffer, offered, needed, returned);
+ return enum_all_printers_info_1_local(buffer, offered, needed, returned);
if (flags & PRINTER_ENUM_NAME)
return enum_all_printers_info_1_name(name, buffer, offered, needed, returned);
@@ -2443,7 +2416,7 @@ static uint32 enumprinters_level1( uint32 flags, fstring name,
return enum_all_printers_info_1_remote(name, buffer, offered, needed, returned);
if (flags & PRINTER_ENUM_NETWORK)
- return enum_all_printers_info_1_network(name, buffer, offered, needed, returned);
+ return enum_all_printers_info_1_network(buffer, offered, needed, returned);
return NT_STATUS_NO_PROBLEMO; /* NT4sp5 does that */
}
@@ -2461,15 +2434,15 @@ static uint32 enumprinters_level2( uint32 flags, fstring servername,
fstrcat(temp, global_myname);
if (flags & PRINTER_ENUM_LOCAL) {
- if (!strcmp(servername, temp))
- return enum_all_printers_info_2(temp, buffer, offered, needed, returned);
+ if (strequal(servername, temp))
+ return enum_all_printers_info_2(buffer, offered, needed, returned);
else
- return enum_all_printers_info_2("", buffer, offered, needed, returned);
+ return enum_all_printers_info_2(buffer, offered, needed, returned);
}
if (flags & PRINTER_ENUM_NAME) {
- if (!strcmp(servername, temp))
- return enum_all_printers_info_2(temp, buffer, offered, needed, returned);
+ if (strequal(servername, temp))
+ return enum_all_printers_info_2(buffer, offered, needed, returned);
else
return ERROR_INVALID_NAME;
}
@@ -2539,14 +2512,14 @@ uint32 _spoolss_enumprinters( uint32 flags, const UNISTR2 *servername, uint32 le
/****************************************************************************
****************************************************************************/
-static uint32 getprinter_level_0(fstring servername, int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed)
+static uint32 getprinter_level_0(int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed)
{
PRINTER_INFO_0 *printer=NULL;
if((printer=(PRINTER_INFO_0*)malloc(sizeof(PRINTER_INFO_0))) == NULL)
return ERROR_NOT_ENOUGH_MEMORY;
- construct_printer_info_0(printer, snum, servername);
+ construct_printer_info_0(printer, snum);
/* check the required size. */
*needed += spoolss_size_printer_info_0(printer);
@@ -2571,14 +2544,14 @@ static uint32 getprinter_level_0(fstring servername, int snum, NEW_BUFFER *buffe
/****************************************************************************
****************************************************************************/
-static uint32 getprinter_level_1(fstring servername, int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed)
+static uint32 getprinter_level_1(int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed)
{
PRINTER_INFO_1 *printer=NULL;
if((printer=(PRINTER_INFO_1*)malloc(sizeof(PRINTER_INFO_1))) == NULL)
return ERROR_NOT_ENOUGH_MEMORY;
- construct_printer_info_1(servername, PRINTER_ENUM_ICON8, printer, snum);
+ construct_printer_info_1(PRINTER_ENUM_ICON8, printer, snum);
/* check the required size. */
*needed += spoolss_size_printer_info_1(printer);
@@ -2603,17 +2576,14 @@ static uint32 getprinter_level_1(fstring servername, int snum, NEW_BUFFER *buffe
/****************************************************************************
****************************************************************************/
-static uint32 getprinter_level_2(fstring servername, int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed)
+static uint32 getprinter_level_2(int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed)
{
PRINTER_INFO_2 *printer=NULL;
- fstring temp;
if((printer=(PRINTER_INFO_2*)malloc(sizeof(PRINTER_INFO_2)))==NULL)
return ERROR_NOT_ENOUGH_MEMORY;
- fstrcpy(temp, "\\\\");
- fstrcat(temp, servername);
- construct_printer_info_2(temp, printer, snum);
+ construct_printer_info_2(printer, snum);
/* check the required size. */
*needed += spoolss_size_printer_info_2(printer);
@@ -2641,14 +2611,12 @@ static uint32 getprinter_level_2(fstring servername, int snum, NEW_BUFFER *buffe
/****************************************************************************
****************************************************************************/
-static uint32 getprinter_level_3(fstring servername, int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed)
+static uint32 getprinter_level_3(int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed)
{
PRINTER_INFO_3 *printer=NULL;
fstring temp;
- fstrcpy(temp, "\\\\");
- fstrcat(temp, servername);
- if (!construct_printer_info_3(temp, &printer, snum))
+ if (!construct_printer_info_3(&printer, snum))
return ERROR_NOT_ENOUGH_MEMORY;
/* check the required size. */
@@ -2678,24 +2646,21 @@ uint32 _spoolss_getprinter(POLICY_HND *handle, uint32 level,
NEW_BUFFER *buffer, uint32 offered, uint32 *needed)
{
int snum;
- fstring servername;
*needed=0;
- pstrcpy(servername, global_myname);
-
if (!get_printer_snum(handle, &snum))
return ERROR_INVALID_HANDLE;
switch (level) {
case 0:
- return getprinter_level_0(servername, snum, buffer, offered, needed);
+ return getprinter_level_0(snum, buffer, offered, needed);
case 1:
- return getprinter_level_1(servername,snum, buffer, offered, needed);
+ return getprinter_level_1(snum, buffer, offered, needed);
case 2:
- return getprinter_level_2(servername,snum, buffer, offered, needed);
+ return getprinter_level_2(snum, buffer, offered, needed);
case 3:
- return getprinter_level_3(servername,snum, buffer, offered, needed);
+ return getprinter_level_3(snum, buffer, offered, needed);
default:
return ERROR_INVALID_LEVEL;
}
@@ -2963,8 +2928,23 @@ static uint32 construct_printer_driver_info_6(DRIVER_INFO_6 *info, int snum, fst
status=get_a_printer_driver(&driver, 3, printer->info_2->drivername, architecture, version);
DEBUG(8,("construct_printer_driver_info_6: status: %d\n", status));
if (status != 0) {
- free_a_printer(&printer,2);
- return ERROR_UNKNOWN_PRINTER_DRIVER;
+ /*
+ * Is this a W2k client ?
+ */
+
+ if (version < 3) {
+ free_a_printer(&printer,2);
+ return ERROR_UNKNOWN_PRINTER_DRIVER;
+ }
+
+ /* Yes - try again with a WinNT driver. */
+ version = 2;
+ status=get_a_printer_driver(&driver, 3, printer->info_2->drivername, architecture, version);
+ DEBUG(8,("construct_printer_driver_info_6: status: %d\n", status));
+ if (status != 0) {
+ free_a_printer(&printer,2);
+ return ERROR_UNKNOWN_PRINTER_DRIVER;
+ }
}
fill_printer_driver_info_6(info, driver, servername);
@@ -3747,7 +3727,7 @@ static uint32 update_printer(POLICY_HND *handle, uint32 level,
*/
convert_printer_info(info, printer, level);
-
+
if (info->info_2->devmode_ptr != 0) {
/* we have a valid devmode
convert it and link it*/
@@ -3963,7 +3943,7 @@ static BOOL fill_job_info_2(JOB_INFO_2 *job_info, print_queue_struct *queue,
job_info->timeelapsed=0;
job_info->pagesprinted=0;
- if((job_info->devmode = construct_dev_mode(snum, global_myname)) == NULL) {
+ if((job_info->devmode = construct_dev_mode(snum)) == NULL) {
free_a_printer(&ntprinter, 2);
return False;
}