From: Ralph Boehme Date: Fri, 8 May 2020 14:32:56 +0000 (+0200) Subject: smbd: use fd_openat() X-Git-Tag: ldb-2.2.0~365 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=75d6943ed880019cca1192d4d4d62d5f27b97d2d;p=thirdparty%2Fsamba.git smbd: use fd_openat() This leaves basically two callers of fd_open(): * open_internal_dirfsp_at() * smbd_smb2_query_directory_send() Those will be the only codepaths that use full paths relative to the share root and so require and use the symlink race protection provided by non_widelink_open(). Of course, until we actuall start passing real dirfsps to fd_openat(), fd_openat() internally calls fd_open(). Signed-off-by: Ralph Boehme Reviewed-by: Jeremy Allison --- diff --git a/source3/smbd/durable.c b/source3/smbd/durable.c index 0b088523893..b71e06819d7 100644 --- a/source3/smbd/durable.c +++ b/source3/smbd/durable.c @@ -815,7 +815,7 @@ NTSTATUS vfs_default_durable_reconnect(struct connection_struct *conn, flags = O_RDONLY; } - status = fd_open(fsp, flags, 0 /* mode */); + status = fd_openat(fsp, flags, 0); if (!NT_STATUS_IS_OK(status)) { TALLOC_FREE(lck); DEBUG(1, ("vfs_default_durable_reconnect: failed to open " diff --git a/source3/smbd/open.c b/source3/smbd/open.c index a1d5f4b0c91..286f1b8e6f7 100644 --- a/source3/smbd/open.c +++ b/source3/smbd/open.c @@ -1116,7 +1116,7 @@ static NTSTATUS fd_open_atomic(files_struct *fsp, /* * We're not creating the file, just pass through. */ - status = fd_open(fsp, flags, mode); + status = fd_openat(fsp, flags, mode); *file_created = false; return status; } @@ -1125,7 +1125,7 @@ static NTSTATUS fd_open_atomic(files_struct *fsp, /* * Fail if already exists, just pass through. */ - status = fd_open(fsp, flags, mode); + status = fd_openat(fsp, flags, mode); /* * Here we've opened with O_CREAT|O_EXCL. If that went @@ -1165,7 +1165,7 @@ static NTSTATUS fd_open_atomic(files_struct *fsp, retry_status = NT_STATUS_OBJECT_NAME_COLLISION; } - status = fd_open(fsp, curr_flags, mode); + status = fd_openat(fsp, curr_flags, mode); if (NT_STATUS_IS_OK(status)) { *file_created = !file_existed; return NT_STATUS_OK; @@ -1184,7 +1184,7 @@ static NTSTATUS fd_open_atomic(files_struct *fsp, curr_flags = flags | O_EXCL; } - status = fd_open(fsp, curr_flags, mode); + status = fd_openat(fsp, curr_flags, mode); } *file_created = (NT_STATUS_IS_OK(status) && !file_existed); @@ -4584,7 +4584,7 @@ static NTSTATUS open_directory(connection_struct *conn, flags |= O_DIRECTORY; #endif - status = fd_open(fsp, flags, 0); + status = fd_openat(fsp, flags, 0); if (!NT_STATUS_IS_OK(status)) { DBG_INFO("Could not open fd for " "%s (%s)\n",