s3: Plumb smb_filename through SMB_VFS_CREATE_FILE
[samba.git] / source3 / smbd / open.c
index d529b009d5086484c5a3727c19412fba4651ca8f..c7d5979a85dd37ca251d060df7f085ab7fcdfb6d 100644 (file)
@@ -206,19 +206,19 @@ void change_file_owner_to_parent(connection_struct *conn,
        }
 
        become_root();
-       ret = SMB_VFS_FCHOWN(fsp, parent_st.st_uid, (gid_t)-1);
+       ret = SMB_VFS_FCHOWN(fsp, parent_st.st_ex_uid, (gid_t)-1);
        unbecome_root();
        if (ret == -1) {
                DEBUG(0,("change_file_owner_to_parent: failed to fchown "
                         "file %s to parent directory uid %u. Error "
                         "was %s\n", fsp->fsp_name,
-                        (unsigned int)parent_st.st_uid,
+                        (unsigned int)parent_st.st_ex_uid,
                         strerror(errno) ));
        }
 
        DEBUG(10,("change_file_owner_to_parent: changed new file %s to "
                  "parent directory uid %u.\n", fsp->fsp_name,
-                 (unsigned int)parent_st.st_uid ));
+                 (unsigned int)parent_st.st_ex_uid ));
 }
 
 NTSTATUS change_dir_owner_to_parent(connection_struct *conn,
@@ -276,9 +276,9 @@ NTSTATUS change_dir_owner_to_parent(connection_struct *conn,
        }
 
        /* Ensure we're pointing at the same place. */
-       if (sbuf.st_dev != psbuf->st_dev ||
-           sbuf.st_ino != psbuf->st_ino ||
-           sbuf.st_mode != psbuf->st_mode ) {
+       if (sbuf.st_ex_dev != psbuf->st_ex_dev ||
+           sbuf.st_ex_ino != psbuf->st_ex_ino ||
+           sbuf.st_ex_mode != psbuf->st_ex_mode ) {
                DEBUG(0,("change_dir_owner_to_parent: "
                         "device/inode/mode on directory %s changed. "
                         "Refusing to chown !\n", fname ));
@@ -287,20 +287,20 @@ NTSTATUS change_dir_owner_to_parent(connection_struct *conn,
        }
 
        become_root();
-       ret = SMB_VFS_CHOWN(conn, ".", parent_st.st_uid, (gid_t)-1);
+       ret = SMB_VFS_CHOWN(conn, ".", parent_st.st_ex_uid, (gid_t)-1);
        unbecome_root();
        if (ret == -1) {
                status = map_nt_error_from_unix(errno);
                DEBUG(10,("change_dir_owner_to_parent: failed to chown "
                          "directory %s to parent directory uid %u. "
                          "Error was %s\n", fname,
-                         (unsigned int)parent_st.st_uid, strerror(errno) ));
+                         (unsigned int)parent_st.st_ex_uid, strerror(errno) ));
                goto out;
        }
 
        DEBUG(10,("change_dir_owner_to_parent: changed ownership of new "
                  "directory %s to parent directory uid %u.\n",
-                 fname, (unsigned int)parent_st.st_uid ));
+                 fname, (unsigned int)parent_st.st_ex_uid ));
 
  out:
 
@@ -346,7 +346,7 @@ static NTSTATUS open_file(files_struct *fsp,
 
        if (!CAN_WRITE(conn)) {
                /* It's a read-only share - fail if we wanted to write. */
-               if(accmode != O_RDONLY) {
+               if(accmode != O_RDONLY || (flags & O_TRUNC) || (flags & O_APPEND)) {
                        DEBUG(3,("Permission denied opening %s\n", path));
                        return NT_STATUS_ACCESS_DENIED;
                } else if(flags & O_CREAT) {
@@ -354,8 +354,8 @@ static NTSTATUS open_file(files_struct *fsp,
                           O_CREAT doesn't create the file if we have write
                           access into the directory.
                        */
-                       flags &= ~O_CREAT;
-                       local_flags &= ~O_CREAT;
+                       flags &= ~(O_CREAT|O_EXCL);
+                       local_flags &= ~(O_CREAT|O_EXCL);
                }
        }
 
@@ -396,7 +396,7 @@ static NTSTATUS open_file(files_struct *fsp,
                 * open flags. JRA.
                 */
 
-               if (file_existed && S_ISFIFO(psbuf->st_mode)) {
+               if (file_existed && S_ISFIFO(psbuf->st_ex_mode)) {
                        local_flags |= O_NONBLOCK;
                }
 #endif
@@ -498,7 +498,7 @@ static NTSTATUS open_file(files_struct *fsp,
                                        }
                                } else if (NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_NOT_FOUND) &&
                                                        fsp->posix_open &&
-                                                       S_ISLNK(psbuf->st_mode)) {
+                                                       S_ISLNK(psbuf->st_ex_mode)) {
                                        /* This is a POSIX stat open for delete
                                         * or rename on a symlink that points
                                         * nowhere. Allow. */
@@ -543,13 +543,13 @@ static NTSTATUS open_file(files_struct *fsp,
         * so catch a directory open and return an EISDIR. JRA.
         */
 
-       if(S_ISDIR(psbuf->st_mode)) {
+       if(S_ISDIR(psbuf->st_ex_mode)) {
                fd_close(fsp);
                errno = EISDIR;
                return NT_STATUS_FILE_IS_A_DIRECTORY;
        }
 
-       fsp->mode = psbuf->st_mode;
+       fsp->mode = psbuf->st_ex_mode;
        fsp->file_id = vfs_file_id_from_sbuf(conn, psbuf);
        fsp->vuid = req ? req->vuid : UID_FIELD_INVALID;
        fsp->file_pid = req ? req->smbpid : 0;
@@ -1033,15 +1033,6 @@ static void defer_open(struct share_mode_lock *lck,
                exit_server("push_deferred_smb_message failed");
        }
        add_deferred_open(lck, req->mid, request_time, state->id);
-
-       /*
-        * Push the MID of this packet on the signing queue.
-        * We only do this once, the first time we push the packet
-        * onto the deferred open queue, as this has a side effect
-        * of incrementing the response sequence number.
-        */
-
-       srv_defer_sign_response(req->mid);
 }
 
 
@@ -1592,7 +1583,7 @@ static NTSTATUS open_file_ntcreate(connection_struct *conn,
                                DEBUG(5,("open_file_ntcreate: FILE_CREATE "
                                         "requested for file %s and file "
                                         "already exists.\n", fname ));
-                               if (S_ISDIR(psbuf->st_mode)) {
+                               if (S_ISDIR(psbuf->st_ex_mode)) {
                                        errno = EISDIR;
                                } else {
                                        errno = EEXIST;
@@ -1619,13 +1610,13 @@ static NTSTATUS open_file_ntcreate(connection_struct *conn,
                             (create_disposition == FILE_OVERWRITE_IF))) {
                if (!open_match_attributes(conn, fname,
                                           existing_dos_attributes,
-                                          new_dos_attributes, psbuf->st_mode,
+                                          new_dos_attributes, psbuf->st_ex_mode,
                                           unx_mode, &new_unx_mode)) {
                        DEBUG(5,("open_file_ntcreate: attributes missmatch "
                                 "for file %s (%x %x) (0%o, 0%o)\n",
                                 fname, existing_dos_attributes,
                                 new_dos_attributes,
-                                (unsigned int)psbuf->st_mode,
+                                (unsigned int)psbuf->st_ex_mode,
                                 (unsigned int)unx_mode ));
                        errno = EACCES;
                        return NT_STATUS_ACCESS_DENIED;
@@ -1724,7 +1715,7 @@ static NTSTATUS open_file_ntcreate(connection_struct *conn,
        }
 
        if (file_existed) {
-               struct timespec old_write_time = get_mtimespec(psbuf);
+               struct timespec old_write_time = psbuf->st_ex_mtime;
                id = vfs_file_id_from_sbuf(conn, psbuf);
 
                lck = get_share_mode_lock(talloc_tos(), id,
@@ -1928,7 +1919,7 @@ static NTSTATUS open_file_ntcreate(connection_struct *conn,
        }
 
        if (!file_existed) {
-               struct timespec old_write_time = get_mtimespec(psbuf);
+               struct timespec old_write_time = psbuf->st_ex_mtime;
                /*
                 * Deal with the race condition where two smbd's detect the
                 * file doesn't exist and do the create at the same time. One
@@ -2143,7 +2134,7 @@ static NTSTATUS open_file_ntcreate(connection_struct *conn,
                                            new_dos_attributes | aARCH,
                                            &tmp_sbuf, parent_dir,
                                            true) == 0) {
-                                       unx_mode = tmp_sbuf.st_mode;
+                                       unx_mode = tmp_sbuf.st_ex_mode;
                                }
                        }
                }
@@ -2211,6 +2202,7 @@ NTSTATUS open_file_fchmod(struct smb_request *req, connection_struct *conn,
                          const char *fname,
                          SMB_STRUCT_STAT *psbuf, files_struct **result)
 {
+       struct smb_filename *smb_fname = NULL;
        files_struct *fsp = NULL;
        NTSTATUS status;
 
@@ -2223,12 +2215,17 @@ NTSTATUS open_file_fchmod(struct smb_request *req, connection_struct *conn,
                return status;
        }
 
-       status = SMB_VFS_CREATE_FILE(
+       status = create_synthetic_smb_fname_split(talloc_tos(), fname, psbuf,
+                                                 &smb_fname);
+       if (!NT_STATUS_IS_OK(status)) {
+               return status;
+       }
+
+        status = SMB_VFS_CREATE_FILE(
                conn,                                   /* conn */
                NULL,                                   /* req */
                0,                                      /* root_dir_fid */
-               fname,                                  /* fname */
-               0,                                      /* create_file_flags */
+               smb_fname,                              /* fname */
                FILE_WRITE_DATA,                        /* access_mask */
                (FILE_SHARE_READ | FILE_SHARE_WRITE |   /* share_access */
                    FILE_SHARE_DELETE),
@@ -2240,8 +2237,10 @@ NTSTATUS open_file_fchmod(struct smb_request *req, connection_struct *conn,
                NULL,                                   /* sd */
                NULL,                                   /* ea_list */
                &fsp,                                   /* result */
-               NULL,                                   /* pinfo */
-               psbuf);                                 /* psbuf */
+               NULL);                                  /* psbuf */
+
+       *psbuf = smb_fname->st;
+       TALLOC_FREE(smb_fname);
 
        /*
         * This is not a user visible file open.
@@ -2314,7 +2313,7 @@ static NTSTATUS mkdir_internal(connection_struct *conn,
                return map_nt_error_from_unix(errno);
        }
 
-       if (!S_ISDIR(psbuf->st_mode)) {
+       if (!S_ISDIR(psbuf->st_ex_mode)) {
                DEBUG(0, ("Directory just '%s' created is not a directory\n",
                          name));
                return NT_STATUS_ACCESS_DENIED;
@@ -2340,9 +2339,9 @@ static NTSTATUS mkdir_internal(connection_struct *conn,
                 * Consider bits automagically set by UNIX, i.e. SGID bit from parent
                 * dir.
                 */
-               if (mode & ~(S_IRWXU|S_IRWXG|S_IRWXO) && (mode & ~psbuf->st_mode)) {
+               if (mode & ~(S_IRWXU|S_IRWXG|S_IRWXO) && (mode & ~psbuf->st_ex_mode)) {
                        SMB_VFS_CHMOD(conn, name,
-                                     psbuf->st_mode | (mode & ~psbuf->st_mode));
+                                     psbuf->st_ex_mode | (mode & ~psbuf->st_ex_mode));
                }
        }
 
@@ -2409,9 +2408,9 @@ static NTSTATUS open_directory(connection_struct *conn,
        }
 
        /* We need to support SeSecurityPrivilege for this. */
-       if (access_mask & SEC_RIGHT_SYSTEM_SECURITY) {
+       if (access_mask & SEC_FLAG_SYSTEM_SECURITY) {
                DEBUG(10, ("open_directory: open on %s "
-                       "failed - SEC_RIGHT_SYSTEM_SECURITY denied.\n",
+                       "failed - SEC_FLAG_SYSTEM_SECURITY denied.\n",
                        fname));
                return NT_STATUS_PRIVILEGE_NOT_HELD;
        }
@@ -2484,7 +2483,7 @@ static NTSTATUS open_directory(connection_struct *conn,
                        return NT_STATUS_INVALID_PARAMETER;
        }
 
-       if(!S_ISDIR(psbuf->st_mode)) {
+       if(!S_ISDIR(psbuf->st_ex_mode)) {
                DEBUG(5,("open_directory: %s is not a directory !\n",
                         fname ));
                return NT_STATUS_NOT_A_DIRECTORY;
@@ -2533,7 +2532,7 @@ static NTSTATUS open_directory(connection_struct *conn,
         * Setup the files_struct for it.
         */
        
-       fsp->mode = psbuf->st_mode;
+       fsp->mode = psbuf->st_ex_mode;
        fsp->file_id = vfs_file_id_from_sbuf(conn, psbuf);
        fsp->vuid = req ? req->vuid : UID_FIELD_INVALID;
        fsp->file_pid = req ? req->smbpid : 0;
@@ -2556,7 +2555,7 @@ static NTSTATUS open_directory(connection_struct *conn,
 
        string_set(&fsp->fsp_name,fname);
 
-       mtimespec = get_mtimespec(psbuf);
+       mtimespec = psbuf->st_ex_mtime;
 
        lck = get_share_mode_lock(talloc_tos(), fsp->file_id,
                                  conn->connectpath,
@@ -2607,20 +2606,17 @@ static NTSTATUS open_directory(connection_struct *conn,
        return NT_STATUS_OK;
 }
 
-NTSTATUS create_directory(connection_struct *conn, struct smb_request *req, const char *directory)
+NTSTATUS create_directory(connection_struct *conn, struct smb_request *req,
+                         struct smb_filename *smb_dname)
 {
        NTSTATUS status;
-       SMB_STRUCT_STAT sbuf;
        files_struct *fsp;
 
-       SET_STAT_INVALID(sbuf);
-       
        status = SMB_VFS_CREATE_FILE(
                conn,                                   /* conn */
                req,                                    /* req */
                0,                                      /* root_dir_fid */
-               directory,                              /* fname */
-               0,                                      /* create_file_flags */
+               smb_dname,                              /* fname */
                FILE_READ_ATTRIBUTES,                   /* access_mask */
                FILE_SHARE_NONE,                        /* share_access */
                FILE_CREATE,                            /* create_disposition*/
@@ -2631,8 +2627,7 @@ NTSTATUS create_directory(connection_struct *conn, struct smb_request *req, cons
                NULL,                                   /* sd */
                NULL,                                   /* ea_list */
                &fsp,                                   /* result */
-               NULL,                                   /* pinfo */
-               &sbuf);                                 /* psbuf */
+               NULL);                                  /* pinfo */
 
        if (NT_STATUS_IS_OK(status)) {
                close_file(req, fsp, NORMAL_CLOSE);
@@ -2791,7 +2786,9 @@ NTSTATUS open_streams_for_delete(connection_struct *conn,
        }
 
        for (i=0; i<num_streams; i++) {
-               char *streamname;
+               struct smb_filename *smb_fname = NULL;
+               char *streamname = NULL;
+               SMB_STRUCT_STAT sbuf;
 
                if (strequal(stream_info[i].name, "::$DATA")) {
                        streams[i] = NULL;
@@ -2800,10 +2797,21 @@ NTSTATUS open_streams_for_delete(connection_struct *conn,
 
                streamname = talloc_asprintf(talloc_tos(), "%s%s", fname,
                                             stream_info[i].name);
-
                if (streamname == NULL) {
                        DEBUG(0, ("talloc_aprintf failed\n"));
                        status = NT_STATUS_NO_MEMORY;
+               }
+
+               if (SMB_VFS_STAT(conn, streamname, &sbuf) == -1) {
+                       SET_STAT_INVALID(sbuf);
+               }
+
+               TALLOC_FREE(streamname);
+
+               status = create_synthetic_smb_fname(talloc_tos(), fname,
+                                                   stream_info[i].name,
+                                                   &sbuf, &smb_fname);
+               if (!NT_STATUS_IS_OK(status)) {
                        goto fail;
                }
 
@@ -2811,8 +2819,7 @@ NTSTATUS open_streams_for_delete(connection_struct *conn,
                         conn,                  /* conn */
                         NULL,                  /* req */
                         0,                     /* root_dir_fid */
-                        streamname,            /* fname */
-                        0,                     /* create_file_flags */
+                        smb_fname,             /* fname */
                         DELETE_ACCESS,         /* access_mask */
                         (FILE_SHARE_READ |     /* share_access */
                             FILE_SHARE_WRITE | FILE_SHARE_DELETE),
@@ -2824,16 +2831,17 @@ NTSTATUS open_streams_for_delete(connection_struct *conn,
                         NULL,                  /* sd */
                         NULL,                  /* ea_list */
                         &streams[i],           /* result */
-                        NULL,                  /* pinfo */
-                        NULL);                 /* psbuf */
-
-               TALLOC_FREE(streamname);
+                        NULL);                 /* pinfo */
 
                if (!NT_STATUS_IS_OK(status)) {
                        DEBUG(10, ("Could not open stream %s: %s\n",
-                                  streamname, nt_errstr(status)));
+                                  smb_fname_str_dbg(smb_fname),
+                                  nt_errstr(status)));
+
+                       TALLOC_FREE(smb_fname);
                        break;
                }
+               TALLOC_FREE(smb_fname);
        }
 
        /*
@@ -2955,7 +2963,7 @@ static NTSTATUS create_file_unixpath(connection_struct *conn,
 
 #if 0
        /* We need to support SeSecurityPrivilege for this. */
-       if ((access_mask & SEC_RIGHT_SYSTEM_SECURITY) &&
+       if ((access_mask & SEC_FLAG_SYSTEM_SECURITY) &&
            !user_has_privileges(current_user.nt_user_token,
                                 &se_security)) {
                status = NT_STATUS_PRIVILEGE_NOT_HELD;
@@ -2963,7 +2971,7 @@ static NTSTATUS create_file_unixpath(connection_struct *conn,
        }
 #else
        /* We need to support SeSecurityPrivilege for this. */
-       if (access_mask & SEC_RIGHT_SYSTEM_SECURITY) {
+       if (access_mask & SEC_FLAG_SYSTEM_SECURITY) {
                status = NT_STATUS_PRIVILEGE_NOT_HELD;
                goto fail;
        }
@@ -3170,7 +3178,7 @@ static NTSTATUS create_file_unixpath(connection_struct *conn,
                }
        }
 
-       if (!fsp->is_directory && S_ISDIR(sbuf.st_mode)) {
+       if (!fsp->is_directory && S_ISDIR(sbuf.st_ex_mode)) {
                status = NT_STATUS_ACCESS_DENIED;
                goto fail;
        }
@@ -3178,7 +3186,7 @@ static NTSTATUS create_file_unixpath(connection_struct *conn,
        /* Save the requested allocation size. */
        if ((info == FILE_WAS_CREATED) || (info == FILE_WAS_OVERWRITTEN)) {
                if (allocation_size
-                   && (allocation_size > sbuf.st_size)) {
+                   && (allocation_size > sbuf.st_ex_size)) {
                        fsp->initial_allocation_size = smb_roundup(
                                fsp->conn, allocation_size);
                        if (fsp->is_directory) {
@@ -3193,7 +3201,7 @@ static NTSTATUS create_file_unixpath(connection_struct *conn,
                        }
                } else {
                        fsp->initial_allocation_size = smb_roundup(
-                               fsp->conn, (uint64_t)sbuf.st_size);
+                               fsp->conn, (uint64_t)sbuf.st_ex_size);
                }
        }
 
@@ -3327,8 +3335,7 @@ NTSTATUS get_relative_fid_filename(connection_struct *conn,
 NTSTATUS create_file_default(connection_struct *conn,
                             struct smb_request *req,
                             uint16_t root_dir_fid,
-                            const char *fname,
-                            uint32_t create_file_flags,
+                            struct smb_filename *smb_fname,
                             uint32_t access_mask,
                             uint32_t share_access,
                             uint32_t create_disposition,
@@ -3340,13 +3347,11 @@ NTSTATUS create_file_default(connection_struct *conn,
                             struct ea_list *ea_list,
 
                             files_struct **result,
-                            int *pinfo,
-                            SMB_STRUCT_STAT *psbuf)
+                            int *pinfo)
 {
-       struct case_semantics_state *case_state = NULL;
-       SMB_STRUCT_STAT sbuf;
        int info = FILE_WAS_OPENED;
        files_struct *fsp = NULL;
+       char *fname = NULL;
        NTSTATUS status;
 
        DEBUG(10,("create_file: access_mask = 0x%x "
@@ -3354,7 +3359,7 @@ NTSTATUS create_file_default(connection_struct *conn,
                  "create_disposition = 0x%x create_options = 0x%x "
                  "oplock_request = 0x%x "
                  "root_dir_fid = 0x%x, ea_list = 0x%p, sd = 0x%p, "
-                 "create_file_flags = 0x%x, fname = %s\n",
+                 "fname = %s\n",
                  (unsigned int)access_mask,
                  (unsigned int)file_attributes,
                  (unsigned int)share_access,
@@ -3362,7 +3367,37 @@ NTSTATUS create_file_default(connection_struct *conn,
                  (unsigned int)create_options,
                  (unsigned int)oplock_request,
                  (unsigned int)root_dir_fid,
-                 ea_list, sd, create_file_flags, fname));
+                 ea_list, sd, smb_fname_str_dbg(smb_fname)));
+
+       /* MSDFS pathname processing must be done FIRST.
+          MSDFS pathnames containing IPv6 addresses can
+          be confused with NTFS stream names (they contain
+          ":" characters. JRA. */
+
+       if ((req != NULL) && (req->flags2 & FLAGS2_DFS_PATHNAMES)) {
+               char *resolved_fname;
+
+               status = resolve_dfspath(talloc_tos(), conn, true,
+                                        smb_fname->base_name,
+                                        &resolved_fname);
+
+               if (!NT_STATUS_IS_OK(status)) {
+                       /*
+                        * For PATH_NOT_COVERED we had
+                        * reply_botherror(req, NT_STATUS_PATH_NOT_COVERED,
+                        *                 ERRSRV, ERRbadpath);
+                        * Need to fix in callers
+                        */
+                       goto fail;
+               }
+               TALLOC_FREE(smb_fname->base_name);
+               smb_fname->base_name = resolved_fname;
+       }
+
+       status = get_full_smb_filename(talloc_tos(), smb_fname, &fname);
+       if (!NT_STATUS_IS_OK(status)) {
+               goto fail;
+       }
 
        /*
         * Calculate the filename from the root_dir_if if necessary.
@@ -3409,7 +3444,7 @@ NTSTATUS create_file_default(connection_struct *conn,
                                goto fail;
                        }
 
-                       ZERO_STRUCT(sbuf);
+                       ZERO_STRUCT(smb_fname->st);
                        goto done;
                }
 
@@ -3419,56 +3454,6 @@ NTSTATUS create_file_default(connection_struct *conn,
                }
        }
 
-       if ((req != NULL) && (req->flags2 & FLAGS2_DFS_PATHNAMES)) {
-               char *resolved_fname;
-
-               status = resolve_dfspath(talloc_tos(), conn, true, fname,
-                                        &resolved_fname);
-
-               if (!NT_STATUS_IS_OK(status)) {
-                       /*
-                        * For PATH_NOT_COVERED we had
-                        * reply_botherror(req, NT_STATUS_PATH_NOT_COVERED,
-                        *                 ERRSRV, ERRbadpath);
-                        * Need to fix in callers
-                        */
-                       goto fail;
-               }
-               fname = resolved_fname;
-       }
-
-       /*
-        * Check if POSIX semantics are wanted.
-        */
-
-       if (file_attributes & FILE_FLAG_POSIX_SEMANTICS) {
-               case_state = set_posix_case_semantics(talloc_tos(), conn);
-       }
-
-       if (create_file_flags & CFF_DOS_PATH) {
-               char *converted_fname;
-
-               SET_STAT_INVALID(sbuf);
-
-               status = unix_convert(talloc_tos(), conn, fname, False,
-                                     &converted_fname, NULL, &sbuf);
-               if (!NT_STATUS_IS_OK(status)) {
-                       goto fail;
-               }
-               fname = converted_fname;
-       } else {
-               if (psbuf != NULL) {
-                       sbuf = *psbuf;
-               } else {
-                       if (SMB_VFS_STAT(conn, fname, &sbuf) == -1) {
-                               SET_STAT_INVALID(sbuf);
-                       }
-               }
-
-       }
-
-       TALLOC_FREE(case_state);
-
        /* All file access must go through check_name() */
 
        status = check_name(conn, fname);
@@ -3480,7 +3465,7 @@ NTSTATUS create_file_default(connection_struct *conn,
                conn, req, fname, access_mask, share_access,
                create_disposition, create_options, file_attributes,
                oplock_request, allocation_size, sd, ea_list,
-               &fsp, &info, &sbuf);
+               &fsp, &info, &smb_fname->st);
 
        if (!NT_STATUS_IS_OK(status)) {
                goto fail;
@@ -3493,9 +3478,6 @@ NTSTATUS create_file_default(connection_struct *conn,
        if (pinfo != NULL) {
                *pinfo = info;
        }
-       if (psbuf != NULL) {
-               *psbuf = sbuf;
-       }
        return NT_STATUS_OK;
 
  fail: