The branch, master has been updated
via 5030bba13ae samba-dcerpcd: Silence a DEBUG message
via 1912a0d65cb smbd: We have the fsp available, use
fsp_is_alternate_stream()
via 118b63bb2c2 smbd: Fix a typo
via 5204da2ac5a smbd: Convert get_real_filename_full_scan() to
OpenDir_ntstatus()
via f143eeae169 smbd: Initialize a pointer
via 7e3c51ee431 vfs: walk_streams() returns NTSTATUS
via 9027cc357a0 smbd: can_delete_directory_fsp() returns NTSTATUS
via be201475167 smbd: Factor out OpenDir_ntstatus()
via afd037df111 smbd: Make OpenDir_fsp() return NTSTATUS
via 2cef24a5fa6 smbd: Initialize a pointer
from a2590298b03 util: CID 1499409: Memory - corruptions
(OVERLAPPING_COPY)
https://git.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit 5030bba13aee6dc5cc1507c063acf19e4e091cf2
Author: Volker Lendecke <[email protected]>
Date: Tue Feb 22 10:02:57 2022 +0100
samba-dcerpcd: Silence a DEBUG message
This is not worth a debuglevel 1 message
Signed-off-by: Volker Lendecke <[email protected]>
Reviewed-by: Ralph Boehme <[email protected]>
Autobuild-User(master): Ralph Böhme <[email protected]>
Autobuild-Date(master): Tue Feb 22 10:16:44 UTC 2022 on sn-devel-184
commit 1912a0d65cb286ebf76c008bfbc9b0b60024859d
Author: Volker Lendecke <[email protected]>
Date: Fri Feb 11 18:49:53 2022 +0100
smbd: We have the fsp available, use fsp_is_alternate_stream()
Signed-off-by: Volker Lendecke <[email protected]>
Reviewed-by: Ralph Boehme <[email protected]>
commit 118b63bb2c2ed9d3d91eb6ab59f9d267adf5c954
Author: Volker Lendecke <[email protected]>
Date: Mon Feb 21 15:26:06 2022 +0100
smbd: Fix a typo
Signed-off-by: Volker Lendecke <[email protected]>
Reviewed-by: Ralph Boehme <[email protected]>
commit 5204da2ac5ace4d62a8665544780453469b885fa
Author: Volker Lendecke <[email protected]>
Date: Mon Feb 21 17:43:17 2022 +0100
smbd: Convert get_real_filename_full_scan() to OpenDir_ntstatus()
Get us a better error message without going through the lossy errno.
Signed-off-by: Volker Lendecke <[email protected]>
Reviewed-by: Ralph Boehme <[email protected]>
commit f143eeae1690dd0084789859d0898291fe6b75a8
Author: Volker Lendecke <[email protected]>
Date: Mon Feb 21 17:30:29 2022 +0100
smbd: Initialize a pointer
Signed-off-by: Volker Lendecke <[email protected]>
Reviewed-by: Ralph Boehme <[email protected]>
commit 7e3c51ee431f5070f87f3596b11da1b7a1c19e9a
Author: Volker Lendecke <[email protected]>
Date: Mon Feb 21 17:19:49 2022 +0100
vfs: walk_streams() returns NTSTATUS
Don't go via errno
Signed-off-by: Volker Lendecke <[email protected]>
Reviewed-by: Ralph Boehme <[email protected]>
commit 9027cc357a0db4fe08b3abc93ce2d7a9d729d815
Author: Volker Lendecke <[email protected]>
Date: Mon Feb 21 17:19:49 2022 +0100
smbd: can_delete_directory_fsp() returns NTSTATUS
Don't go via errno
Signed-off-by: Volker Lendecke <[email protected]>
Reviewed-by: Ralph Boehme <[email protected]>
commit be201475167afaeb7824cbb40034b3dde4a182bb
Author: Volker Lendecke <[email protected]>
Date: Mon Feb 21 17:17:24 2022 +0100
smbd: Factor out OpenDir_ntstatus()
We might have callers interested in the exact NTSTATUS error code.
Signed-off-by: Volker Lendecke <[email protected]>
Reviewed-by: Ralph Boehme <[email protected]>
commit afd037df1111202adefa49d1b746ec18d522dcd1
Author: Volker Lendecke <[email protected]>
Date: Mon Feb 21 17:12:05 2022 +0100
smbd: Make OpenDir_fsp() return NTSTATUS
Preparation for making OpenDir return NTSTATUS
Signed-off-by: Volker Lendecke <[email protected]>
Reviewed-by: Ralph Boehme <[email protected]>
commit 2cef24a5fa681840147509e1f97d8ce19e0f533d
Author: Volker Lendecke <[email protected]>
Date: Mon Feb 21 17:09:36 2022 +0100
smbd: Initialize a pointer
Signed-off-by: Volker Lendecke <[email protected]>
Reviewed-by: Ralph Boehme <[email protected]>
-----------------------------------------------------------------------
Summary of changes:
source3/modules/vfs_streams_depot.c | 8 +--
source3/rpc_server/rpc_host.c | 8 +--
source3/smbd/close.c | 2 +-
source3/smbd/dir.c | 102 +++++++++++++++++++++++-------------
source3/smbd/filename.c | 12 +++--
source3/smbd/proto.h | 6 +++
source3/smbd/reply.c | 2 +-
7 files changed, 91 insertions(+), 49 deletions(-)
Changeset truncated at 500 lines:
diff --git a/source3/modules/vfs_streams_depot.c
b/source3/modules/vfs_streams_depot.c
index ae73ba965a5..f1ec5b9748a 100644
--- a/source3/modules/vfs_streams_depot.c
+++ b/source3/modules/vfs_streams_depot.c
@@ -551,6 +551,7 @@ static NTSTATUS walk_streams(vfs_handle_struct *handle,
const char *dname = NULL;
long offset = 0;
char *talloced = NULL;
+ NTSTATUS status;
dirname = stream_dir(handle, smb_fname_base, &smb_fname_base->st,
false);
@@ -594,13 +595,14 @@ static NTSTATUS walk_streams(vfs_handle_struct *handle,
orig_connectpath = handle->conn->connectpath;
handle->conn->connectpath = rootdir;
- dir_hnd = OpenDir(talloc_tos(), handle->conn, dir_smb_fname, NULL, 0);
- if (dir_hnd == NULL) {
+ status = OpenDir_ntstatus(
+ talloc_tos(), handle->conn, dir_smb_fname, NULL, 0, &dir_hnd);
+ if (!NT_STATUS_IS_OK(status)) {
handle->conn->connectpath = orig_connectpath;
TALLOC_FREE(rootdir);
TALLOC_FREE(dir_smb_fname);
TALLOC_FREE(dirname);
- return map_nt_error_from_unix(errno);
+ return status;
}
while ((dname = ReadDirName(dir_hnd, &offset, NULL, &talloced))
diff --git a/source3/rpc_server/rpc_host.c b/source3/rpc_server/rpc_host.c
index 4a370f96e65..7ca24240a92 100644
--- a/source3/rpc_server/rpc_host.c
+++ b/source3/rpc_server/rpc_host.c
@@ -1347,10 +1347,10 @@ again:
goto done;
}
- DBG_WARNING("Sending new client %s to %d with %"PRIu32" clients\n",
- server->rpc_server_exe,
- worker->pid,
- worker->num_clients);
+ DBG_INFO("Sending new client %s to %d with %"PRIu32" clients\n",
+ server->rpc_server_exe,
+ worker->pid,
+ worker->num_clients);
iov = (struct iovec) {
.iov_base = blob.data, .iov_len = blob.length,
diff --git a/source3/smbd/close.c b/source3/smbd/close.c
index c13826567d5..4ad8e42f319 100644
--- a/source3/smbd/close.c
+++ b/source3/smbd/close.c
@@ -441,7 +441,7 @@ static NTSTATUS close_remove_share_mode(files_struct *fsp,
}
if ((conn->fs_capabilities & FILE_NAMED_STREAMS)
- && !is_ntfs_stream_smb_fname(fsp->fsp_name)) {
+ && !fsp_is_alternate_stream(fsp)) {
status = delete_all_streams(conn, fsp->fsp_name);
diff --git a/source3/smbd/dir.c b/source3/smbd/dir.c
index 3cf6cb285a4..c9cc6b73e58 100644
--- a/source3/smbd/dir.c
+++ b/source3/smbd/dir.c
@@ -81,10 +81,13 @@ struct dptr_struct {
struct memcache *dptr_cache;
};
-static struct smb_Dir *OpenDir_fsp(TALLOC_CTX *mem_ctx, connection_struct
*conn,
- files_struct *fsp,
- const char *mask,
- uint32_t attr);
+static NTSTATUS OpenDir_fsp(
+ TALLOC_CTX *mem_ctx,
+ connection_struct *conn,
+ files_struct *fsp,
+ const char *mask,
+ uint32_t attr,
+ struct smb_Dir **_dir_hnd);
static void DirCacheAdd(struct smb_Dir *dir_hnd, const char *name, long
offset);
@@ -216,7 +219,8 @@ NTSTATUS dptr_create(connection_struct *conn,
{
struct smbd_server_connection *sconn = conn->sconn;
struct dptr_struct *dptr = NULL;
- struct smb_Dir *dir_hnd;
+ struct smb_Dir *dir_hnd = NULL;
+ NTSTATUS status;
DBG_INFO("dir=%s\n", fsp_str_dbg(fsp));
@@ -235,9 +239,9 @@ NTSTATUS dptr_create(connection_struct *conn,
fsp_str_dbg(fsp));
return NT_STATUS_ACCESS_DENIED;
}
- dir_hnd = OpenDir_fsp(NULL, conn, fsp, wcard, attr);
- if (!dir_hnd) {
- return map_nt_error_from_unix(errno);
+ status = OpenDir_fsp(NULL, conn, fsp, wcard, attr, &dir_hnd);
+ if (!NT_STATUS_IS_OK(status)) {
+ return status;
}
dptr = talloc_zero(NULL, struct dptr_struct);
@@ -1473,11 +1477,12 @@ static int smb_Dir_OpenDir_destructor(struct smb_Dir
*dir_hnd)
return 0;
}
-struct smb_Dir *OpenDir(TALLOC_CTX *mem_ctx,
- connection_struct *conn,
- const struct smb_filename *smb_dname,
- const char *mask,
- uint32_t attr)
+NTSTATUS OpenDir_ntstatus(TALLOC_CTX *mem_ctx,
+ connection_struct *conn,
+ const struct smb_filename *smb_dname,
+ const char *mask,
+ uint32_t attr,
+ struct smb_Dir **_dir_hnd)
{
struct files_struct *fsp = NULL;
struct smb_Dir *dir_hnd = NULL;
@@ -1488,14 +1493,12 @@ struct smb_Dir *OpenDir(TALLOC_CTX *mem_ctx,
O_RDONLY,
&fsp);
if (!NT_STATUS_IS_OK(status)) {
- /* Ensure we return the actual error from status in errno. */
- errno = map_errno_from_nt_status(status);
- return NULL;
+ return status;
}
- dir_hnd = OpenDir_fsp(mem_ctx, conn, fsp, mask, attr);
- if (dir_hnd == NULL) {
- return NULL;
+ status = OpenDir_fsp(mem_ctx, conn, fsp, mask, attr, &dir_hnd);
+ if (!NT_STATUS_IS_OK(status)) {
+ return status;
}
/*
@@ -1503,31 +1506,56 @@ struct smb_Dir *OpenDir(TALLOC_CTX *mem_ctx,
* but smb_Dir_OpenDir_destructor() calls the OpenDir_fsp() destructor.
*/
talloc_set_destructor(dir_hnd, smb_Dir_OpenDir_destructor);
- return dir_hnd;
+
+ *_dir_hnd = dir_hnd;
+ return NT_STATUS_OK;
}
+struct smb_Dir *OpenDir(TALLOC_CTX *mem_ctx,
+ connection_struct *conn,
+ const struct smb_filename *smb_dname,
+ const char *mask,
+ uint32_t attr)
+{
+ struct smb_Dir *dir_hnd = NULL;
+ NTSTATUS status;
+
+ status = OpenDir_ntstatus(
+ mem_ctx, conn, smb_dname, mask, attr, &dir_hnd);
+ if (!NT_STATUS_IS_OK(status)) {
+ /* Ensure we return the actual error from status in errno. */
+ errno = map_errno_from_nt_status(status);
+ return NULL;
+ }
+
+ return dir_hnd;
+}
/*******************************************************************
Open a directory from an fsp.
********************************************************************/
-static struct smb_Dir *OpenDir_fsp(TALLOC_CTX *mem_ctx, connection_struct
*conn,
- files_struct *fsp,
- const char *mask,
- uint32_t attr)
+static NTSTATUS OpenDir_fsp(
+ TALLOC_CTX *mem_ctx,
+ connection_struct *conn,
+ files_struct *fsp,
+ const char *mask,
+ uint32_t attr,
+ struct smb_Dir **_dir_hnd)
{
struct smb_Dir *dir_hnd = talloc_zero(mem_ctx, struct smb_Dir);
+ NTSTATUS status;
if (!dir_hnd) {
- goto fail;
+ return NT_STATUS_NO_MEMORY;
}
if (!fsp->fsp_flags.is_directory) {
- errno = EBADF;
+ status = NT_STATUS_INVALID_HANDLE;
goto fail;
}
if (fsp_get_io_fd(fsp) == -1) {
- errno = EBADF;
+ status = NT_STATUS_INVALID_HANDLE;
goto fail;
}
@@ -1546,12 +1574,13 @@ static struct smb_Dir *OpenDir_fsp(TALLOC_CTX *mem_ctx,
connection_struct *conn,
dir_hnd->dir_smb_fname = cp_smb_filename(dir_hnd, fsp->fsp_name);
if (!dir_hnd->dir_smb_fname) {
- errno = ENOMEM;
+ status = NT_STATUS_NO_MEMORY;
goto fail;
}
dir_hnd->dir = SMB_VFS_FDOPENDIR(fsp, mask, attr);
if (dir_hnd->dir == NULL) {
+ status = map_nt_error_from_unix(errno);
goto fail;
}
dir_hnd->fsp = fsp;
@@ -1563,11 +1592,12 @@ static struct smb_Dir *OpenDir_fsp(TALLOC_CTX *mem_ctx,
connection_struct *conn,
talloc_set_destructor(dir_hnd, smb_Dir_destructor);
- return dir_hnd;
+ *_dir_hnd = dir_hnd;
+ return NT_STATUS_OK;
fail:
TALLOC_FREE(dir_hnd);
- return NULL;
+ return status;
}
@@ -1885,14 +1915,12 @@ NTSTATUS can_delete_directory_fsp(files_struct *fsp)
char *talloced = NULL;
SMB_STRUCT_STAT st;
struct connection_struct *conn = fsp->conn;
- struct smb_Dir *dir_hnd = OpenDir(talloc_tos(),
- conn,
- fsp->fsp_name,
- NULL,
- 0);
+ struct smb_Dir *dir_hnd = NULL;
- if (!dir_hnd) {
- return map_nt_error_from_unix(errno);
+ status = OpenDir_ntstatus(
+ talloc_tos(), conn, fsp->fsp_name, NULL, 0, &dir_hnd);
+ if (!NT_STATUS_IS_OK(status)) {
+ return status;
}
while ((dname = ReadDirName(dir_hnd, &dirpos, &st, &talloced))) {
diff --git a/source3/smbd/filename.c b/source3/smbd/filename.c
index 00fc3c7ca68..33aed86718f 100644
--- a/source3/smbd/filename.c
+++ b/source3/smbd/filename.c
@@ -1540,12 +1540,13 @@ int get_real_filename_full_scan(connection_struct *conn,
TALLOC_CTX *mem_ctx,
char **found_name)
{
- struct smb_Dir *cur_dir;
+ struct smb_Dir *cur_dir = NULL;
const char *dname = NULL;
char *talloced = NULL;
char *unmangled_name = NULL;
long curpos;
struct smb_filename *smb_fname = NULL;
+ NTSTATUS status;
/* handle null paths */
if ((path == NULL) || (*path == 0)) {
@@ -1598,10 +1599,15 @@ int get_real_filename_full_scan(connection_struct *conn,
}
/* open the directory */
- if (!(cur_dir = OpenDir(talloc_tos(), conn, smb_fname, NULL, 0))) {
- DEBUG(3,("scan dir didn't open dir [%s]\n",path));
+ status = OpenDir_ntstatus(
+ talloc_tos(), conn, smb_fname, NULL, 0, &cur_dir);
+ if (!NT_STATUS_IS_OK(status)) {
+ DBG_NOTICE("scan dir didn't open dir [%s]: %s\n",
+ path,
+ nt_errstr(status));
TALLOC_FREE(unmangled_name);
TALLOC_FREE(smb_fname);
+ errno = map_errno_from_nt_status(status);
return -1;
}
diff --git a/source3/smbd/proto.h b/source3/smbd/proto.h
index a5edf6c1fe7..6ca5e125aaf 100644
--- a/source3/smbd/proto.h
+++ b/source3/smbd/proto.h
@@ -231,6 +231,12 @@ bool get_dir_entry(TALLOC_CTX *ctx,
bool ask_sharemode);
struct smb_Dir;
bool is_visible_fsp(files_struct *fsp);
+NTSTATUS OpenDir_ntstatus(TALLOC_CTX *mem_ctx,
+ connection_struct *conn,
+ const struct smb_filename *smb_dname,
+ const char *mask,
+ uint32_t attr,
+ struct smb_Dir **_dir_hnd);
struct smb_Dir *OpenDir(TALLOC_CTX *mem_ctx,
connection_struct *conn,
const struct smb_filename *smb_fname,
diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c
index 955ebdd7829..3e9f2781292 100644
--- a/source3/smbd/reply.c
+++ b/source3/smbd/reply.c
@@ -7437,7 +7437,7 @@ NTSTATUS rename_internals_fsp(connection_struct *conn,
parent_dir_fname_src = parent_dir_fname_dst;
} else {
/*
- * source and destingation parent directories are
+ * source and destination parent directories are
* different.
*
* Get a pathref on the source parent directory, so
--
Samba Shared Repository