smbd: switch caller of fd_openat() to fd_open()
authorRalph Boehme <slow@samba.org>
Wed, 30 Sep 2020 14:26:29 +0000 (16:26 +0200)
committerJeremy Allison <jra@samba.org>
Fri, 2 Oct 2020 19:39:43 +0000 (19:39 +0000)
fd_openat() was added to be used with real dirfsp, but after adding pathref fd
support we will never use this.

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

index 2265d7c51025f94c0fb1a06539cb55225ac54089..8f3ad80389c2b34a625639511149c62aa94ea04a 100644 (file)
@@ -815,7 +815,7 @@ NTSTATUS vfs_default_durable_reconnect(struct connection_struct *conn,
                flags = O_RDONLY;
        }
 
-       status = fd_openat(fsp, flags, 0);
+       status = fd_open(fsp, flags, 0);
        if (!NT_STATUS_IS_OK(status)) {
                TALLOC_FREE(lck);
                DEBUG(1, ("vfs_default_durable_reconnect: failed to open "
index 17d6823bcb8ae0ce91d977f00e3ccd26dfc9a0c1..88354ef8bb2e98f8ec6639ceba226ecb5d4e3b39 100644 (file)
@@ -824,70 +824,6 @@ NTSTATUS fd_open(files_struct *fsp,
        return status;
 }
 
-NTSTATUS fd_openat(files_struct *fsp,
-                  int flags,
-                  mode_t mode)
-{
-       NTSTATUS status = NT_STATUS_OK;
-       int saved_errno = 0;
-
-       if (fsp->dirfsp == fsp->conn->cwd_fsp) {
-               return fd_open(fsp, flags, mode);
-       }
-
-       /*
-        * Never follow symlinks at this point, filename_convert() should have
-        * resolved any symlink.
-        */
-
-       flags |= O_NOFOLLOW;
-
-       /*
-        * Only follow symlinks within a share
-        * definition.
-        */
-       fsp->fh->fd = SMB_VFS_OPENAT(fsp->conn,
-                                    fsp->dirfsp,
-                                    fsp->fsp_name,
-                                    fsp,
-                                    flags,
-                                    mode);
-       if (fsp->fh->fd == -1) {
-               saved_errno = errno;
-       }
-       if (saved_errno != 0) {
-               errno = saved_errno;
-       }
-
-       if (fsp->fh->fd == -1) {
-               int posix_errno = link_errno_convert(errno);
-
-               status = map_nt_error_from_unix(posix_errno);
-
-               if (errno == EMFILE) {
-                       static time_t last_warned = 0L;
-
-                       if (time((time_t *) NULL) > last_warned) {
-                               DEBUG(0,("Too many open files, unable "
-                                       "to open more!  smbd's max "
-                                       "open files = %d\n",
-                                       lp_max_open_files()));
-                               last_warned = time((time_t *) NULL);
-                       }
-               }
-
-               DBG_DEBUG("name %s, flags = 0%o mode = 0%o, fd = %d. %s\n",
-                         fsp_str_dbg(fsp), flags, (int)mode,
-                         fsp->fh->fd, strerror(errno));
-               return status;
-       }
-
-       DBG_DEBUG("name %s, flags = 0%o mode = 0%o, fd = %d\n",
-                 fsp_str_dbg(fsp), flags, (int)mode, fsp->fh->fd);
-
-       return status;
-}
-
 /****************************************************************************
  Close the file associated with a fsp.
 ****************************************************************************/
@@ -1108,7 +1044,7 @@ static NTSTATUS fd_open_atomic(files_struct *fsp,
                /*
                 * We're not creating the file, just pass through.
                 */
-               status = fd_openat(fsp, flags, mode);
+               status = fd_open(fsp, flags, mode);
                *file_created = false;
                return status;
        }
@@ -1117,7 +1053,7 @@ static NTSTATUS fd_open_atomic(files_struct *fsp,
                /*
                 * Fail if already exists, just pass through.
                 */
-               status = fd_openat(fsp, flags, mode);
+               status = fd_open(fsp, flags, mode);
 
                /*
                 * Here we've opened with O_CREAT|O_EXCL. If that went
@@ -1157,7 +1093,7 @@ static NTSTATUS fd_open_atomic(files_struct *fsp,
                retry_status = NT_STATUS_OBJECT_NAME_COLLISION;
        }
 
-       status = fd_openat(fsp, curr_flags, mode);
+       status = fd_open(fsp, curr_flags, mode);
        if (NT_STATUS_IS_OK(status)) {
                *file_created = !file_existed;
                return NT_STATUS_OK;
@@ -1176,7 +1112,7 @@ static NTSTATUS fd_open_atomic(files_struct *fsp,
                        curr_flags = flags | O_EXCL;
                }
 
-               status = fd_openat(fsp, curr_flags, mode);
+               status = fd_open(fsp, curr_flags, mode);
        }
 
        *file_created = (NT_STATUS_IS_OK(status) && !file_existed);
@@ -4599,7 +4535,7 @@ static NTSTATUS open_directory(connection_struct *conn,
        flags |= O_DIRECTORY;
 #endif
 
-       status = fd_openat(fsp, flags, 0);
+       status = fd_open(fsp, flags, 0);
        if (!NT_STATUS_IS_OK(status)) {
                DBG_INFO("Could not open fd for "
                        "%s (%s)\n",
index a001c4834f47298bf39074142acdfd7b31fb6124..8c36f9ec01f975054d623793899a463ef8607326 100644 (file)
@@ -722,9 +722,6 @@ NTSTATUS check_parent_access(struct connection_struct *conn,
                                uint32_t access_mask);
 NTSTATUS fd_open(files_struct *fsp,
                 int flags, mode_t mode);
-NTSTATUS fd_openat(files_struct *fsp,
-                  int flags,
-                  mode_t mode);
 NTSTATUS fd_close(files_struct *fsp);
 void change_file_owner_to_parent(connection_struct *conn,
                                 struct smb_filename *inherit_from_dir,