Return either STATUS_BUFFER_OVERFLOW or ERRDOS/ERRmoredata depending on
[samba.git] / source3 / smbd / ipc.c
index d359bc3500064623fe9cae2dd083e0f2abd901f1..a4d452b2a84cc4c61b36736ea61bb382deddc381 100644 (file)
@@ -37,8 +37,8 @@
 extern int DEBUGLEVEL;
 extern int max_send;
 
-extern pstring local_machine;
-extern pstring global_myworkgroup;
+extern fstring local_machine;
+extern fstring global_myworkgroup;
 
 #define NERR_Success 0
 #define NERR_badpass 86
@@ -61,6 +61,7 @@ extern pstring global_myworkgroup;
 
 extern int Client;
 extern int smb_read_error;
+extern uint32 global_client_caps;
 
 static BOOL api_Unsupported(connection_struct *conn,uint16 vuid, char *param,char *data,
                            int mdrcnt,int mprcnt,
@@ -187,9 +188,15 @@ static void send_trans_reply(char *outbuf,
 
        if (buffer_too_large)
        {
-               /* issue a buffer size warning.  on a DCE/RPC pipe, expect an SMBreadX... */
-               SIVAL(outbuf, smb_flg2, FLAGS2_32_BIT_ERROR_CODES);
-               SIVAL(outbuf, smb_rcls, 0x80000000 | NT_STATUS_ACCESS_VIOLATION);
+               if (global_client_caps & CAP_STATUS32)
+               {
+                       /* issue a buffer size warning.  on a DCE/RPC pipe, expect an SMBreadX... */
+                       SIVAL(outbuf, smb_flg2, FLAGS2_32_BIT_ERROR_CODES);
+                       SIVAL(outbuf, smb_rcls, 0x80000005); /* STATUS_BUFFER_OVERFLOW */
+               } else {
+                       SCVAL(outbuf, smb_rcls, ERRDOS);
+                       SSVAL(outbuf, smb_err, ERRmoredata);
+               }
        }
 
        copy_trans_params_and_data(outbuf, align,
@@ -635,7 +642,7 @@ static void fill_printq_info(connection_struct *conn, int snum, int uLevel,
     pstring fname;
 
     pstrcpy(fname,lp_driverfile());
-    f=fopen(fname,"r");
+    f=sys_fopen(fname,"r");
     if (!f) {
       DEBUG(3,("fill_printq_info: Can't open %s - %s\n",fname,strerror(errno)));
       desc->errcode=NERR_notsupported;
@@ -741,7 +748,7 @@ static int get_printerdrivernumber(int snum)
   pstrcpy(fname,lp_driverfile());
 
   DEBUG(4,("In get_printerdrivernumber: %s\n",fname));
-  f=fopen(fname,"r");
+  f=sys_fopen(fname,"r");
   if (!f) {
     DEBUG(3,("get_printerdrivernumber: Can't open %s - %s\n",fname,strerror(errno)));
     return(0);
@@ -842,6 +849,26 @@ static BOOL api_DosPrintQGetInfo(connection_struct *conn,
   if (init_package(&desc,1,count)) {
          desc.subcount = count;
          fill_printq_info(conn,snum,uLevel,&desc,count,queue,&status);
+  } else if(uLevel == 0) {
+       /*
+        * This is a *disgusting* hack.
+        * This is *so* bad that even I'm embarrassed (and I
+        * have no shame). Here's the deal :
+        * Until we get the correct SPOOLSS code into smbd
+        * then when we're running with NT SMB support then
+        * NT makes this call with a level of zero, and then
+        * immediately follows it with an open request to
+        * the \\SRVSVC pipe. If we allow that open to
+        * succeed then NT barfs when it cannot open the
+        * \\SPOOLSS pipe immediately after and continually
+        * whines saying "Printer name is invalid" forever
+        * after. If we cause *JUST THIS NEXT OPEN* of \\SRVSVC
+        * to fail, then NT downgrades to using the downlevel code
+        * and everything works as well as before. I hate
+        * myself for adding this code.... JRA.
+        */
+
+       fail_next_srvsvc_open();
   }
 
   *rdata_len = desc.usedlen;
@@ -999,7 +1026,7 @@ static int get_server_info(uint32 servertype,
   pstrcat(fname,"/");
   pstrcat(fname,SERVER_LIST);
 
-  f = fopen(fname,"r");
+  f = sys_fopen(fname,"r");
 
   if (!f) {
     DEBUG(4,("Can't open %s - %s\n",fname,strerror(errno)));
@@ -1704,13 +1731,13 @@ static BOOL api_SamOEMChangePassword(connection_struct *conn,uint16 vuid, char *
    * Check the parameter definition is correct.
    */
   if(!strequal(param + 2, "zsT")) {
-    DEBUG(0,("api_SamOEMChangePassword: Invalid parameter string %sn\n", param + 2));
+    DEBUG(0,("api_SamOEMChangePassword: Invalid parameter string %s\n", param + 2));
     return False;
   }
   p = skip_string(p, 1);
 
   if(!strequal(p, "B516B16")) {
-    DEBUG(0,("api_SamOEMChangePassword: Invalid data parameter string %sn\n", p));
+    DEBUG(0,("api_SamOEMChangePassword: Invalid data parameter string %s\n", p));
     return False;
   }
   p = skip_string(p,1);
@@ -3216,7 +3243,8 @@ static int api_fd_reply(connection_struct *conn,uint16 vuid,char *outbuf,
                                  subcommand, p->name, pnum));
 
                /* record maximum data length that can be transmitted in an SMBtrans */
-               p->file_offset = mdrcnt;
+               p->file_offset          = mdrcnt;
+               p->prev_pdu_file_offset = 0;
 
                 DEBUG(10,("api_fd_reply: p:%p file_offset: %d\n",
                            p, p->file_offset));