]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
smbd: Reduce indentation in check_reduced_name()
authorVolker Lendecke <vl@samba.org>
Fri, 12 Jun 2020 09:36:56 +0000 (11:36 +0200)
committerJeremy Allison <jra@samba.org>
Mon, 15 Jun 2020 17:59:39 +0000 (17:59 +0000)
No change in behaviour.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/smbd/vfs.c

index 85b23d35ba6c10924535b87441c18f0f717967b7..38b4070139d61885411b5553c8275b4d00f008f3 100644 (file)
@@ -1293,59 +1293,58 @@ NTSTATUS check_reduced_name(connection_struct *conn,
        resolved_fname = SMB_VFS_REALPATH(conn, ctx, smb_fname);
 
        if (resolved_fname == NULL) {
-               switch (errno) {
-                       case ENOTDIR:
-                               DEBUG(3,("check_reduced_name: Component not a "
-                                        "directory in getting realpath for "
-                                        "%s\n", fname));
-                               return NT_STATUS_OBJECT_PATH_NOT_FOUND;
-                       case ENOENT:
-                       {
-                               struct smb_filename *dir_fname = NULL;
-                               struct smb_filename *last_component = NULL;
-
-                               /* Last component didn't exist.
-                                  Remove it and try and canonicalise
-                                  the directory name. */
-
-                               ok = parent_smb_fname(ctx,
-                                                     smb_fname,
-                                                     &dir_fname,
-                                                     &last_component);
-                               if (!ok) {
-                                       return NT_STATUS_NO_MEMORY;
-                               }
+               struct smb_filename *dir_fname = NULL;
+               struct smb_filename *last_component = NULL;
+
+               if (errno == ENOTDIR) {
+                       DBG_NOTICE("Component not a directory in getting "
+                                  "realpath for %s\n",
+                                  fname);
+                       return NT_STATUS_OBJECT_PATH_NOT_FOUND;
+               }
+               if (errno != ENOENT) {
+                       NTSTATUS status = map_nt_error_from_unix(errno);
+                       DBG_NOTICE("couldn't get realpath for %s: %s\n",
+                                  fname,
+                                  strerror(errno));
+                       return status;
+               }
 
-                               resolved_fname = SMB_VFS_REALPATH(conn,
-                                                       ctx,
-                                                       dir_fname);
-                               if (resolved_fname == NULL) {
-                                       NTSTATUS status = map_nt_error_from_unix(errno);
-
-                                       if (errno == ENOENT || errno == ENOTDIR) {
-                                               status = NT_STATUS_OBJECT_PATH_NOT_FOUND;
-                                       }
-
-                                       DEBUG(3,("check_reduce_name: "
-                                                "couldn't get realpath for "
-                                                "%s (%s)\n",
-                                               smb_fname_str_dbg(dir_fname),
-                                               nt_errstr(status)));
-                                       return status;
-                               }
-                               resolved_name = talloc_asprintf(ctx,
+               /* errno == ENOENT */
+
+               /*
+                * Last component didn't exist. Remove it and try and
+                * canonicalise the directory name.
+                */
+
+               ok = parent_smb_fname(ctx,
+                                     smb_fname,
+                                     &dir_fname,
+                                     &last_component);
+               if (!ok) {
+                       return NT_STATUS_NO_MEMORY;
+               }
+
+               resolved_fname = SMB_VFS_REALPATH(conn, ctx, dir_fname);
+               if (resolved_fname == NULL) {
+                       NTSTATUS status = map_nt_error_from_unix(errno);
+
+                       if (errno == ENOENT || errno == ENOTDIR) {
+                               status = NT_STATUS_OBJECT_PATH_NOT_FOUND;
+                       }
+
+                       DBG_NOTICE("couldn't get realpath for "
+                                  "%s (%s)\n",
+                                  smb_fname_str_dbg(dir_fname),
+                                  nt_errstr(status));
+                       return status;
+               }
+               resolved_name = talloc_asprintf(ctx,
                                                "%s/%s",
                                                resolved_fname->base_name,
                                                last_component->base_name);
-                               if (resolved_name == NULL) {
-                                       return NT_STATUS_NO_MEMORY;
-                               }
-                               break;
-                       }
-                       default:
-                               DEBUG(3,("check_reduced_name: couldn't get "
-                                        "realpath for %s\n", fname));
-                               return map_nt_error_from_unix(errno);
+               if (resolved_name == NULL) {
+                       return NT_STATUS_NO_MEMORY;
                }
        } else {
                resolved_name = resolved_fname->base_name;