diff options
Diffstat (limited to 'source/rpc_server/srv_spoolss_nt.c')
-rw-r--r-- | source/rpc_server/srv_spoolss_nt.c | 45 |
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; } |