Added "nt status support" parameter. Fix offline synchronisation.
authorJeremy Allison <jra@samba.org>
Wed, 27 Feb 2002 21:46:53 +0000 (21:46 +0000)
committerJeremy Allison <jra@samba.org>
Wed, 27 Feb 2002 21:46:53 +0000 (21:46 +0000)
Jeremy.
(This used to be commit 9243a9778e52999d5c62cba484640637b24994d8)

source3/include/smb.h
source3/param/loadparm.c
source3/smbd/error.c
source3/smbd/negprot.c
source3/smbd/nttrans.c
source3/smbd/reply.c

index 6f05868a3f9ed41fdbce90a98efe586851d53ecb..357362f8a2e41c2f9903c9f514dea57fc3ada2c2 100644 (file)
@@ -1277,6 +1277,7 @@ char *strdup(char *s);
    
 #define FLAGS2_LONG_PATH_COMPONENTS   0x0001
 #define FLAGS2_EXTENDED_ATTRIBUTES    0x0002
+#define FLAGS2_IS_LONG_NAME           0x0040
 #define FLAGS2_EXTENDED_SECURITY      0x0800 
 #define FLAGS2_DFS_PATHNAMES          0x1000
 #define FLAGS2_READ_PERMIT_NO_EXECUTE 0x2000
index 8679addcffe240eb905ee2a02fcb36067c859c86..7548ff03a8be4a0e51cd691db3631a907bba0b80 100644 (file)
@@ -255,6 +255,7 @@ typedef struct
        BOOL bTimestampLogs;
        BOOL bNTSmbSupport;
        BOOL bNTPipeSupport;
+       BOOL bNTStatusSupport;
        BOOL bStatCache;
        BOOL bKernelOplocks;
        BOOL bAllowTrustedDomains;
@@ -808,6 +809,7 @@ static struct parm_struct parm_table[] = {
        
        {"nt pipe support", P_BOOL, P_GLOBAL, &Globals.bNTPipeSupport, NULL, NULL, 0},
        {"nt acl support", P_BOOL,  P_LOCAL, &sDefault.bNTAclSupport, NULL, NULL, FLAG_GLOBAL | FLAG_SHARE },
+       {"nt status support", P_BOOL, P_GLOBAL, &Globals.bNTStatusSupport, NULL, NULL, 0},
        {"announce version", P_STRING, P_GLOBAL, &Globals.szAnnounceVersion, NULL, NULL, 0},
        {"announce as", P_ENUM, P_GLOBAL, &Globals.announce_as, NULL, enum_announce_as, 0},
        {"max mux", P_INTEGER, P_GLOBAL, &Globals.max_mux, NULL, NULL, 0},
@@ -1298,6 +1300,7 @@ static void init_globals(void)
        Globals.bPasswdChatDebug = False;
        Globals.bUnicode = True;        /* Do unicode on the wire by default */
        Globals.bNTPipeSupport = True;  /* Do NT pipes by default. */
+       Globals.bNTStatusSupport = True; /* Use NT status by default. */
        Globals.bStatCache = True;      /* use stat cache by default */
        Globals.bRestrictAnonymous = False;
        Globals.bLanmanAuth = True;     /* Do use the LanMan hash if it is available */
@@ -1601,6 +1604,7 @@ FN_GLOBAL_BOOL(lp_unix_password_sync, &Globals.bUnixPasswdSync)
 FN_GLOBAL_BOOL(lp_passwd_chat_debug, &Globals.bPasswdChatDebug)
 FN_GLOBAL_BOOL(lp_unicode, &Globals.bUnicode)
 FN_GLOBAL_BOOL(lp_nt_pipe_support, &Globals.bNTPipeSupport)
+FN_GLOBAL_BOOL(lp_nt_status_support, &Globals.bNTStatusSupport)
 FN_GLOBAL_BOOL(lp_stat_cache, &Globals.bStatCache)
 FN_GLOBAL_BOOL(lp_allow_trusted_domains, &Globals.bAllowTrustedDomains)
 FN_GLOBAL_BOOL(lp_restrict_anonymous, &Globals.bRestrictAnonymous)
index 6b3b73aa87b025d73075dae1e8556382c1169bfd..92a7c11b153c073074a000464d7148dcd5d8392c 100644 (file)
@@ -90,10 +90,17 @@ int error_packet(char *outbuf,NTSTATUS ntstatus,
        if (errno != 0)
                DEBUG(3,("error string = %s\n",strerror(errno)));
   
-       if (global_client_caps & CAP_STATUS32) {
-               if (NT_STATUS_V(ntstatus) == 0 && eclass) {
+       /*
+        * We can explicitly force 32 bit error codes even when the
+        * parameter "nt status" is set to no by pre-setting the
+        * FLAGS2_32_BIT_ERROR_CODES bit in the smb_flg2 outbuf.
+        * This is to allow work arounds for client bugs that are needed
+        * when talking with clients that normally expect nt status codes. JRA.
+        */
+
+       if ((lp_nt_status_support() || (SVAL(outbuf,smb_flg2) & FLAGS2_32_BIT_ERROR_CODES)) && (global_client_caps & CAP_STATUS32)) {
+               if (NT_STATUS_V(ntstatus) == 0 && eclass)
                        ntstatus = dos_to_ntstatus(eclass, ecode);
-               }
                SIVAL(outbuf,smb_rcls,NT_STATUS_V(ntstatus));
                SSVAL(outbuf,smb_flg2, SVAL(outbuf,smb_flg2)|FLAGS2_32_BIT_ERROR_CODES);
                DEBUG(3,("error packet at %s(%d) cmd=%d (%s) %s\n",
@@ -104,9 +111,8 @@ int error_packet(char *outbuf,NTSTATUS ntstatus,
                return outsize;
        } 
 
-       if (eclass == 0 && NT_STATUS_V(ntstatus)) {
+       if (eclass == 0 && NT_STATUS_V(ntstatus))
                ntstatus_to_dos(ntstatus, &eclass, &ecode);
-       }
 
        SSVAL(outbuf,smb_flg2, SVAL(outbuf,smb_flg2)&~FLAGS2_32_BIT_ERROR_CODES);
        SSVAL(outbuf,smb_rcls,eclass);
index 934d594853d64a96221ba343893cd2992abcb8ae..f4ed360845e6093f0d49a22327f0b7ff3dd67b19 100644 (file)
@@ -220,7 +220,7 @@ static int reply_nt1(char *inbuf, char *outbuf)
 {
        /* dual names + lock_and_read + nt SMBs + remote API calls */
        int capabilities = CAP_NT_FIND|CAP_LOCK_AND_READ|
-               CAP_LEVEL_II_OPLOCKS|CAP_STATUS32;
+               CAP_LEVEL_II_OPLOCKS;
 
        int secword=0;
        time_t t = time(NULL);
@@ -242,28 +242,29 @@ static int reply_nt1(char *inbuf, char *outbuf)
        
        capabilities |= CAP_NT_SMBS|CAP_RPC_REMOTE_APIS|CAP_UNIX;
        
-       if (lp_large_readwrite() && (SMB_OFF_T_BITS == 64)) {
+       if (lp_large_readwrite() && (SMB_OFF_T_BITS == 64))
                capabilities |= CAP_LARGE_READX|CAP_LARGE_WRITEX|CAP_W2K_SMBS;
-       }
        
-       if (SMB_OFF_T_BITS == 64) {
+       if (SMB_OFF_T_BITS == 64)
                capabilities |= CAP_LARGE_FILES;
-       }
-       
-       if (lp_readraw() && lp_writeraw()) {
+
+       if (lp_readraw() && lp_writeraw())
                capabilities |= CAP_RAW_MODE;
-       }
        
        /* allow for disabling unicode */
-       if (lp_unicode()) {
+       if (lp_unicode())
                capabilities |= CAP_UNICODE;
-       }
+
+       if (lp_nt_status_support())
+               capabilities |= CAP_STATUS32;
        
        if (lp_host_msdfs())
                capabilities |= CAP_DFS;
        
-       if (lp_security() >= SEC_USER) secword |= 1;
-       if (global_encrypted_passwords_negotiated) secword |= 2;
+       if (lp_security() >= SEC_USER)
+               secword |= 1;
+       if (global_encrypted_passwords_negotiated)
+               secword |= 2;
        
        set_message(outbuf,17,0,True);
        
index 501f0e9ab05ddd50ac8d5cba85a282c0e4db7d70..d56b7fe62211c4b2fb7edb4a9894a6a64336ba81 100644 (file)
@@ -828,8 +828,8 @@ int reply_ntcreate_and_X(connection_struct *conn,
        if(oplock_request && EXCLUSIVE_OPLOCK_TYPE(fsp->oplock_type))
                smb_action |= EXTENDED_OPLOCK_GRANTED;
 
-#if 1 /* JRATEST */
-       /* W2K sends back 42 words here ! */
+#if 0
+       /* W2K sends back 42 words here ! If we do the same it breaks offline sync. Go figure... ? JRA. */
        set_message(outbuf,42,0,True);
 #else
        set_message(outbuf,34,0,True);
@@ -1809,9 +1809,8 @@ due to being in oplock break state.\n" ));
     }
   }
 
-  if (Protocol >= PROTOCOL_NT1) {
-    SSVAL(outbuf,smb_flg2,SVAL(outbuf,smb_flg2) | 0x40); /* IS_LONG_NAME */
-  }
+  if (Protocol >= PROTOCOL_NT1)
+    SSVAL(outbuf,smb_flg2,SVAL(outbuf,smb_flg2) | FLAGS2_IS_LONG_NAME);
 
   /* Now we must call the relevant NT_TRANS function */
   switch(function_code) {
index c7f805122db4d1d2db24d3b3ea1875c2544a457b..0a349a9c8a7af539985df66099005dc098466b42 100644 (file)
@@ -482,9 +482,8 @@ int reply_getatr(connection_struct *conn, char *inbuf,char *outbuf, int dum_size
     put_dos_date3(outbuf,smb_vwv1,mtime);
   SIVAL(outbuf,smb_vwv3,(uint32)size);
 
-  if (Protocol >= PROTOCOL_NT1) {
-         SSVAL(outbuf,smb_flg2,SVAL(outbuf, smb_flg2) | 0x40); /* IS_LONG_NAME */
-  }
+  if (Protocol >= PROTOCOL_NT1)
+         SSVAL(outbuf,smb_flg2,SVAL(outbuf, smb_flg2) | FLAGS2_IS_LONG_NAME);
   
   DEBUG( 3, ( "getatr name=%s mode=%d size=%d\n", fname, mode, (uint32)size ) );
   
@@ -760,9 +759,8 @@ int reply_search(connection_struct *conn, char *inbuf,char *outbuf, int dum_size
   SCVAL(smb_buf(outbuf),0,5);
   SSVAL(smb_buf(outbuf),1,numentries*DIR_STRUCT_SIZE);
 
-  if (Protocol >= PROTOCOL_NT1) {
-    SSVAL(outbuf,smb_flg2,SVAL(outbuf, smb_flg2) | 0x40); /* IS_LONG_NAME */
-  }
+  if (Protocol >= PROTOCOL_NT1)
+    SSVAL(outbuf,smb_flg2,SVAL(outbuf, smb_flg2) | FLAGS2_IS_LONG_NAME);
   
   outsize += DIR_STRUCT_SIZE*numentries;
   smb_setlen(outbuf,outsize - 4);