r20253: Reduce some code duplication, make reply_mkdir go through the same code paths
authorVolker Lendecke <vlendec@samba.org>
Tue, 19 Dec 2006 16:36:54 +0000 (16:36 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 17:16:37 +0000 (12:16 -0500)
ncreate does. This is a bit slower (about 10-20%), because it goes touches the
share mode db, but I think not having to call change_owner_to_parent and
friends in fewer places outweighs this. And, mkdir is not the way current
Windows boxes create directories, they do it via the ncreate call.

Volker
(This used to be commit ddae494fbe36e4a74776f71c212b00cce61fbf81)

source3/smbd/reply.c

index c069bd28b9ae1a4d5a1c6c51a7b017f92e3f2ab8..a7804d3f43162f11c3615b13c4c28610bd7e597b 100644 (file)
@@ -3795,6 +3795,7 @@ int reply_mkdir(connection_struct *conn, char *inbuf,char *outbuf, int dum_size,
        NTSTATUS status;
        BOOL bad_path = False;
        SMB_STRUCT_STAT sbuf;
+       files_struct *fsp;
 
        START_PROFILE(SMBmkdir);
  
@@ -3808,17 +3809,17 @@ int reply_mkdir(connection_struct *conn, char *inbuf,char *outbuf, int dum_size,
 
        unix_convert(directory,conn,0,&bad_path,&sbuf);
 
-       if( is_ntfs_stream_name(directory)) {
-               DEBUG(5,("reply_mkdir: failing create on filename %s with colon in name\n", directory));
-               END_PROFILE(SMBmkdir);
-               return ERROR_NT(NT_STATUS_NOT_A_DIRECTORY);
-       }
+       status = open_directory(conn, directory, &sbuf,
+                               FILE_READ_ATTRIBUTES, /* Just a stat open */
+                               FILE_SHARE_NONE, /* Ignored for stat opens */
+                               FILE_CREATE, 0, NULL, &fsp);
+
+       DEBUG(1, ("open_directory returned %s\n", nt_errstr(status)));
 
-       status = mkdir_internal(conn, directory,bad_path);
        if (!NT_STATUS_IS_OK(status)) {
 
-               if (NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_COLLISION) &&
-                   !use_nt_status()) {
+               if (NT_STATUS_EQUAL(
+                           status, NT_STATUS_DOS(ERRDOS, ERRfilexists))) {
                        /*
                         * Yes, in the DOS error code case we get a
                         * ERRDOS:ERRnoaccess here. See BASE-SAMBA3ERROR
@@ -3831,23 +3832,7 @@ int reply_mkdir(connection_struct *conn, char *inbuf,char *outbuf, int dum_size,
                return ERROR_NT(status);
        }
 
-       if (lp_inherit_owner(SNUM(conn))) {
-               /* Ensure we're checking for a symlink here.... */
-               /* We don't want to get caught by a symlink racer. */
-
-               if(SMB_VFS_LSTAT(conn,directory, &sbuf) != 0) {
-                       END_PROFILE(SMBmkdir);
-                       return(UNIXERROR(ERRDOS,ERRnoaccess));
-               }
-                                                                                                                                                   
-               if(!S_ISDIR(sbuf.st_mode)) {
-                       DEBUG(0,("reply_mkdir: %s is not a directory !\n", directory ));
-                       END_PROFILE(SMBmkdir);
-                       return(UNIXERROR(ERRDOS,ERRnoaccess));
-               }
-
-               change_owner_to_parent(conn, NULL, directory, &sbuf);
-       }
+       close_file(fsp, NORMAL_CLOSE);
 
        outsize = set_message(outbuf,0,0,False);