r24474: Map error value NT_STATUS_OBJECT_NAME_COLLISION
authorJeremy Allison <jra@samba.org>
Wed, 15 Aug 2007 23:56:08 +0000 (23:56 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 17:29:51 +0000 (12:29 -0500)
to ERRDOS, ERRfilexists for NTCreateX and NTTransCreate.
Jeremy.

source/smbd/nttrans.c

index 1b6c324e9d9a7fe58e17a754b44847cf9cff6d29..23905181cdca3b9d681ff77fd72eea68f6e8f4e4 100644 (file)
@@ -788,18 +788,6 @@ void reply_ntcreate_and_X(connection_struct *conn,
                                        file_attributes,
                                        &info, &fsp);
 
-               TALLOC_FREE(case_state);
-
-               if(!NT_STATUS_IS_OK(status)) {
-                       if (!use_nt_status() && NT_STATUS_EQUAL(
-                                   status, NT_STATUS_OBJECT_NAME_COLLISION)) {
-                               status = NT_STATUS_DOS(ERRDOS, ERRfilexists);
-                       }
-                       reply_nterror(req, status);
-                       END_PROFILE(SMBntcreateX);
-                       return;
-               }
-
        } else {
 
                /*
@@ -861,7 +849,7 @@ void reply_ntcreate_and_X(connection_struct *conn,
                                        END_PROFILE(SMBntcreateX);
                                        return;
                                }
-       
+
                                oplock_request = 0;
                                status = open_directory(conn, req, fname,
                                                        &sbuf,
@@ -872,31 +860,33 @@ void reply_ntcreate_and_X(connection_struct *conn,
                                                        file_attributes,
                                                        &info, &fsp);
 
-                               if(!NT_STATUS_IS_OK(status)) {
-                                       TALLOC_FREE(case_state);
-                                       if (!use_nt_status() && NT_STATUS_EQUAL(
-                                                   status, NT_STATUS_OBJECT_NAME_COLLISION)) {
-                                               status = NT_STATUS_DOS(ERRDOS, ERRfilexists);
-                                       }
-                                       reply_nterror(req, status);
-                                       END_PROFILE(SMBntcreateX);
-                                       return;
-                               }
-                       } else {
-                               TALLOC_FREE(case_state);
-                               END_PROFILE(SMBntcreateX);
-                               if (open_was_deferred(req->mid)) {
-                                       /* We have re-scheduled this call. */
-                                       return;
-                               }
-                               reply_nterror(req, status);
-                               return;
                        }
-               } 
+               }
        }
-               
+
        TALLOC_FREE(case_state);
 
+        if (!NT_STATUS_IS_OK(status)) {
+               END_PROFILE(SMBntcreateX);
+               if (open_was_deferred(req->mid)) {
+                       /* We have re-scheduled this call. */
+                       return;
+               }
+               if (NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_COLLISION)) {
+                       /*
+                        * We hit an existing file, and if we're returning DOS
+                        * error codes OBJECT_NAME_COLLISION would map to
+                        * ERRDOS/183, we need to return ERRDOS/80, see bug
+                        * 4852.
+                        */
+                       reply_botherror(req, NT_STATUS_OBJECT_NAME_COLLISION,
+                               ERRDOS, ERRfilexists);
+                       return;
+               }
+               reply_nterror(req, status);
+               return;
+       }
+
        file_len = sbuf.st_size;
        fattr = dos_mode(conn,fname,&sbuf);
        if(fattr == 0) {