* set PRINTER_ATTRIBUTE_RAW_ONLY; CR 1736
authorGerald Carter <jerry@samba.org>
Sat, 15 Feb 2003 23:33:30 +0000 (23:33 +0000)
committerGerald Carter <jerry@samba.org>
Sat, 15 Feb 2003 23:33:30 +0000 (23:33 +0000)
* never save a pointer to an automatic variable (they go away)
  implement a deep copy for SPOOLSS_NOTIFY_MSG to correct
  messages being sent that have junk for strings;
  fix in response to changes for CR 1504
(This used to be commit ffda9e2480414c7ed6156958f516e0d1f3c61350)

source3/include/rpc_spoolss.h
source3/printing/notify.c
source3/printing/nt_printing.c
source3/rpc_server/srv_spoolss_nt.c

index 249053403d17de0d74a1e0ff9fa93bbb14b27e51..c2e3d92787c4784b3e153008f39eaac28c7c6aa6 100755 (executable)
@@ -373,6 +373,10 @@ PRINTER_MESSAGE_INFO;
 #define PRINTER_ATTRIBUTE_RAW_ONLY             0x00001000
 #define PRINTER_ATTRIBUTE_PUBLISHED            0x00002000
 
+#define PRINTER_ATTRIBUTE_SAMBA                        (PRINTER_ATTRIBUTE_RAW_ONLY|\
+                                                PRINTER_ATTRIBUTE_SHARED|\
+                                                PRINTER_ATTRIBUTE_NETWORK)
+
 #define NO_PRIORITY     0
 #define MAX_PRIORITY   99
 #define MIN_PRIORITY    1
index c344edb8d8937bcefaff8a0921b4a95c6a1a4a2c..50c5ce39f645ccb77cf0fcbdb79a5e53728cba57 100644 (file)
@@ -190,11 +190,35 @@ void print_notify_send_messages(unsigned int timeout)
        talloc_destroy_pool(send_ctx);
 }
 
+/**********************************************************************
+ deep copy a SPOOLSS_NOTIFY_MSG structure using a TALLOC_CTX
+ *********************************************************************/
+static BOOL copy_notify2_msg( SPOOLSS_NOTIFY_MSG *to, SPOOLSS_NOTIFY_MSG *from )
+{
+
+       if ( !to || !from )
+               return False;
+       
+       memcpy( to, from, sizeof(SPOOLSS_NOTIFY_MSG) );
+       
+       if ( from->len ) {
+               to->notify.data = talloc_memdup(send_ctx, from->notify.data, from->len );
+               if ( !to->notify.data ) {
+                       DEBUG(0,("copy_notify2_msg: talloc_memdup() of size [%d] failed!\n", from->len ));
+                       return False;
+               }
+       }
+       
+
+       return True;
+}
+
 /*******************************************************************
  Batch up print notify messages.
 *******************************************************************/
 
-static void send_spoolss_notify2_msg(struct spoolss_notify_msg *msg)
+static void send_spoolss_notify2_msg(SPOOLSS_NOTIFY_MSG *msg)
 {
        struct notify_queue *pnqueue, *tmp_ptr;
 
@@ -227,7 +251,14 @@ in notify_queue\n", msg->type, msg->field, msg->printer));
                return;
        }
 
-       pnqueue->msg = msg;
+       /* allocate a new msg structure and copy the fields */
+       
+       if ( !(pnqueue->msg = (SPOOLSS_NOTIFY_MSG*)talloc(send_ctx, sizeof(SPOOLSS_NOTIFY_MSG))) ) {
+               DEBUG(0,("send_spoolss_notify2_msg: talloc() of size [%d] failed!\n", 
+                       sizeof(SPOOLSS_NOTIFY_MSG)));
+               return;
+       }
+       copy_notify2_msg(pnqueue->msg, msg);
        pnqueue->buf = NULL;
        pnqueue->buflen = 0;
 
index 73f1dd5f0d45130b2a7796002325787441993716..10d490a4c1f69cdc756aafce08f935e1b46bd530 100644 (file)
@@ -3132,7 +3132,7 @@ static WERROR get_a_printer_2_default(NT_PRINTER_INFO_LEVEL_2 **info_ptr, fstrin
        fstrcpy(info.printprocessor, "winprint");
        fstrcpy(info.datatype, "RAW");
 
-       info.attributes = PRINTER_ATTRIBUTE_SHARED | PRINTER_ATTRIBUTE_NETWORK;      /* attributes */
+       info.attributes = PRINTER_ATTRIBUTE_SAMBA;
 
        info.starttime = 0; /* Minutes since 12:00am GMT */
        info.untiltime = 0; /* Minutes since 12:00am GMT */
@@ -3224,7 +3224,7 @@ static WERROR get_a_printer_2(NT_PRINTER_INFO_LEVEL_2 **info_ptr, fstring sharen
                        info.parameters);
 
        /* Samba has to have shared raw drivers. */
-       info.attributes |= (PRINTER_ATTRIBUTE_SHARED | PRINTER_ATTRIBUTE_NETWORK); 
+       info.attributes |= PRINTER_ATTRIBUTE_SAMBA;
 
        /* Restore the stripped strings. */
        slprintf(info.servername, sizeof(info.servername)-1, "\\\\%s", get_called_name());
index 8304b14a1ceb2e2c5ba34f6c3a33aa7dbf466bec..0bcc3c5a30c1226f78b56fd7cc54b5574714b032 100644 (file)
@@ -5770,7 +5770,7 @@ static BOOL check_printer_ok(NT_PRINTER_INFO_LEVEL_2 *info, int snum)
        fstrcpy(info->sharename, lp_servicename(snum));
        slprintf(info->printername, sizeof(info->printername)-1, "\\\\%s\\%s",
                 get_called_name(), info->sharename);
-       info->attributes = PRINTER_ATTRIBUTE_SHARED | PRINTER_ATTRIBUTE_NETWORK;
+       info->attributes = PRINTER_ATTRIBUTE_SAMBA;
        
        return True;
 }