]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3: smbd: Inside rename_internals() remove '{ ... }' block around singleton rename...
authorJeremy Allison <jra@samba.org>
Thu, 2 Dec 2021 00:35:54 +0000 (16:35 -0800)
committerRalph Boehme <slow@samba.org>
Thu, 9 Dec 2021 18:06:35 +0000 (18:06 +0000)
Best viewed with 'git show -b'

As we're touching the DEBUG() code, change it to modern DBG_NOTICE().

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

index 7e829f1aa00274ce6ec9efeef6084e34f3fa73e2..5b0686019b09f7e9cad57e7a50feffc398883593 100644 (file)
@@ -7716,6 +7716,7 @@ NTSTATUS rename_internals(TALLOC_CTX *ctx,
        int create_options = 0;
        struct smb2_create_blobs *posx = NULL;
        int rc;
+       struct files_struct *fsp = NULL;
        bool posix_pathname = (smb_fname_src->flags & SMB_FILENAME_POSIX_PATH);
        bool case_sensitive = posix_pathname ? true : conn->case_sensitive;
        bool case_preserve = posix_pathname ? true : conn->case_preserve;
@@ -7768,70 +7769,67 @@ NTSTATUS rename_internals(TALLOC_CTX *ctx,
                }
        }
 
-       {
-               files_struct *fsp;
+       /*
+        * Only one file needs to be renamed. Append the mask back
+        * onto the directory.
+        */
+       TALLOC_FREE(smb_fname_src->base_name);
+       if (ISDOT(fname_src_dir)) {
+               /* Ensure we use canonical names on open. */
+               smb_fname_src->base_name = talloc_asprintf(smb_fname_src,
+                                               "%s",
+                                               fname_src_mask);
+       } else {
+               smb_fname_src->base_name = talloc_asprintf(smb_fname_src,
+                                               "%s/%s",
+                                               fname_src_dir,
+                                               fname_src_mask);
+       }
+       if (!smb_fname_src->base_name) {
+               status = NT_STATUS_NO_MEMORY;
+               goto out;
+       }
 
-               /*
-                * Only one file needs to be renamed. Append the mask back
-                * onto the directory.
-                */
-               TALLOC_FREE(smb_fname_src->base_name);
-               if (ISDOT(fname_src_dir)) {
-                       /* Ensure we use canonical names on open. */
-                       smb_fname_src->base_name = talloc_asprintf(smb_fname_src,
-                                                       "%s",
-                                                       fname_src_mask);
-               } else {
-                       smb_fname_src->base_name = talloc_asprintf(smb_fname_src,
-                                                       "%s/%s",
-                                                       fname_src_dir,
-                                                       fname_src_mask);
-               }
-               if (!smb_fname_src->base_name) {
-                       status = NT_STATUS_NO_MEMORY;
-                       goto out;
-               }
+       DBG_NOTICE("case_sensitive = %d, "
+                 "case_preserve = %d, short case preserve = %d, "
+                 "directory = %s, newname = %s, "
+                 "last_component_dest = %s\n",
+                 case_sensitive, case_preserve,
+                 short_case_preserve,
+                 smb_fname_str_dbg(smb_fname_src),
+                 smb_fname_str_dbg(smb_fname_dst),
+                 dst_original_lcomp);
 
-               DEBUG(3, ("rename_internals: case_sensitive = %d, "
-                         "case_preserve = %d, short case preserve = %d, "
-                         "directory = %s, newname = %s, "
-                         "last_component_dest = %s\n",
-                         case_sensitive, case_preserve,
-                         short_case_preserve,
-                         smb_fname_str_dbg(smb_fname_src),
-                         smb_fname_str_dbg(smb_fname_dst),
-                         dst_original_lcomp));
+       ZERO_STRUCT(smb_fname_src->st);
 
-               ZERO_STRUCT(smb_fname_src->st);
+       rc = vfs_stat(conn, smb_fname_src);
+       if (rc == -1) {
+               status = map_nt_error_from_unix_common(errno);
+               goto out;
+       }
 
-               rc = vfs_stat(conn, smb_fname_src);
-               if (rc == -1) {
-                       status = map_nt_error_from_unix_common(errno);
+       status = openat_pathref_fsp(conn->cwd_fsp, smb_fname_src);
+       if (!NT_STATUS_IS_OK(status)) {
+               if (!NT_STATUS_EQUAL(status,
+                               NT_STATUS_OBJECT_NAME_NOT_FOUND)) {
                        goto out;
                }
-
-               status = openat_pathref_fsp(conn->cwd_fsp, smb_fname_src);
-               if (!NT_STATUS_IS_OK(status)) {
-                       if (!NT_STATUS_EQUAL(status,
-                                       NT_STATUS_OBJECT_NAME_NOT_FOUND)) {
-                               goto out;
-                       }
-                       /*
-                        * Possible symlink src.
-                        */
-                       if (!(smb_fname_src->flags & SMB_FILENAME_POSIX_PATH)) {
-                               goto out;
-                       }
-                       if (!S_ISLNK(smb_fname_src->st.st_ex_mode)) {
-                               goto out;
-                       }
+               /*
+                * Possible symlink src.
+                */
+               if (!(smb_fname_src->flags & SMB_FILENAME_POSIX_PATH)) {
+                       goto out;
                }
-
-               if (S_ISDIR(smb_fname_src->st.st_ex_mode)) {
-                       create_options |= FILE_DIRECTORY_FILE;
+               if (!S_ISLNK(smb_fname_src->st.st_ex_mode)) {
+                       goto out;
                }
+       }
 
-               status = SMB_VFS_CREATE_FILE(
+       if (S_ISDIR(smb_fname_src->st.st_ex_mode)) {
+               create_options |= FILE_DIRECTORY_FILE;
+       }
+
+       status = SMB_VFS_CREATE_FILE(
                        conn,                           /* conn */
                        req,                            /* req */
                        smb_fname_src,                  /* fname */
@@ -7852,27 +7850,25 @@ NTSTATUS rename_internals(TALLOC_CTX *ctx,
                        posx,                           /* in_context_blobs */
                        NULL);                          /* out_context_blobs */
 
-               if (!NT_STATUS_IS_OK(status)) {
-                       DEBUG(3, ("Could not open rename source %s: %s\n",
-                                 smb_fname_str_dbg(smb_fname_src),
-                                 nt_errstr(status)));
-                       goto out;
-               }
+       if (!NT_STATUS_IS_OK(status)) {
+               DBG_NOTICE("Could not open rename source %s: %s\n",
+                         smb_fname_str_dbg(smb_fname_src),
+                         nt_errstr(status));
+               goto out;
+       }
 
-               status = rename_internals_fsp(conn,
+       status = rename_internals_fsp(conn,
                                        fsp,
                                        smb_fname_dst,
                                        dst_original_lcomp,
                                        attrs,
                                        replace_if_exists);
 
-               close_file(req, fsp, NORMAL_CLOSE);
+       close_file(req, fsp, NORMAL_CLOSE);
 
-               DEBUG(3, ("rename_internals: Error %s rename %s -> %s\n",
-                         nt_errstr(status), smb_fname_str_dbg(smb_fname_src),
-                         smb_fname_str_dbg(smb_fname_dst)));
-
-       }
+       DBG_NOTICE("Error %s rename %s -> %s\n",
+                 nt_errstr(status), smb_fname_str_dbg(smb_fname_src),
+                 smb_fname_str_dbg(smb_fname_dst));
 
  out:
        TALLOC_FREE(posx);