summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
Diffstat (limited to 'source3')
-rw-r--r--source3/printing/printing.c38
-rw-r--r--source3/rpc_server/srv_spoolss_nt.c25
-rw-r--r--source3/utils/smbcontrol.c10
3 files changed, 45 insertions, 28 deletions
diff --git a/source3/printing/printing.c b/source3/printing/printing.c
index f783f8d590..7d4a52c351 100644
--- a/source3/printing/printing.c
+++ b/source3/printing/printing.c
@@ -246,16 +246,6 @@ static int traverse_fn_delete(TDB_CONTEXT *t, TDB_DATA key, TDB_DATA data, void
return 0;
}
-/**
- * Send PRINTER NOTIFY to all processes.
- **/
-void broadcast_printer_notify(const char *printer_name)
-{
- /* include NUL */
- message_send_all(conn_tdb_ctx(), MSG_PRINTER_NOTIFY, printer_name,
- strlen(printer_name) + 1, False, NULL);
-}
-
/****************************************************************************
check if the print queue has been updated recently enough
****************************************************************************/
@@ -321,6 +311,20 @@ static void set_updating_pid(fstring printer_name, BOOL delete)
}
/****************************************************************************
+ Send a message saying the queue changed.
+****************************************************************************/
+
+static void send_queue_message(const char *printer_name, uint32 high, uint32 low)
+{
+ char msg[8 + sizeof(fstring)];
+ SIVAL(msg,0,low);
+ SIVAL(msg,4,high);
+ fstrcpy(&msg[8], printer_name);
+
+ message_send_all(conn_tdb_ctx(), MSG_PRINTER_NOTIFY, msg, 8 + strlen(printer_name) + 1, False, NULL);
+}
+
+/****************************************************************************
update the internal database from the system print queue for a queue in the background
****************************************************************************/
@@ -452,7 +456,7 @@ static void print_queue_update_background(int snum)
if( qcount != get_queue_status(snum, &old_status)) {
DEBUG(10,("print_queue_update: queue status change %d jobs -> %d jobs for printer %s\n",
old_status.qcount, qcount, printer_name ));
- broadcast_printer_notify(printer_name);
+ send_queue_message(printer_name, 0, PRINTER_CHANGE_JOB);
}
/* store the new queue status structure */
@@ -696,7 +700,7 @@ BOOL print_job_delete(struct current_user *user, int jobid, WERROR *errcode)
printer_name = PRINTERNAME(snum);
- broadcast_printer_notify(printer_name);
+ send_queue_message(printer_name, 0, PRINTER_CHANGE_JOB);
return !print_job_exists(jobid);
}
@@ -739,7 +743,7 @@ BOOL print_job_pause(struct current_user *user, int jobid, WERROR *errcode)
printer_name = PRINTERNAME(snum);
- broadcast_printer_notify(printer_name);
+ send_queue_message(printer_name, 0, PRINTER_CHANGE_JOB);
/* how do we tell if this succeeded? */
@@ -782,7 +786,7 @@ BOOL print_job_resume(struct current_user *user, int jobid, WERROR *errcode)
printer_name = PRINTERNAME(snum);
- broadcast_printer_notify(printer_name);
+ send_queue_message(printer_name, 0, PRINTER_CHANGE_JOB);
return True;
}
@@ -1282,7 +1286,7 @@ BOOL print_queue_pause(struct current_user *user, int snum, WERROR *errcode)
printer_name = PRINTERNAME(snum);
- broadcast_printer_notify(printer_name);
+ send_queue_message(printer_name, 0, PRINTER_CHANGE_JOB);
return True;
}
@@ -1314,7 +1318,7 @@ BOOL print_queue_resume(struct current_user *user, int snum, WERROR *errcode)
printer_name = PRINTERNAME(snum);
- broadcast_printer_notify(printer_name);
+ send_queue_message(printer_name, 0, PRINTER_CHANGE_JOB);
return True;
}
@@ -1350,7 +1354,7 @@ BOOL print_queue_purge(struct current_user *user, int snum, WERROR *errcode)
printer_name = PRINTERNAME(snum);
- broadcast_printer_notify(printer_name);
+ send_queue_message(printer_name, 0, PRINTER_CHANGE_JOB);
return True;
}
diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c
index 6f46b4bc42..c7b4df9d82 100644
--- a/source3/rpc_server/srv_spoolss_nt.c
+++ b/source3/rpc_server/srv_spoolss_nt.c
@@ -566,33 +566,39 @@ static void srv_spoolss_receive_message(int msg_type, pid_t src, void *buf, size
{
Printer_entry *find_printer;
WERROR status;
+ fstring printer_name;
char msg[8];
+ char *buf_ptr = (char *)buf;
uint32 low, high;
- if (len != sizeof(msg)) {
+ if (len < sizeof(msg) + 2) {
DEBUG(2,("srv_spoolss_receive_message: got incorrect message size (%u)!\n", (unsigned int)len));
return;
}
- memcpy(msg, buf, len);
+ memcpy(msg, buf_ptr, sizeof(msg));
low = IVAL(msg,0);
high = IVAL(msg,4);
+ fstrcpy(printer_name, buf_ptr + sizeof(msg));
- DEBUG(10,("srv_spoolss_receive_message: Got message printer change low=0x%x high=0x%x\n", (unsigned int)low,
- (unsigned int)high ));
-
- find_printer = printers_list;
+ DEBUG(10,("srv_spoolss_receive_message: Got message printer change name [%s] low=0x%x high=0x%x\n",
+ printer_name, (unsigned int)low, (unsigned int)high ));
/* Iterate the printer list */
- for(; find_printer; find_printer = find_printer->next) {
+ for(find_printer = printers_list; find_printer; find_printer = find_printer->next) {
/*
* If the entry has a connected client we send the message.
*/
-
if (find_printer->notify.client_connected==True) {
DEBUG(10,("srv_spoolss_receive_message: printerserver [%s]\n", find_printer->dev.printerservername ));
+ if (*printer_name && !strequal(printer_name, find_printer->dev.handlename)) {
+ DEBUG(10,("srv_spoolss_receive_message: ignoring message sent to %s [%s]\n",
+ printer_name, find_printer->dev.handlename ));
+ continue;
+ }
+
if (cli_spoolss_reply_rrpcn(&cli, &find_printer->notify.client_hnd, low, high, &status))
DEBUG(10,("srv_spoolss_receive_message: cli_spoolss_reply_rrpcn status = 0x%x\n",
(unsigned int)W_ERROR_V(status)));
@@ -608,8 +614,9 @@ static void srv_spoolss_receive_message(int msg_type, pid_t src, void *buf, size
static BOOL srv_spoolss_sendnotify(uint32 high, uint32 low)
{
- char msg[8];
+ char msg[10];
+ ZERO_STRUCT(msg);
SIVAL(msg,0,low);
SIVAL(msg,4,high);
DEBUG(10,("srv_spoolss_sendnotify: printer change low=0x%x high=0x%x\n", low, high));
diff --git a/source3/utils/smbcontrol.c b/source3/utils/smbcontrol.c
index 331059d5bb..ce2d503971 100644
--- a/source3/utils/smbcontrol.c
+++ b/source3/utils/smbcontrol.c
@@ -334,8 +334,14 @@ static BOOL do_command(char *dest, char *msg_name, int iparams, char **params)
fprintf(stderr, "printer-notify needs a printer name\n");
return (False);
}
- retval = send_message(dest, MSG_PRINTER_NOTIFY, params[0],
- strlen(params[0]) + 1, False);
+ {
+ char msg[8 + sizeof(fstring)];
+ SIVAL(msg,0,PRINTER_CHANGE_ALL);
+ SIVAL(msg,4,0);
+ fstrcpy(&msg[8], params[0]);
+
+ retval = send_message(dest, MSG_PRINTER_NOTIFY, msg, 8 + strlen(params[0]) + 1, False);
+ }
break;
case MSG_SMB_FORCE_TDIS: