s3: Make all callers of SMB_VFS_CREATEFILE call unix_convert first
[metze/samba/wip.git] / source3 / smbd / smb2_create.c
index e264afab1402b0bd7610082e7d04429d8c6316ac..73c7cec63a527b666c04cf2a56f34999ae894900 100644 (file)
@@ -252,6 +252,7 @@ static struct tevent_req *smbd_smb2_create_send(TALLOC_CTX *mem_ctx,
        files_struct *result;
        int info;
        SMB_STRUCT_STAT sbuf;
+       struct smb_filename *smb_fname = NULL;
 
        req = tevent_req_create(mem_ctx, &state,
                                struct smbd_smb2_create_state);
@@ -265,7 +266,7 @@ static struct tevent_req *smbd_smb2_create_send(TALLOC_CTX *mem_ctx,
 
        smbreq = smbd_smb2_fake_smb_request(smb2req);
        if (tevent_req_nomem(smbreq, req)) {
-               return tevent_req_post(req, ev);
+               goto out;
        }
 
        if (IS_IPC(smbreq->conn)) {
@@ -273,7 +274,7 @@ static struct tevent_req *smbd_smb2_create_send(TALLOC_CTX *mem_ctx,
 
                if (!lp_nt_pipe_support()) {
                        tevent_req_nterror(req, NT_STATUS_ACCESS_DENIED);
-                       return tevent_req_post(req, ev);
+                       goto out;
                }
 
                /* Strip \\ off the name. */
@@ -284,7 +285,7 @@ static struct tevent_req *smbd_smb2_create_send(TALLOC_CTX *mem_ctx,
                status = open_np_file(smbreq, pipe_name, &result);
                if (!NT_STATUS_IS_OK(status)) {
                        tevent_req_nterror(req, status);
-                       return tevent_req_post(req, ev);
+                       goto out;
                }
                info = FILE_WAS_OPENED;
                ZERO_STRUCT(sbuf);
@@ -292,7 +293,7 @@ static struct tevent_req *smbd_smb2_create_send(TALLOC_CTX *mem_ctx,
                status = file_new(smbreq, smbreq->conn, &result);
                if(!NT_STATUS_IS_OK(status)) {
                        tevent_req_nterror(req, status);
-                       return tevent_req_post(req, ev);
+                       goto out;
                }
 
                status = print_fsp_open(smbreq,
@@ -304,19 +305,32 @@ static struct tevent_req *smbd_smb2_create_send(TALLOC_CTX *mem_ctx,
                if (!NT_STATUS_IS_OK(status)) {
                        file_free(smbreq, result);
                        tevent_req_nterror(req, status);
-                       return tevent_req_post(req, ev);
+                       goto out;
                }
                info = FILE_WAS_CREATED;
        } else {
+               char *fname = NULL;
+
                /* these are ignored for SMB2 */
                in_create_options &= ~(0x10);/* NTCREATEX_OPTIONS_SYNC_ALERT */
                in_create_options &= ~(0x20);/* NTCREATEX_OPTIONS_ASYNC_ALERT */
 
+               status = unix_convert(talloc_tos(), smbreq->conn, in_name,
+                                     &smb_fname, 0);
+               if (!NT_STATUS_IS_OK(status)) {
+                       goto out;
+               }
+
+               status = get_full_smb_filename(talloc_tos(), smb_fname, &fname);
+               if (!NT_STATUS_IS_OK(status)) {
+                       goto out;
+               }
+
                status = SMB_VFS_CREATE_FILE(smbreq->conn,
                                             smbreq,
                                             0, /* root_dir_fid */
-                                            in_name,
-                                            CFF_DOS_PATH, /* create_file_flags */
+                                            fname,
+                                            0, /* create_file_flags */
                                             in_desired_access,
                                             in_share_access,
                                             in_create_disposition,
@@ -328,11 +342,12 @@ static struct tevent_req *smbd_smb2_create_send(TALLOC_CTX *mem_ctx,
                                             NULL, /* ea_list */
                                             &result,
                                             &info,
-                                            &sbuf);
+                                            &smb_fname->st);
                if (!NT_STATUS_IS_OK(status)) {
                        tevent_req_nterror(req, status);
-                       return tevent_req_post(req, ev);
+                       goto out;
                }
+               sbuf = smb_fname->st;
        }
 
        smb2req->compat_chain_fsp = smbreq->chain_fsp;
@@ -359,6 +374,8 @@ static struct tevent_req *smbd_smb2_create_send(TALLOC_CTX *mem_ctx,
        state->out_file_id_volatile = result->fnum;
 
        tevent_req_done(req);
+ out:
+       TALLOC_FREE(smb_fname);
        return tevent_req_post(req, ev);
 }