The branch, master has been updated via b96c2cf0199 vfs: directory enumeration is now handle based via 2a11c8f7134 vfs: update status of SMB_VFS_MKDIRAT() via 33e1f3cafeb pysmbd: use real dirfsp for SMB_VFS_MKDIRAT() via 5feabb64de7 vfs: update status of SMB_VFS_MKNODAT() via 77fc6894c1c s3: smbd: Change smb_unix_mknod() to use a real directory fsp for SMB_VFS_MKNODAT(). via ebcde172de0 s3: smbd: Move creation of parent_fname out of lp_inherit_permissions() clause in smb_unix_mknod(). via 30af87f46f9 s3: VFS: glusterfs: Fix vfs_gluster_mknodat() to cope with a real dirfsp. via 163a6802b64 s3: VFS: glusterfs: Fix missing END_PROFILE() in mkdirat() return. via 30d985759d1 s3: VFS: ceph: Fix cephwrap_mknodat() to cope with real directory fsps. via 8291c13f820 s3: VFS: ceph: Fix cephwrap_mkdirat() to cope with real directory fsps. from e84f8bdff58 samba-tool: Optionally hide disabled/expired accounts in "group listmembers"
https://git.samba.org/?p=samba.git;a=shortlog;h=master - Log ----------------------------------------------------------------- commit b96c2cf0199495b32dbdce5c833a0b64a9c4bd5d Author: Ralph Boehme <s...@samba.org> Date: Fri Jan 15 16:37:56 2021 +0100 vfs: directory enumeration is now handle based Remove obsolete description. Also remove SMB_VFS_STATX() as I don't see a need for that atm. Signed-off-by: Ralph Boehme <s...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> Autobuild-User(master): Jeremy Allison <j...@samba.org> Autobuild-Date(master): Fri Jan 15 22:01:55 UTC 2021 on sn-devel-184 commit 2a11c8f7134bf78bc5b46cfb9ec602465ad66d00 Author: Ralph Boehme <s...@samba.org> Date: Fri Jan 15 10:13:36 2021 +0100 vfs: update status of SMB_VFS_MKDIRAT() Signed-off-by: Ralph Boehme <s...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> commit 33e1f3cafebcad1e5d79360bf1fd320fe9cc09bd Author: Ralph Boehme <s...@samba.org> Date: Fri Jan 15 10:12:29 2021 +0100 pysmbd: use real dirfsp for SMB_VFS_MKDIRAT() Signed-off-by: Ralph Boehme <s...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> commit 5feabb64de76b87b60847270d03f344f09bae6eb Author: Ralph Boehme <s...@samba.org> Date: Fri Jan 15 09:54:15 2021 +0100 vfs: update status of SMB_VFS_MKNODAT() Signed-off-by: Ralph Boehme <s...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> commit 77fc6894c1c507d242352d0fd67f141f7f5ce102 Author: Jeremy Allison <j...@samba.org> Date: Thu Jan 14 12:18:50 2021 -0800 s3: smbd: Change smb_unix_mknod() to use a real directory fsp for SMB_VFS_MKNODAT(). New VFS change. Signed-off-by: Jeremy Allison <j...@samba.org> Reviewed-by: Ralph Boehme <s...@samba.org> commit ebcde172de0886cb41741f9a5ad6ebaf36efeea6 Author: Jeremy Allison <j...@samba.org> Date: Thu Jan 14 11:50:39 2021 -0800 s3: smbd: Move creation of parent_fname out of lp_inherit_permissions() clause in smb_unix_mknod(). We will need this for the upcoming openat_pathref_fsp() use. Signed-off-by: Jeremy Allison <j...@samba.org> Reviewed-by: Ralph Boehme <s...@samba.org> commit 30af87f46f91b3175d51908b8c77e6ee178145f3 Author: Jeremy Allison <j...@samba.org> Date: Thu Jan 14 12:25:24 2021 -0800 s3: VFS: glusterfs: Fix vfs_gluster_mknodat() to cope with a real dirfsp. Signed-off-by: Jeremy Allison <j...@samba.org> Reviewed-by: Ralph Boehme <s...@samba.org> commit 163a6802b64888b9f810a0e2d32694dc9f1c67a0 Author: Jeremy Allison <j...@samba.org> Date: Thu Jan 14 12:26:48 2021 -0800 s3: VFS: glusterfs: Fix missing END_PROFILE() in mkdirat() return. Signed-off-by: Jeremy Allison <j...@samba.org> Reviewed-by: Ralph Boehme <s...@samba.org> commit 30d985759d1f6bce2dde0d665de66e65abd11c43 Author: Jeremy Allison <j...@samba.org> Date: Thu Jan 14 12:35:29 2021 -0800 s3: VFS: ceph: Fix cephwrap_mknodat() to cope with real directory fsps. Signed-off-by: Jeremy Allison <j...@samba.org> Reviewed-by: Ralph Boehme <s...@samba.org> commit 8291c13f820f008a99df77394cb75fffd6add589 Author: Jeremy Allison <j...@samba.org> Date: Thu Jan 14 12:31:24 2021 -0800 s3: VFS: ceph: Fix cephwrap_mkdirat() to cope with real directory fsps. Signed-off-by: Jeremy Allison <j...@samba.org> Reviewed-by: Ralph Boehme <s...@samba.org> ----------------------------------------------------------------------- Summary of changes: source3/modules/The_New_VFS.org | 12 ++---------- source3/modules/The_New_VFS.txt | 10 ++-------- source3/modules/vfs_ceph.c | 32 +++++++++++++++++++++++++------ source3/modules/vfs_glusterfs.c | 17 +++++++++++++++-- source3/smbd/pysmbd.c | 28 +++++++++++++++++++++++++-- source3/smbd/trans2.c | 42 ++++++++++++++++++++++++++++------------- 6 files changed, 100 insertions(+), 41 deletions(-) Changeset truncated at 500 lines: diff --git a/source3/modules/The_New_VFS.org b/source3/modules/The_New_VFS.org index aff51c4375d..d034acaa661 100644 --- a/source3/modules/The_New_VFS.org +++ b/source3/modules/The_New_VFS.org @@ -258,8 +258,8 @@ whenever VFS access is done in a piecemeal fashion. | SMB_VFS_LOCK() | [[fsp][fsp]] | - | | SMB_VFS_LSEEK() | [[fsp][fsp]] | - | | SMB_VFS_LSTAT() | [[Path][Path]] | Todo | -| SMB_VFS_MKDIRAT() | [[NsC][NsC]] | Todo | -| SMB_VFS_MKNODAT() | [[NsC][NsC]] | Todo | +| SMB_VFS_MKDIRAT() | [[NsC][NsC]] | - | +| SMB_VFS_MKNODAT() | [[NsC][NsC]] | - | | SMB_VFS_NTIMES() | [[Path][Path]] | Todo | | SMB_VFS_OFFLOAD_READ_RECV() | [[fsp][fsp]] | - | | SMB_VFS_OFFLOAD_READ_SEND() | [[fsp][fsp]] | - | @@ -310,7 +310,6 @@ whenever VFS access is done in a piecemeal fashion. |---------------------------------+----------+--------| | SMB_VFS_SYS_ACL_DELETE_DEF_FD() | [[xpathref][xpathref]] | Todo | | SMB_VFS_READDIR_ATTRAT() | [[Enum][Enum]] | Todo | -| SMB_VFS_STATX() | [[Enum][Enum]] | Todo | | SMB_VFS_FUTIMENS() | [[fsp][fsp]] | Todo | |---------------------------------+----------+--------| @@ -437,16 +436,9 @@ whenever VFS access is done in a piecemeal fashion. functions with real dirfsps. *** AT VFS functions needed for directory enumeration <<Enum>> - - SMB_VFS_GET_DOS_ATTRIBUTES_SEND() - SMB_VFS_GETXATTRAT_SEND() - SMB_VFS_READDIR_ATTRAT() (NEW) - - SMB_VFS_STATX() (NEW) - - We can't open file-handles on all directory children for performance - reasons. Therefor we need *AT based VFS functions for all metadata VFS queries - done in the directory enumeration loop. - *** Handle based VFS functions not allowed on O_PATH opened handles <<xpathref>> - SMB_VFS_FGETXATTR() - SMB_VFS_FLISTXATTR() diff --git a/source3/modules/The_New_VFS.txt b/source3/modules/The_New_VFS.txt index 345457c5a90..6d94cfdc6a2 100644 --- a/source3/modules/The_New_VFS.txt +++ b/source3/modules/The_New_VFS.txt @@ -326,8 +326,8 @@ Table of Contents SMB_VFS_LOCK() [fsp] - SMB_VFS_LSEEK() [fsp] - SMB_VFS_LSTAT() [Path] Todo - SMB_VFS_MKDIRAT() [NsC] Todo - SMB_VFS_MKNODAT() [NsC] Todo + SMB_VFS_MKDIRAT() [NsC] - + SMB_VFS_MKNODAT() [NsC] - SMB_VFS_NTIMES() [Path] Todo SMB_VFS_OFFLOAD_READ_RECV() [fsp] - SMB_VFS_OFFLOAD_READ_SEND() [fsp] - @@ -400,7 +400,6 @@ Table of Contents ───────────────────────────────────────────────────── SMB_VFS_SYS_ACL_DELETE_DEF_FD() [xpathref] Todo SMB_VFS_READDIR_ATTRAT() [Enum] Todo - SMB_VFS_STATX() [Enum] Todo SMB_VFS_FUTIMENS() [fsp] Todo ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ @@ -558,11 +557,6 @@ Table of Contents • SMB_VFS_GET_DOS_ATTRIBUTES_SEND() • SMB_VFS_GETXATTRAT_SEND() • SMB_VFS_READDIR_ATTRAT() (NEW) - • SMB_VFS_STATX() (NEW) - - We can't open file-handles on all directory children for performance - reasons. Therefor we need *AT based VFS functions for all metadata VFS - queries done in the directory enumeration loop. 2.2.7 Handle based VFS functions not allowed on O_PATH opened handles diff --git a/source3/modules/vfs_ceph.c b/source3/modules/vfs_ceph.c index 6bb770005e1..b2d9ead1db5 100644 --- a/source3/modules/vfs_ceph.c +++ b/source3/modules/vfs_ceph.c @@ -364,14 +364,23 @@ static int cephwrap_mkdirat(struct vfs_handle_struct *handle, const struct smb_filename *smb_fname, mode_t mode) { + struct smb_filename *full_fname = NULL; int result; + full_fname = full_path_from_dirfsp_atname(talloc_tos(), + dirfsp, + smb_fname); + if (full_fname == NULL) { + return -1; + } + DBG_DEBUG("[CEPH] mkdir(%p, %s)\n", - handle, smb_fname_str_dbg(smb_fname)); + handle, smb_fname_str_dbg(full_fname)); - SMB_ASSERT(dirfsp == dirfsp->conn->cwd_fsp); + result = ceph_mkdir(handle->data, full_fname->base_name, mode); + + TALLOC_FREE(full_fname); - result = ceph_mkdir(handle->data, smb_fname->base_name, mode); return WRAP_RETURN(result); } @@ -1102,11 +1111,22 @@ static int cephwrap_mknodat(struct vfs_handle_struct *handle, mode_t mode, SMB_DEV_T dev) { + struct smb_filename *full_fname = NULL; int result = -1; - DBG_DEBUG("[CEPH] mknodat(%p, %s)\n", handle, smb_fname->base_name); - SMB_ASSERT(dirfsp == dirfsp->conn->cwd_fsp); - result = ceph_mknod(handle->data, smb_fname->base_name, mode, dev); + + full_fname = full_path_from_dirfsp_atname(talloc_tos(), + dirfsp, + smb_fname); + if (full_fname == NULL) { + return -1; + } + + DBG_DEBUG("[CEPH] mknodat(%p, %s)\n", handle, full_fname->base_name); + result = ceph_mknod(handle->data, full_fname->base_name, mode, dev); DBG_DEBUG("[CEPH] mknodat(...) = %d\n", result); + + TALLOC_FREE(full_fname); + WRAP_RETURN(result); } diff --git a/source3/modules/vfs_glusterfs.c b/source3/modules/vfs_glusterfs.c index ddead1f269c..59b76546112 100644 --- a/source3/modules/vfs_glusterfs.c +++ b/source3/modules/vfs_glusterfs.c @@ -723,6 +723,7 @@ static int vfs_gluster_mkdirat(struct vfs_handle_struct *handle, dirfsp, smb_fname); if (full_fname == NULL) { + END_PROFILE(syscall_mkdirat); return -1; } @@ -1899,11 +1900,23 @@ static int vfs_gluster_mknodat(struct vfs_handle_struct *handle, mode_t mode, SMB_DEV_T dev) { + struct smb_filename *full_fname = NULL; int ret; START_PROFILE(syscall_mknodat); - SMB_ASSERT(dirfsp == dirfsp->conn->cwd_fsp); - ret = glfs_mknod(handle->data, smb_fname->base_name, mode, dev); + + full_fname = full_path_from_dirfsp_atname(talloc_tos(), + dirfsp, + smb_fname); + if (full_fname == NULL) { + END_PROFILE(syscall_mknodat); + return -1; + } + + ret = glfs_mknod(handle->data, full_fname->base_name, mode, dev); + + TALLOC_FREE(full_fname); + END_PROFILE(syscall_mknodat); return ret; diff --git a/source3/smbd/pysmbd.c b/source3/smbd/pysmbd.c index 216de7a82fd..042e31b79d6 100644 --- a/source3/smbd/pysmbd.c +++ b/source3/smbd/pysmbd.c @@ -1026,8 +1026,12 @@ static PyObject *py_smbd_mkdir(PyObject *self, PyObject *args, PyObject *kwargs) TALLOC_CTX *frame = talloc_stackframe(); struct connection_struct *conn = NULL; struct smb_filename *smb_fname = NULL; + struct smb_filename *parent_fname = NULL; + struct smb_filename *base_name = NULL; + NTSTATUS status; int ret; mode_t saved_umask; + bool ok; if (!PyArg_ParseTupleAndKeywords(args, kwargs, @@ -1076,13 +1080,33 @@ static PyObject *py_smbd_mkdir(PyObject *self, PyObject *args, PyObject *kwargs) return NULL; } + ok = parent_smb_fname(frame, + smb_fname, + &parent_fname, + &base_name); + if (!ok) { + TALLOC_FREE(frame); + return NULL; + } + + ret = vfs_stat(conn, parent_fname); + if (ret == -1) { + TALLOC_FREE(frame); + return NULL; + } + status = openat_pathref_fsp(conn->cwd_fsp, parent_fname); + if (!NT_STATUS_IS_OK(status)) { + TALLOC_FREE(frame); + return NULL; + } + /* we want total control over the permissions on created files, so set our umask to 0 */ saved_umask = umask(0); ret = SMB_VFS_MKDIRAT(conn, - conn->cwd_fsp, - smb_fname, + parent_fname->fsp, + base_name, 00755); umask(saved_umask); diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c index 69b8323a29d..3c1df4ca3ac 100644 --- a/source3/smbd/trans2.c +++ b/source3/smbd/trans2.c @@ -8113,6 +8113,9 @@ static NTSTATUS smb_unix_mknod(connection_struct *conn, NTSTATUS status; mode_t unixmode; int ret; + struct smb_filename *parent_fname = NULL; + struct smb_filename *base_name = NULL; + bool ok; if (total_data < 100) { return NT_STATUS_INVALID_PARAMETER; @@ -8169,14 +8172,37 @@ static NTSTATUS smb_unix_mknod(connection_struct *conn, "%.0f mode 0%o for file %s\n", (double)dev, (unsigned int)unixmode, smb_fname_str_dbg(smb_fname))); + ok = parent_smb_fname(talloc_tos(), + smb_fname, + &parent_fname, + &base_name); + if (!ok) { + return NT_STATUS_NO_MEMORY; + } + + ret = vfs_stat(conn, parent_fname); + if (ret == -1) { + TALLOC_FREE(parent_fname); + return map_nt_error_from_unix(errno); + } + status = openat_pathref_fsp(conn->cwd_fsp, parent_fname); + if (NT_STATUS_EQUAL(status, NT_STATUS_STOPPED_ON_SYMLINK)) { + status = NT_STATUS_OBJECT_NAME_NOT_FOUND; + } + if (!NT_STATUS_IS_OK(status)) { + TALLOC_FREE(parent_fname); + return status; + } + /* Ok - do the mknod. */ ret = SMB_VFS_MKNODAT(conn, - conn->cwd_fsp, - smb_fname, + parent_fname->fsp, + base_name, unixmode, dev); if (ret != 0) { + TALLOC_FREE(parent_fname); return map_nt_error_from_unix(errno); } @@ -8185,22 +8211,12 @@ static NTSTATUS smb_unix_mknod(connection_struct *conn, */ if (lp_inherit_permissions(SNUM(conn))) { - struct smb_filename *parent_fname = NULL; - bool ok; - - ok = parent_smb_fname(talloc_tos(), - smb_fname, - &parent_fname, - NULL); - if (!ok) { - return NT_STATUS_NO_MEMORY; - } inherit_access_posix_acl(conn, parent_fname, smb_fname, unixmode); - TALLOC_FREE(parent_fname); } + TALLOC_FREE(parent_fname); return NT_STATUS_OK; } -- Samba Shared Repository