merge from SAMBA_2_2.
authorGerald Carter <jerry@samba.org>
Fri, 24 May 2002 16:27:54 +0000 (16:27 +0000)
committerGerald Carter <jerry@samba.org>
Fri, 24 May 2002 16:27:54 +0000 (16:27 +0000)
Tim, please check the prs_align() removed from sec_io_desc()
and make sure it doesn't break anything else.  I know it is
right for the printing needs and I have tested some other
general things like viewing acls on directories, but I would
feel more comfortable if you would have a look as well.

jerry
(This used to be commit 83f109c940f30d9b35176540d8bdccbb22ffa3a1)

source3/rpc_parse/parse_sec.c
source3/rpc_parse/parse_spoolss.c
source3/rpc_server/srv_spoolss_nt.c

index c501f90479b5dbb627e05e1ab7d2f2606284f1c9..a8c956a2095dead1c24ec4cd4716a235e638de37 100644 (file)
@@ -749,8 +749,15 @@ BOOL sec_io_desc(char *desc, SEC_DESC **ppsd, prs_struct *ps, int depth)
        prs_debug(ps, depth, desc, "sec_io_desc");
        depth++;
 
+#if 0  /* JERRY */
+       /*
+        * if alignment is needed, should be done by the the 
+        * caller.  Not here.  This caused me problems when marshalling
+        * printer info into a buffer.   --jerry
+        */
        if(!prs_align(ps))
                return False;
+#endif
        
        /* start of security descriptor stored for back-calc offset purposes */
        old_offset = prs_offset(ps);
index bcfaa1d42f2960b473c22d22ababdfec18d6ff08..72d88c8129fc9de164c85f0bcb8b77bac6670f51 100644 (file)
@@ -2283,6 +2283,8 @@ BOOL smb_io_printer_info_1(char *desc, NEW_BUFFER *buffer, PRINTER_INFO_1 *info,
 BOOL smb_io_printer_info_2(char *desc, NEW_BUFFER *buffer, PRINTER_INFO_2 *info, int depth)
 {
        prs_struct *ps=&buffer->prs;
+       uint32 dm_offset, sd_offset, current_offset;
+       uint32 dummy_value = 0;
 
        prs_debug(ps, depth, desc, "smb_io_printer_info_2");
        depth++;        
@@ -2304,8 +2306,9 @@ BOOL smb_io_printer_info_2(char *desc, NEW_BUFFER *buffer, PRINTER_INFO_2 *info,
        if (!smb_io_relstr("location", buffer, depth, &info->location))
                return False;
 
-       /* NT parses the DEVMODE at the end of the struct */
-       if (!smb_io_reldevmode("devmode", buffer, depth, &info->devmode))
+       /* save current offset and wind forwared by a uint32 */
+       dm_offset = prs_offset(ps);
+       if (!prs_uint32("devmode", ps, depth, &dummy_value))
                return False;
        
        if (!smb_io_relstr("sepfile", buffer, depth, &info->sepfile))
@@ -2317,9 +2320,31 @@ BOOL smb_io_printer_info_2(char *desc, NEW_BUFFER *buffer, PRINTER_INFO_2 *info,
        if (!smb_io_relstr("parameters", buffer, depth, &info->parameters))
                return False;
 
+       /* save current offset for the sec_desc */
+       sd_offset = prs_offset(ps);
+       if (!prs_uint32("sec_desc", ps, depth, &dummy_value))
+               return False;
+
+       
+       /* save current location so we can pick back up here */
+       current_offset = prs_offset(ps);
+       
+       /* parse the devmode */
+       if (!prs_set_offset(ps, dm_offset))
+               return False;
+       if (!smb_io_reldevmode("devmode", buffer, depth, &info->devmode))
+               return False;
+       
+       /* parse the sec_desc */
+       if (!prs_set_offset(ps, sd_offset))
+               return False;
        if (!smb_io_relsecdesc("secdesc", buffer, depth, &info->secdesc))
                return False;
 
+       /* pick up where we left off */
+       if (!prs_set_offset(ps, current_offset))
+               return False;
+
        if (!prs_uint32("attributes", ps, depth, &info->attributes))
                return False;
        if (!prs_uint32("priority", ps, depth, &info->priority))
@@ -3095,7 +3120,7 @@ uint32 spoolss_size_printer_info_2(PRINTER_INFO_2 *info)
        uint32 size=0;
                
        size += 4;
-       /* JRA !!!! TESTME - WHAT ABOUT prs_align.... !!! */
+       
        size += sec_desc_size( info->secdesc );
 
        size+=size_of_device_mode( info->devmode );
@@ -3121,6 +3146,16 @@ uint32 spoolss_size_printer_info_2(PRINTER_INFO_2 *info)
        size+=size_of_uint32( &info->status );
        size+=size_of_uint32( &info->cjobs );
        size+=size_of_uint32( &info->averageppm );      
+               
+       /* 
+        * add any adjustments for alignment.  This is
+        * not optimal since we could be calling this
+        * function from a loop (e.g. enumprinters), but 
+        * it is easier to maintain the calculation here and
+        * not place the burden on the caller to remember.   --jerry
+        */
+       size += size % 4;
+       
        return size;
 }
 
index c4a8d3917c6fa66612c910592fb216943f7cd614..3f86768379ac9fef0749e42ec2210f1e232e2bec 100644 (file)
@@ -1510,7 +1510,11 @@ static BOOL getprinterdata_printer_server(TALLOC_CTX *ctx, fstring value, uint32
                *type = 0x4;
                if((*data = (uint8 *)talloc(ctx, 4*sizeof(uint8) )) == NULL)
                        return False;
+#ifndef EMULATE_WIN2K_HACK /* JERRY */
                SIVAL(*data, 0, 2);
+#else
+               SIVAL(*data, 0, 3);
+#endif
                *needed = 0x4;
                return True;
        }
@@ -3004,7 +3008,7 @@ static BOOL construct_printer_info_0(PRINTER_INFO_0 *printer, int snum)
 
        printer->global_counter = global_counter;
        printer->total_pages = 0;
-#if 0  /* JERRY */
+#ifndef EMULATE_WIN2K_HACK     /* JERRY */
        printer->major_version = 0x0004;        /* NT 4 */
        printer->build_version = 0x0565;        /* build 1381 */
 #else
@@ -5257,8 +5261,6 @@ static WERROR update_printer(pipes_struct *p, POLICY_HND *handle, uint32 level,
        if (!strequal(printer->info_2->location, old_printer->info_2->location))
                msg.flags |= PRINTER_MESSAGE_LOCATION;
 
-       ZERO_STRUCT(msg);
-       
        msg.low = PRINTER_CHANGE_ADD_PRINTER;
        fstrcpy(msg.printer_name, printer->info_2->printername);