summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2002-01-22 01:48:50 +0000
committerJeremy Allison <jra@samba.org>2002-01-22 01:48:50 +0000
commit2773633d42ee75aef7c071b5c58d592e3fb79492 (patch)
treed787794d3b2d8fec367f9d919c2dc7b26470a722
parentdcb005482845dfc03ac1b4c14796c5068ac5551e (diff)
downloadsamba-2773633d42ee75aef7c071b5c58d592e3fb79492.tar.gz
samba-2773633d42ee75aef7c071b5c58d592e3fb79492.tar.xz
samba-2773633d42ee75aef7c071b5c58d592e3fb79492.zip
Brillient discovery by JohnR. When we're sending a change notify to
ourselves on printer change we *must* use the same handle that the change was caused on, or we really confuse the client spooler.... Jeremy.
-rw-r--r--source/rpc_server/srv_spoolss_nt.c45
1 files changed, 34 insertions, 11 deletions
diff --git a/source/rpc_server/srv_spoolss_nt.c b/source/rpc_server/srv_spoolss_nt.c
index e3a88063f9c..24b09e6a5d9 100644
--- a/source/rpc_server/srv_spoolss_nt.c
+++ b/source/rpc_server/srv_spoolss_nt.c
@@ -610,23 +610,39 @@ static BOOL alloc_buffer_size(NEW_BUFFER *buffer, uint32 buffer_size)
static void srv_spoolss_receive_message(int msg_type, pid_t src, void *buf, size_t len)
{
- fstring printer;
WERROR status;
struct pipes_struct *p;
struct policy *pol;
struct handle_list *hl;
+ fstring printer;
+ char *msg = (char *)buf;
*printer = '\0';
- fstrcpy(printer,buf);
- if (len == 0) {
+ if (len < 5 + sizeof(POLICY_HND)) {
DEBUG(0,("srv_spoolss_receive_message: got null message !\n"));
return;
}
+ /*
+ * If this is a message to ourselves, just send a change notify with
+ * the given handle, we know it's still open.
+ */
+
+ fstrcpy(printer,&msg[4 + sizeof(POLICY_HND)]);
DEBUG(10,("srv_spoolss_receive_message: Got message about printer %s\n", printer ));
+ if (IVAL(buf,0) == (uint32)sys_getpid()) {
+ POLICY_HND sent_pol;
+
+ memcpy(&sent_pol, &msg[4], sizeof(POLICY_HND));
+ DEBUG(10,("srv_spoolss_receive_message: using our own handle.\n"));
+ cli_spoolss_reply_rrpcn(&cli, &sent_pol, PRINTER_CHANGE_ALL, 0x0, &status);
+ return;
+ }
+
/*
+ * Not a locally opened handle.
* We need to enumerate all printers. The handle list is shared
* across pipes of the same name, so just find the first open
* spoolss pipe.
@@ -671,7 +687,8 @@ static void srv_spoolss_receive_message(int msg_type, pid_t src, void *buf, size
****************************************************************************/
static BOOL srv_spoolss_sendnotify(pipes_struct *p, POLICY_HND *handle)
{
- fstring printer;
+ pstring msg;
+ size_t msg_len;
Printer_entry *Printer=find_printer_index_by_hnd(p, handle);
@@ -680,16 +697,22 @@ static BOOL srv_spoolss_sendnotify(pipes_struct *p, POLICY_HND *handle)
return False;
}
- if (Printer->printer_type==PRINTER_HANDLE_IS_PRINTER)
- fstrcpy(printer, Printer->dev.handlename);
- else
- fstrcpy(printer, "");
+ memset(msg, '\0', sizeof(msg));
- /*srv_spoolss_receive_message(printer);*/
- DEBUG(10,("srv_spoolss_sendnotify: Sending message about printer %s\n", printer ));
+ if (Printer->printer_type==PRINTER_HANDLE_IS_PRINTER) {
+ uint32 mypid = (uint32)sys_getpid();
+ SIVAL(msg,0,mypid);
+ memcpy(&msg[4], handle, sizeof(POLICY_HND));
+ fstrcpy(&msg[4+sizeof(POLICY_HND)], Printer->dev.handlename);
+ msg_len = 4 + sizeof(POLICY_HND) + strlen(Printer->dev.handlename) + 1;
+ } else {
+ fstrcpy(&msg[4+sizeof(POLICY_HND)], "");
+ msg_len = 4 + sizeof(POLICY_HND) + 1;
+ }
- message_send_all(conn_tdb_ctx(), MSG_PRINTER_NOTIFY, printer, strlen(printer) + 1, False); /* Null terminate... */
+ DEBUG(10,("srv_spoolss_sendnotify: Sending message about printer %s\n", &msg[4+sizeof(POLICY_HND)] ));
+ message_send_all(conn_tdb_ctx(), MSG_PRINTER_NOTIFY, msg, msg_len, False);
return True;
}