summaryrefslogtreecommitdiff
path: root/source3/rpc_server
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/rpc_server
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/rpc_server')
-rw-r--r--source3/rpc_server/srv_spoolss_nt.c150
1 files changed, 65 insertions, 85 deletions
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;
}