]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
r6174: Fixup T2 open call - we were returning 2 bytes short.
authorJeremy Allison <jra@samba.org>
Sat, 2 Apr 2005 00:13:27 +0000 (00:13 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 15:56:27 +0000 (10:56 -0500)
Jeremy.

source/smbd/open.c
source/smbd/reply.c
source/smbd/trans2.c

index 41ced420344c6928d9ccd4b295ae9c9189b3ae65..fbe763ab0ac5cc941ed0976ae9530300f4e0c960 100644 (file)
@@ -1098,23 +1098,6 @@ files_struct *open_file_shared1(connection_struct *conn,char *fname, SMB_STRUCT_
                return print_fsp_open(conn, fname);
        }
 
-       switch(ofun) {
-               case FILE_EXISTS_OPEN:
-               case FILE_EXISTS_TRUNCATE:
-               case FILE_EXISTS_FAIL | FILE_CREATE_IF_NOT_EXIST:
-               case FILE_EXISTS_OPEN | FILE_CREATE_IF_NOT_EXIST:
-               case FILE_EXISTS_TRUNCATE | FILE_CREATE_IF_NOT_EXIST:
-                       break; /* These are ok. */
-               default:
-                       if (GET_OPEN_MODE(share_mode) == DOS_OPEN_EXEC) {
-                               ofun = FILE_EXISTS_FAIL | FILE_CREATE_IF_NOT_EXIST;
-                               break;
-                       }
-                       /* Cause caller to force dos errors. */
-                       set_saved_error_triple(ERRDOS, ERRbadaccess, NT_STATUS_INVALID);
-                       return NULL;
-       }
-
        DEBUG(10,("open_file_shared: fname = %s, dos_attrs = %x, share_mode = %x, ofun = %x, mode = %o, oplock request = %d\n",
                fname, new_dos_mode, share_mode, ofun, (int)mode,  oplock_request ));
 
index aef9755122f14574ee9d7cca8d9ac933ee867ce5..22cb599195fff6cccaf7c0d1dfc93e9e93fa62f7 100644 (file)
@@ -1295,7 +1295,17 @@ int reply_open_and_X(connection_struct *conn, char *inbuf,char *outbuf,int lengt
                END_PROFILE(SMBopenX);
                return ERROR_NT(NT_STATUS_OBJECT_PATH_NOT_FOUND);
        }
-    
+
+       /* Strange open mode mapping. */
+       if (smb_ofun == 0) {
+               if (GET_OPEN_MODE(smb_mode) == DOS_OPEN_EXEC) {
+                       smb_ofun = FILE_EXISTS_FAIL | FILE_CREATE_IF_NOT_EXIST;
+               } else {
+                       END_PROFILE(SMBopenX);
+                       return ERROR_FORCE_DOS(ERRDOS, ERRbadaccess);
+               }
+       }
+
        fsp = open_file_shared(conn,fname,&sbuf,smb_mode,smb_ofun,(uint32)smb_attr,
                        oplock_request, &rmode,&smb_action);
       
index a497e8d81c1d6eacd6279115de7c2886618f89ba..cbb350ebb7dc85a33a96ac6269f40c857ab462a5 100644 (file)
@@ -732,6 +732,7 @@ static int call_trans2open(connection_struct *conn, char *inbuf, char *outbuf, i
        files_struct *fsp;
        TALLOC_CTX *ctx = NULL;
        struct ea_list *ea_list = NULL;
+       uint16 flags = 0;
        NTSTATUS status;
 
        /*
@@ -742,11 +743,12 @@ static int call_trans2open(connection_struct *conn, char *inbuf, char *outbuf, i
                return ERROR_NT(NT_STATUS_INVALID_PARAMETER);
        }
 
+       flags = SVAL(params, 0);
        open_mode = SVAL(params, 2);
        open_attr = SVAL(params,6);
-        oplock_request = (SVAL(params,0) & REQUEST_OPLOCK) ? EXCLUSIVE_OPLOCK : 0;
+        oplock_request = (flags & REQUEST_OPLOCK) ? EXCLUSIVE_OPLOCK : 0;
         if (oplock_request) {
-                oplock_request |= (SVAL(params,0) & REQUEST_BATCH_OPLOCK) ? BATCH_OPLOCK : 0;
+                oplock_request |= (flags & REQUEST_BATCH_OPLOCK) ? BATCH_OPLOCK : 0;
         }
 
 #if 0
@@ -780,6 +782,16 @@ static int call_trans2open(connection_struct *conn, char *inbuf, char *outbuf, i
                return set_bad_path_error(errno, bad_path, outbuf, ERRDOS,ERRnoaccess);
        }
 
+       /* Strange open mode mapping. */
+       if (open_ofun == 0) {
+               if (GET_OPEN_MODE(open_mode) == DOS_OPEN_EXEC) {
+                       open_ofun = FILE_EXISTS_FAIL | FILE_CREATE_IF_NOT_EXIST;
+               } else {
+                       END_PROFILE(SMBopenX);
+                       return ERROR_FORCE_DOS(ERRDOS, ERRbadaccess);
+               }
+       }
+
        /* Any data in this call is an EA list. */
        if (total_data && !lp_ea_support(SNUM(conn))) {
                return ERROR_NT(NT_STATUS_EAS_NOT_SUPPORTED);
@@ -839,21 +851,22 @@ static int call_trans2open(connection_struct *conn, char *inbuf, char *outbuf, i
        }
 
        /* Realloc the size of parameters and data we will return */
-       params = SMB_REALLOC(*pparams, 28);
+       params = SMB_REALLOC(*pparams, 30);
        if( params == NULL ) {
                return ERROR_NT(NT_STATUS_NO_MEMORY);
        }
        *pparams = params;
 
-       memset((char *)params,'\0',28);
+       memset((char *)params,'\0',30);
        SSVAL(params,0,fsp->fnum);
        SSVAL(params,2,fmode);
        put_dos_date2(params,4, mtime);
        SIVAL(params,8, (uint32)size);
        SSVAL(params,12,rmode);
 
-       if (oplock_request && lp_fake_oplocks(SNUM(conn)))
+       if (oplock_request && lp_fake_oplocks(SNUM(conn))) {
                smb_action |= EXTENDED_OPLOCK_GRANTED;
+       }
 
        SSVAL(params,18,smb_action);
 
@@ -861,9 +874,13 @@ static int call_trans2open(connection_struct *conn, char *inbuf, char *outbuf, i
         * WARNING - this may need to be changed if SMB_INO_T <> 4 bytes.
         */
        SIVAL(params,20,inode);
+       if (flags & 8) {
+               uint32 ea_size = estimate_ea_size(conn, fsp, fname);
+               SIVAL(params, 26, ea_size);
+       }
+
        /* Send the required number of replies */
-       send_trans2_replies(outbuf, bufsize, params, 28, *ppdata, 0);
+       send_trans2_replies(outbuf, bufsize, params, 30, *ppdata, 0);
 
        return -1;
 }