]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3: smbd: In mkdir_internal() assign the passed in parent_dir_fname_in, smb_fname_atn...
authorJeremy Allison <jra@samba.org>
Mon, 24 May 2021 23:33:58 +0000 (16:33 -0700)
committerRalph Boehme <slow@samba.org>
Wed, 9 Jun 2021 13:14:30 +0000 (13:14 +0000)
We don't need the parent_pathref() and more, and as we don't
own parent_dir_fname anymore, don't free it on exit.

Next step will be to remove the local variables.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
source3/smbd/open.c

index a3e104d9c6a56cf870601db1f28c703f5e10fa5c..a50f99e66309d3a78cd8a510cb2c989331725ee4 100644 (file)
@@ -4409,8 +4409,8 @@ static NTSTATUS mkdir_internal(connection_struct *conn,
        const struct loadparm_substitution *lp_sub =
                loadparm_s3_global_substitution();
        mode_t mode;
-       struct smb_filename *parent_dir_fname = NULL;
-       struct smb_filename *base_name = NULL;
+       struct smb_filename *parent_dir_fname = parent_dir_fname_in;
+       struct smb_filename *base_name = smb_fname_atname_in;
        NTSTATUS status;
        bool posix_open = false;
        bool need_re_stat = false;
@@ -4423,15 +4423,6 @@ static NTSTATUS mkdir_internal(connection_struct *conn,
                return NT_STATUS_ACCESS_DENIED;
        }
 
-       status = parent_pathref(talloc_tos(),
-                               conn->cwd_fsp,
-                               smb_dname,
-                               &parent_dir_fname,
-                               &base_name);
-       if (!NT_STATUS_IS_OK(status)) {
-               return status;
-       }
-
        if (file_attributes & FILE_FLAG_POSIX_SEMANTICS) {
                posix_open = true;
                mode = (mode_t)(file_attributes & ~FILE_FLAG_POSIX_SEMANTICS);
@@ -4449,7 +4440,6 @@ static NTSTATUS mkdir_internal(connection_struct *conn,
                        smb_fname_str_dbg(parent_dir_fname),
                        smb_dname->base_name,
                        nt_errstr(status));
-               TALLOC_FREE(parent_dir_fname);
                return status;
        }
 
@@ -4466,7 +4456,6 @@ static NTSTATUS mkdir_internal(connection_struct *conn,
                              base_name,
                              mode);
        if (ret != 0) {
-               TALLOC_FREE(parent_dir_fname);
                return map_nt_error_from_unix(errno);
        }
 
@@ -4478,7 +4467,6 @@ static NTSTATUS mkdir_internal(connection_struct *conn,
 
        status = fd_openat(conn->cwd_fsp, smb_dname, fsp, O_RDONLY | O_DIRECTORY, 0);
        if (!NT_STATUS_IS_OK(status)) {
-               TALLOC_FREE(parent_dir_fname);
                return status;
        }
 
@@ -4488,14 +4476,12 @@ static NTSTATUS mkdir_internal(connection_struct *conn,
        if (SMB_VFS_FSTAT(fsp, &smb_dname->st) == -1) {
                DEBUG(2, ("Could not stat directory '%s' just created: %s\n",
                          smb_fname_str_dbg(smb_dname), strerror(errno)));
-               TALLOC_FREE(parent_dir_fname);
                return map_nt_error_from_unix(errno);
        }
 
        if (!S_ISDIR(smb_dname->st.st_ex_mode)) {
                DEBUG(0, ("Directory '%s' just created is not a directory !\n",
                          smb_fname_str_dbg(smb_dname)));
-               TALLOC_FREE(parent_dir_fname);
                return NT_STATUS_NOT_A_DIRECTORY;
        }
 
@@ -4547,8 +4533,6 @@ static NTSTATUS mkdir_internal(connection_struct *conn,
                need_re_stat = true;
        }
 
-       TALLOC_FREE(parent_dir_fname);
-
        if (need_re_stat) {
                if (SMB_VFS_FSTAT(fsp, &smb_dname->st) == -1) {
                        DEBUG(2, ("Could not stat directory '%s' just created: %s\n",