[SCM] Samba Shared Repository - branch master updated
Ralph Böhme
slow at samba.org
Wed Jun 2 06:31:01 UTC 2021
The branch, master has been updated
via b0f28dcd7a3 s3: smbd: Remove parent_smb_fname(), no longer used.
via 50a6da636c5 s3: smbd: check_reduced_name(), parent_smb_fname() -> SMB_VFS_PARENT_PATHNAME().
via 7dc7a2c0482 s3: smbd: check_reduced_name_with_privilege(), parent_smb_fname() -> SMB_VFS_PARENT_PATHNAME().
via 2e41ffe1045 s3: smbd: parent_dirname_compatible_open(), parent_smb_fname() -> SMB_VFS_PARENT_PATHNAME().
via 6263338f455 s3: smbd: non_widelink_open(), parent_smb_fname() -> SMB_VFS_PARENT_PATHNAME().
via 0dc842b4fab s3: smbd: In inherit_new_acl(), parent_smb_fname() -> SMB_VFS_PARENT_PATHNAME().
via 4f5928d286d s3: smbd: open_file_ntcreate(), parent_smb_fname() -> SMB_VFS_PARENT_PATHNAME().
via 38410ea2f7e s3: smbd: In check_parent_access(), parent_smb_fname() -> SMB_VFS_PARENT_PATHNAME().
via 0dde001c369 s3: smbd: copy_internals(). parent_smb_fname() -> SMB_VFS_PARENT_PATHNAME().
via b2027f982fe s3: smbd: In parent_pathref(), parent_smb_fname() -> SMB_VFS_PARENT_PATHNAME().
via ad99ee75785 s3: smbd: In can_delete_file_in_directory(), parent_smb_fname() -> SMB_VFS_PARENT_PATHNAME().
via 97c12be097f s3: VFS: linux_xfs_sgid. parent_smb_fname() -> SMB_VFS_PARENT_PATHNAME().
via fb5749fa6b4 s3: VFS: gpfs. parent_smb_fname() -> SMB_VFS_PARENT_PATHNAME().
via d0e84e28bfc s3: VFS: error_inject. parent_smb_fname() -> SMB_VFS_PARENT_PATHNAME().
via 9cd853da6bf s3: VFS: acl_common. parent_smb_fname() -> SMB_VFS_PARENT_PATHNAME().
via 71f69b6c1cc s3: VFS: shadow_copy2. Implement SMB_VFS_PARENT_PATHNAME().
via 0e75f9ffabc s3: VFS: Add SMB_VFS_PARENT_PATHNAME().
via c500d99e2f5 s3: lib: Fix talloc heirarcy error in parent_smb_fname().
from 58b5513d523 selftest: standardise and shorten winbind socket name
https://git.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit b0f28dcd7a32447ec55cce457664ef112baf2a7d
Author: Jeremy Allison <jra at samba.org>
Date: Wed May 26 11:51:38 2021 -0700
s3: smbd: Remove parent_smb_fname(), no longer used.
Moved into the VFS as SMB_VFS_PARENT_PATHNAME() to
allow modules to process the returned parent dirname.
Signed-off-by: Jeremy Allison <jra at samba.org>
Reviewed-by: Ralph Boehme <slow at samba.org>
Autobuild-User(master): Ralph Böhme <slow at samba.org>
Autobuild-Date(master): Wed Jun 2 06:30:36 UTC 2021 on sn-devel-184
commit 50a6da636c59d5cd3af269828e201efae7eedb47
Author: Jeremy Allison <jra at samba.org>
Date: Wed May 26 11:50:23 2021 -0700
s3: smbd: check_reduced_name(), parent_smb_fname() -> SMB_VFS_PARENT_PATHNAME().
Signed-off-by: Jeremy Allison <jra at samba.org>
Reviewed-by: Ralph Boehme <slow at samba.org>
commit 7dc7a2c04823e8a472b51d1728c840d7c88bd961
Author: Jeremy Allison <jra at samba.org>
Date: Wed May 26 11:47:36 2021 -0700
s3: smbd: check_reduced_name_with_privilege(), parent_smb_fname() -> SMB_VFS_PARENT_PATHNAME().
Signed-off-by: Jeremy Allison <jra at samba.org>
Reviewed-by: Ralph Boehme <slow at samba.org>
commit 2e41ffe104579b0e7f5d09a2f02fb3b8e2b00d83
Author: Jeremy Allison <jra at samba.org>
Date: Wed May 26 11:45:42 2021 -0700
s3: smbd: parent_dirname_compatible_open(), parent_smb_fname() -> SMB_VFS_PARENT_PATHNAME().
Signed-off-by: Jeremy Allison <jra at samba.org>
Reviewed-by: Ralph Boehme <slow at samba.org>
commit 6263338f45598b8fb2a712dab562b5458a7e69d3
Author: Jeremy Allison <jra at samba.org>
Date: Wed May 26 11:43:16 2021 -0700
s3: smbd: non_widelink_open(), parent_smb_fname() -> SMB_VFS_PARENT_PATHNAME().
Signed-off-by: Jeremy Allison <jra at samba.org>
Reviewed-by: Ralph Boehme <slow at samba.org>
commit 0dc842b4fab43c025ef79814684dbf33e936c972
Author: Jeremy Allison <jra at samba.org>
Date: Wed May 26 12:17:29 2021 -0700
s3: smbd: In inherit_new_acl(), parent_smb_fname() -> SMB_VFS_PARENT_PATHNAME().
Signed-off-by: Jeremy Allison <jra at samba.org>
Reviewed-by: Ralph Boehme <slow at samba.org>
commit 4f5928d286d5afd1ba2277f51de99ee637f3a07b
Author: Jeremy Allison <jra at samba.org>
Date: Wed May 26 12:13:40 2021 -0700
s3: smbd: open_file_ntcreate(), parent_smb_fname() -> SMB_VFS_PARENT_PATHNAME().
Signed-off-by: Jeremy Allison <jra at samba.org>
Reviewed-by: Ralph Boehme <slow at samba.org>
commit 38410ea2f7e19e0e4586d7a5c5453658edde6007
Author: Jeremy Allison <jra at samba.org>
Date: Wed May 26 12:11:36 2021 -0700
s3: smbd: In check_parent_access(), parent_smb_fname() -> SMB_VFS_PARENT_PATHNAME().
Signed-off-by: Jeremy Allison <jra at samba.org>
Reviewed-by: Ralph Boehme <slow at samba.org>
commit 0dde001c369743c3a5078134461f98c1eee471fa
Author: Jeremy Allison <jra at samba.org>
Date: Wed May 26 11:40:32 2021 -0700
s3: smbd: copy_internals(). parent_smb_fname() -> SMB_VFS_PARENT_PATHNAME().
Off-topic. This function is insane and should be removed..
Signed-off-by: Jeremy Allison <jra at samba.org>
Reviewed-by: Ralph Boehme <slow at samba.org>
commit b2027f982fe49023baca36101451e38df0b898c6
Author: Jeremy Allison <jra at samba.org>
Date: Wed May 26 11:22:00 2021 -0700
s3: smbd: In parent_pathref(), parent_smb_fname() -> SMB_VFS_PARENT_PATHNAME().
Signed-off-by: Jeremy Allison <jra at samba.org>
Reviewed-by: Ralph Boehme <slow at samba.org>
commit ad99ee7578558358a79e748d53402fcc66ae72c3
Author: Jeremy Allison <jra at samba.org>
Date: Wed May 26 11:10:53 2021 -0700
s3: smbd: In can_delete_file_in_directory(), parent_smb_fname() -> SMB_VFS_PARENT_PATHNAME().
Signed-off-by: Jeremy Allison <jra at samba.org>
Reviewed-by: Ralph Boehme <slow at samba.org>
commit 97c12be097f5b26fdcc2ee50da1d169ddce7731b
Author: Jeremy Allison <jra at samba.org>
Date: Wed May 26 11:07:53 2021 -0700
s3: VFS: linux_xfs_sgid. parent_smb_fname() -> SMB_VFS_PARENT_PATHNAME().
Signed-off-by: Jeremy Allison <jra at samba.org>
Reviewed-by: Ralph Boehme <slow at samba.org>
commit fb5749fa6b417c89cc8a150f00a79dbb46e23d42
Author: Jeremy Allison <jra at samba.org>
Date: Wed May 26 11:05:32 2021 -0700
s3: VFS: gpfs. parent_smb_fname() -> SMB_VFS_PARENT_PATHNAME().
Signed-off-by: Jeremy Allison <jra at samba.org>
Reviewed-by: Ralph Boehme <slow at samba.org>
commit d0e84e28bfc6b8ed0cc44bcc9cf6f021e633895e
Author: Jeremy Allison <jra at samba.org>
Date: Wed May 26 11:03:25 2021 -0700
s3: VFS: error_inject. parent_smb_fname() -> SMB_VFS_PARENT_PATHNAME().
Signed-off-by: Jeremy Allison <jra at samba.org>
Reviewed-by: Ralph Boehme <slow at samba.org>
commit 9cd853da6bf3e942f5f3c8bee1d4e13ba99e4b06
Author: Jeremy Allison <jra at samba.org>
Date: Wed May 26 11:00:49 2021 -0700
s3: VFS: acl_common. parent_smb_fname() -> SMB_VFS_PARENT_PATHNAME().
Signed-off-by: Jeremy Allison <jra at samba.org>
Reviewed-by: Ralph Boehme <slow at samba.org>
commit 71f69b6c1cc836b33159ddb8716a5e73ef83a90b
Author: Jeremy Allison <jra at samba.org>
Date: Tue Jun 1 11:58:55 2021 -0700
s3: VFS: shadow_copy2. Implement SMB_VFS_PARENT_PATHNAME().
Allows the snapdirseverywhere code to still find
snapshots even when not in the parent path.
Signed-off-by: Jeremy Allison <jra at samba.org>
Reviewed-by: Ralph Boehme <slow at samba.org>
commit 0e75f9ffabc751231e80f9583837f6afbc2d6233
Author: Jeremy Allison <jra at samba.org>
Date: Wed May 26 10:39:43 2021 -0700
s3: VFS: Add SMB_VFS_PARENT_PATHNAME().
Not yet used.
Default is NTSTATUS version of parent_smb_fname(). Now
to replace all users of parent_smb_fname() with
SMB_VFS_PARENT_PATHNAME() and then remove parent_smb_fname().
Needed due to snapdirseverywhere code in vfs_shadow_copy2.
Signed-off-by: Jeremy Allison <jra at samba.org>
Reviewed-by: Ralph Boehme <slow at samba.org>
commit c500d99e2f5aaec102bf952b7941a2596b3e35a1
Author: Jeremy Allison <jra at samba.org>
Date: Tue Jun 1 13:27:47 2021 -0700
s3: lib: Fix talloc heirarcy error in parent_smb_fname().
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14722
Signed-off-by: Jeremy Allison <jra at samba.org>
Reviewed-by: Ralph Boehme <slow at samba.org>
-----------------------------------------------------------------------
Summary of changes:
examples/VFS/skel_opaque.c | 10 ++++
examples/VFS/skel_transparent.c | 14 +++++
source3/include/proto.h | 4 --
source3/include/vfs.h | 17 ++++++
source3/include/vfs_macros.h | 5 ++
source3/lib/filename_util.c | 63 ----------------------
source3/modules/vfs_acl_common.c | 15 +++---
source3/modules/vfs_default.c | 65 +++++++++++++++++++++++
source3/modules/vfs_error_inject.c | 11 ++--
source3/modules/vfs_full_audit.c | 25 +++++++++
source3/modules/vfs_gpfs.c | 15 +++---
source3/modules/vfs_linux_xfs_sgid.c | 13 +++--
source3/modules/vfs_not_implemented.c | 10 ++++
source3/modules/vfs_shadow_copy2.c | 98 +++++++++++++++++++++++++++++++++++
source3/modules/vfs_time_audit.c | 29 +++++++++++
source3/smbd/file_access.c | 9 +++-
source3/smbd/files.c | 14 ++---
source3/smbd/nttrans.c | 13 +++--
source3/smbd/open.c | 49 ++++++++++--------
source3/smbd/reply.c | 15 +++---
source3/smbd/vfs.c | 47 +++++++++++------
21 files changed, 390 insertions(+), 151 deletions(-)
Changeset truncated at 500 lines:
diff --git a/examples/VFS/skel_opaque.c b/examples/VFS/skel_opaque.c
index 487919f38a8..4ac5e61f1ff 100644
--- a/examples/VFS/skel_opaque.c
+++ b/examples/VFS/skel_opaque.c
@@ -684,6 +684,15 @@ static NTSTATUS skel_translate_name(struct vfs_handle_struct *handle,
return NT_STATUS_NOT_IMPLEMENTED;
}
+static NTSTATUS skel_parent_pathname(struct vfs_handle_struct *handle,
+ TALLOC_CTX *mem_ctx,
+ const struct smb_filename *smb_fname_in,
+ struct smb_filename **parent_dir_out,
+ struct smb_filename **atname_out)
+{
+ return NT_STATUS_NOT_IMPLEMENTED;
+}
+
static NTSTATUS skel_fsctl(struct vfs_handle_struct *handle,
struct files_struct *fsp,
TALLOC_CTX *ctx,
@@ -1063,6 +1072,7 @@ static struct vfs_fn_pointers skel_opaque_fns = {
.brl_unlock_windows_fn = skel_brl_unlock_windows,
.strict_lock_check_fn = skel_strict_lock_check,
.translate_name_fn = skel_translate_name,
+ .parent_pathname_fn = skel_parent_pathname,
.fsctl_fn = skel_fsctl,
.freaddir_attr_fn = skel_freaddir_attr,
.audit_file_fn = skel_audit_file,
diff --git a/examples/VFS/skel_transparent.c b/examples/VFS/skel_transparent.c
index a0a747d8b57..9138bde0872 100644
--- a/examples/VFS/skel_transparent.c
+++ b/examples/VFS/skel_transparent.c
@@ -898,6 +898,19 @@ static NTSTATUS skel_translate_name(struct vfs_handle_struct *handle,
mem_ctx, pmapped_name);
}
+static NTSTATUS skel_parent_pathname(struct vfs_handle_struct *handle,
+ TALLOC_CTX *mem_ctx,
+ const struct smb_filename *smb_fname_in,
+ struct smb_filename **parent_dir_out,
+ struct smb_filename **atname_out)
+{
+ return SMB_VFS_NEXT_PARENT_PATHNAME(handle,
+ mem_ctx,
+ smb_fname_in,
+ parent_dir_out,
+ atname_out);
+}
+
static NTSTATUS skel_fsctl(struct vfs_handle_struct *handle,
struct files_struct *fsp,
TALLOC_CTX *ctx,
@@ -1368,6 +1381,7 @@ static struct vfs_fn_pointers skel_transparent_fns = {
.brl_unlock_windows_fn = skel_brl_unlock_windows,
.strict_lock_check_fn = skel_strict_lock_check,
.translate_name_fn = skel_translate_name,
+ .parent_pathname_fn = skel_parent_pathname,
.fsctl_fn = skel_fsctl,
.freaddir_attr_fn = skel_freaddir_attr,
.audit_file_fn = skel_audit_file,
diff --git a/source3/include/proto.h b/source3/include/proto.h
index f9bffb3aa59..d33cccd8390 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -376,10 +376,6 @@ char *myhostname_upper(void);
#include "lib/util_path.h"
bool parent_dirname(TALLOC_CTX *mem_ctx, const char *dir, char **parent,
const char **name);
-bool parent_smb_fname(TALLOC_CTX *mem_ctx,
- const struct smb_filename *path,
- struct smb_filename **_parent,
- struct smb_filename **_name);
bool ms_has_wild(const char *s);
bool ms_has_wild_w(const smb_ucs2_t *s);
bool mask_match(const char *string, const char *pattern, bool is_case_sensitive);
diff --git a/source3/include/vfs.h b/source3/include/vfs.h
index 02293c64733..0f01da81148 100644
--- a/source3/include/vfs.h
+++ b/source3/include/vfs.h
@@ -354,6 +354,7 @@
* Version 45 - Remove SMB_VFS_READDIR_ATTR
* Version 45 - Add SMB_VFS_SYS_ACL_DELETE_DEF_FD
* Version 45 - Remove SMB_VFS_SYS_ACL_DELETE_DEF_FILE
+ * Version 45 - Add SMB_VFS_PARENT_PATHNAME
*/
#define SMB_VFS_INTERFACE_VERSION 45
@@ -1150,6 +1151,12 @@ struct vfs_fn_pointers {
TALLOC_CTX *mem_ctx,
char **mapped_name);
+ NTSTATUS (*parent_pathname_fn)(struct vfs_handle_struct *handle,
+ TALLOC_CTX *mem_ctx,
+ const struct smb_filename *smb_fname_in,
+ struct smb_filename **parent_dir_out,
+ struct smb_filename **atname_out);
+
NTSTATUS (*fsctl_fn)(struct vfs_handle_struct *handle,
struct files_struct *fsp,
TALLOC_CTX *ctx,
@@ -1616,6 +1623,11 @@ NTSTATUS smb_vfs_call_translate_name(struct vfs_handle_struct *handle,
enum vfs_translate_direction direction,
TALLOC_CTX *mem_ctx,
char **mapped_name);
+NTSTATUS smb_vfs_call_parent_pathname(struct vfs_handle_struct *handle,
+ TALLOC_CTX *mem_ctx,
+ const struct smb_filename *smb_fname_in,
+ struct smb_filename **parent_dir_out,
+ struct smb_filename **atname_out);
NTSTATUS smb_vfs_call_fsctl(struct vfs_handle_struct *handle,
struct files_struct *fsp,
TALLOC_CTX *ctx,
@@ -2075,6 +2087,11 @@ NTSTATUS vfs_not_implemented_translate_name(struct vfs_handle_struct *handle,
const char *mapped_name,
enum vfs_translate_direction direction,
TALLOC_CTX *mem_ctx, char **pmapped_name);
+NTSTATUS vfs_not_implemented_parent_pathname(struct vfs_handle_struct *handle,
+ TALLOC_CTX *mem_ctx,
+ const struct smb_filename *smb_fname_in,
+ struct smb_filename **parent_dir_out,
+ struct smb_filename **atname_out);
NTSTATUS vfs_not_implemented_fsctl(struct vfs_handle_struct *handle,
struct files_struct *fsp,
TALLOC_CTX *ctx,
diff --git a/source3/include/vfs_macros.h b/source3/include/vfs_macros.h
index 018d60ce914..71492b4db79 100644
--- a/source3/include/vfs_macros.h
+++ b/source3/include/vfs_macros.h
@@ -388,6 +388,11 @@
#define SMB_VFS_NEXT_TRANSLATE_NAME(handle, name, direction, mem_ctx, mapped_name) \
smb_vfs_call_translate_name((handle)->next, (name), (direction), (mem_ctx), (mapped_name))
+#define SMB_VFS_PARENT_PATHNAME(conn, mem_ctx, smb_fname_in, parent_dir_out, atname_out) \
+ smb_vfs_call_parent_pathname((conn)->vfs_handles, (mem_ctx), (smb_fname_in), (parent_dir_out), (atname_out))
+#define SMB_VFS_NEXT_PARENT_PATHNAME(handle, mem_ctx, smb_fname_in, parent_dir_out, atname_out) \
+ smb_vfs_call_parent_pathname((handle)->next, (mem_ctx), (smb_fname_in), (parent_dir_out), (atname_out))
+
#define SMB_VFS_FSCTL(fsp, ctx, function, req_flags, in_data, in_len, out_data, max_out_len, out_len) \
smb_vfs_call_fsctl((fsp)->conn->vfs_handles, (fsp), (ctx), (function), (req_flags), (in_data), (in_len), (out_data), (max_out_len), (out_len))
diff --git a/source3/lib/filename_util.c b/source3/lib/filename_util.c
index f535ea1f088..120d2ecc4bc 100644
--- a/source3/lib/filename_util.c
+++ b/source3/lib/filename_util.c
@@ -269,69 +269,6 @@ struct smb_filename *cp_smb_filename(TALLOC_CTX *mem_ctx,
return out;
}
-/**
- * Return allocated parent directory and basename of path
- *
- * Note: if requesting name, it is returned as talloc child of the
- * parent. Freeing the parent is thus sufficient to free both.
- */
-bool parent_smb_fname(TALLOC_CTX *mem_ctx,
- const struct smb_filename *path,
- struct smb_filename **_parent,
- struct smb_filename **_name)
-{
- TALLOC_CTX *frame = talloc_stackframe();
- struct smb_filename *parent = NULL;
- struct smb_filename *name = NULL;
- char *p = NULL;
-
- parent = cp_smb_filename(frame, path);
- if (parent == NULL) {
- TALLOC_FREE(frame);
- return false;
- }
- TALLOC_FREE(parent->stream_name);
- SET_STAT_INVALID(parent->st);
-
- p = strrchr_m(parent->base_name, '/'); /* Find final '/', if any */
- if (p == NULL) {
- TALLOC_FREE(parent->base_name);
- parent->base_name = talloc_strdup(parent, ".");
- if (parent->base_name == NULL) {
- TALLOC_FREE(frame);
- return false;
- }
- p = path->base_name;
- } else {
- *p = '\0';
- p++;
- }
-
- if (_name == NULL) {
- *_parent = talloc_move(mem_ctx, &parent);
- TALLOC_FREE(frame);
- return true;
- }
-
- name = cp_smb_filename(frame, path);
- if (name == NULL) {
- TALLOC_FREE(frame);
- return false;
- }
- TALLOC_FREE(name->base_name);
-
- name->base_name = talloc_strdup(mem_ctx, p);
- if (name == NULL) {
- TALLOC_FREE(frame);
- return false;
- }
-
- *_parent = talloc_move(mem_ctx, &parent);
- *_name = talloc_move(*_parent, &name);
- TALLOC_FREE(frame);
- return true;
-}
-
static void assert_valid_stream_smb_fname(const struct smb_filename *smb_fname)
{
/* stream_name must always be NULL if there is no stream. */
diff --git a/source3/modules/vfs_acl_common.c b/source3/modules/vfs_acl_common.c
index 39afdcb1cf3..0615c06c81b 100644
--- a/source3/modules/vfs_acl_common.c
+++ b/source3/modules/vfs_acl_common.c
@@ -1200,7 +1200,7 @@ static int acl_common_remove_object(vfs_handle_struct *handle,
struct smb_filename *parent_dir_fname = NULL;
int saved_errno = 0;
struct smb_filename *saved_dir_fname = NULL;
- bool ok;
+ NTSTATUS status;
saved_dir_fname = vfs_GetWd(talloc_tos(),conn);
if (saved_dir_fname == NULL) {
@@ -1215,12 +1215,13 @@ static int acl_common_remove_object(vfs_handle_struct *handle,
goto out;
}
- ok = parent_smb_fname(talloc_tos(),
- full_fname,
- &parent_dir_fname,
- &local_fname);
- if (!ok) {
- saved_errno = ENOMEM;
+ status = SMB_VFS_PARENT_PATHNAME(conn,
+ talloc_tos(),
+ full_fname,
+ &parent_dir_fname,
+ &local_fname);
+ if (!NT_STATUS_IS_OK(status)) {
+ saved_errno = map_errno_from_nt_status(status);
goto out;
}
diff --git a/source3/modules/vfs_default.c b/source3/modules/vfs_default.c
index e384f8885d1..77e709f2449 100644
--- a/source3/modules/vfs_default.c
+++ b/source3/modules/vfs_default.c
@@ -1325,6 +1325,70 @@ static NTSTATUS vfswrap_translate_name(struct vfs_handle_struct *handle,
return NT_STATUS_NONE_MAPPED;
}
+/**
+ * Return allocated parent directory and basename of path
+ *
+ * Note: if requesting name, it is returned as talloc child of the
+ * parent. Freeing the parent is thus sufficient to free both.
+ */
+static NTSTATUS vfswrap_parent_pathname(struct vfs_handle_struct *handle,
+ TALLOC_CTX *mem_ctx,
+ const struct smb_filename *smb_fname_in,
+ struct smb_filename **parent_dir_out,
+ struct smb_filename **atname_out)
+{
+ TALLOC_CTX *frame = talloc_stackframe();
+ struct smb_filename *parent = NULL;
+ struct smb_filename *name = NULL;
+ char *p = NULL;
+
+ parent = cp_smb_filename(frame, smb_fname_in);
+ if (parent == NULL) {
+ TALLOC_FREE(frame);
+ return NT_STATUS_NO_MEMORY;
+ }
+ TALLOC_FREE(parent->stream_name);
+ SET_STAT_INVALID(parent->st);
+
+ p = strrchr_m(parent->base_name, '/'); /* Find final '/', if any */
+ if (p == NULL) {
+ TALLOC_FREE(parent->base_name);
+ parent->base_name = talloc_strdup(parent, ".");
+ if (parent->base_name == NULL) {
+ TALLOC_FREE(frame);
+ return NT_STATUS_NO_MEMORY;
+ }
+ p = smb_fname_in->base_name;
+ } else {
+ *p = '\0';
+ p++;
+ }
+
+ if (atname_out == NULL) {
+ *parent_dir_out = talloc_move(mem_ctx, &parent);
+ TALLOC_FREE(frame);
+ return NT_STATUS_OK;
+ }
+
+ name = cp_smb_filename(frame, smb_fname_in);
+ if (name == NULL) {
+ TALLOC_FREE(frame);
+ return NT_STATUS_NO_MEMORY;
+ }
+ TALLOC_FREE(name->base_name);
+
+ name->base_name = talloc_strdup(name, p);
+ if (name->base_name == NULL) {
+ TALLOC_FREE(frame);
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ *parent_dir_out = talloc_move(mem_ctx, &parent);
+ *atname_out = talloc_move(*parent_dir_out, &name);
+ TALLOC_FREE(frame);
+ return NT_STATUS_OK;
+}
+
/*
* Implement the default fsctl operation.
*/
@@ -3824,6 +3888,7 @@ static struct vfs_fn_pointers vfs_default_fns = {
.brl_unlock_windows_fn = vfswrap_brl_unlock_windows,
.strict_lock_check_fn = vfswrap_strict_lock_check,
.translate_name_fn = vfswrap_translate_name,
+ .parent_pathname_fn = vfswrap_parent_pathname,
.fsctl_fn = vfswrap_fsctl,
.fset_dos_attributes_fn = vfswrap_fset_dos_attributes,
.get_dos_attributes_send_fn = vfswrap_get_dos_attributes_send,
diff --git a/source3/modules/vfs_error_inject.c b/source3/modules/vfs_error_inject.c
index 31257cc1d00..dca8783edaf 100644
--- a/source3/modules/vfs_error_inject.c
+++ b/source3/modules/vfs_error_inject.c
@@ -133,7 +133,7 @@ static int vfs_error_inject_unlinkat(struct vfs_handle_struct *handle,
struct smb_filename *parent_fname = NULL;
int error = inject_unix_error("unlinkat", handle);
int ret;
- bool ok;
+ NTSTATUS status;
if (error == 0) {
return SMB_VFS_NEXT_UNLINKAT(handle, dirfsp, smb_fname, flags);
@@ -146,9 +146,14 @@ static int vfs_error_inject_unlinkat(struct vfs_handle_struct *handle,
return -1;
}
- ok = parent_smb_fname(full_fname, full_fname, &parent_fname, NULL);
- if (!ok) {
+ status = SMB_VFS_PARENT_PATHNAME(handle->conn,
+ full_fname, /* TALLOC_CTX. */
+ full_fname,
+ &parent_fname,
+ NULL);
+ if (!NT_STATUS_IS_OK(status)) {
TALLOC_FREE(full_fname);
+ errno = map_errno_from_nt_status(status);
return -1;
}
diff --git a/source3/modules/vfs_full_audit.c b/source3/modules/vfs_full_audit.c
index 85ba9ef2418..32e7879f7da 100644
--- a/source3/modules/vfs_full_audit.c
+++ b/source3/modules/vfs_full_audit.c
@@ -170,6 +170,7 @@ typedef enum _vfs_op_type {
SMB_VFS_OP_BRL_UNLOCK_WINDOWS,
SMB_VFS_OP_STRICT_LOCK_CHECK,
SMB_VFS_OP_TRANSLATE_NAME,
+ SMB_VFS_OP_PARENT_PATHNAME,
SMB_VFS_OP_FSCTL,
SMB_VFS_OP_OFFLOAD_READ_SEND,
SMB_VFS_OP_OFFLOAD_READ_RECV,
@@ -309,6 +310,7 @@ static struct {
{ SMB_VFS_OP_BRL_UNLOCK_WINDOWS, "brl_unlock_windows" },
{ SMB_VFS_OP_STRICT_LOCK_CHECK, "strict_lock_check" },
{ SMB_VFS_OP_TRANSLATE_NAME, "translate_name" },
+ { SMB_VFS_OP_PARENT_PATHNAME, "parent_pathname" },
{ SMB_VFS_OP_FSCTL, "fsctl" },
{ SMB_VFS_OP_OFFLOAD_READ_SEND, "offload_read_send" },
{ SMB_VFS_OP_OFFLOAD_READ_RECV, "offload_read_recv" },
@@ -2128,6 +2130,28 @@ static NTSTATUS smb_full_audit_translate_name(struct vfs_handle_struct *handle,
return result;
}
+static NTSTATUS smb_full_audit_parent_pathname(struct vfs_handle_struct *handle,
+ TALLOC_CTX *mem_ctx,
+ const struct smb_filename *smb_fname_in,
+ struct smb_filename **parent_dir_out,
+ struct smb_filename **atname_out)
+{
+ NTSTATUS result;
+
+ result = SMB_VFS_NEXT_PARENT_PATHNAME(handle,
+ mem_ctx,
+ smb_fname_in,
+ parent_dir_out,
+ atname_out);
+ do_log(SMB_VFS_OP_CONNECTPATH,
+ NT_STATUS_IS_OK(result),
+ handle,
+ "%s",
+ smb_fname_str_do_log(handle->conn, smb_fname_in));
+
+ return result;
+}
+
static NTSTATUS smb_full_audit_fsctl(struct vfs_handle_struct *handle,
struct files_struct *fsp,
TALLOC_CTX *ctx,
@@ -2990,6 +3014,7 @@ static struct vfs_fn_pointers vfs_full_audit_fns = {
.brl_unlock_windows_fn = smb_full_audit_brl_unlock_windows,
.strict_lock_check_fn = smb_full_audit_strict_lock_check,
.translate_name_fn = smb_full_audit_translate_name,
+ .parent_pathname_fn = smb_full_audit_parent_pathname,
.fsctl_fn = smb_full_audit_fsctl,
.get_dos_attributes_send_fn = smb_full_audit_get_dos_attributes_send,
.get_dos_attributes_recv_fn = smb_full_audit_get_dos_attributes_recv,
diff --git a/source3/modules/vfs_gpfs.c b/source3/modules/vfs_gpfs.c
index fa2fa81eec0..a05bb0f3c7a 100644
--- a/source3/modules/vfs_gpfs.c
+++ b/source3/modules/vfs_gpfs.c
@@ -1721,18 +1721,19 @@ static int stat_with_capability(struct vfs_handle_struct *handle,
{
#if defined(HAVE_FSTATAT)
int fd = -1;
- bool ok;
+ NTSTATUS status;
struct smb_filename *dir_name = NULL;
struct smb_filename *rel_name = NULL;
struct stat st;
int ret = -1;
- ok = parent_smb_fname(talloc_tos(),
- smb_fname,
- &dir_name,
- &rel_name);
- if (!ok) {
- errno = ENOMEM;
+ status = SMB_VFS_PARENT_PATHNAME(handle->conn,
+ talloc_tos(),
+ smb_fname,
+ &dir_name,
+ &rel_name);
+ if (!NT_STATUS_IS_OK(status)) {
+ errno = map_errno_from_nt_status(status);
return -1;
}
diff --git a/source3/modules/vfs_linux_xfs_sgid.c b/source3/modules/vfs_linux_xfs_sgid.c
index 4f07ceab092..a08e2d40f83 100644
--- a/source3/modules/vfs_linux_xfs_sgid.c
+++ b/source3/modules/vfs_linux_xfs_sgid.c
@@ -31,7 +31,7 @@ static int linux_xfs_sgid_mkdirat(vfs_handle_struct *handle,
struct smb_filename *fname = NULL;
int mkdir_res;
int res;
- bool ok;
+ NTSTATUS status;
DEBUG(10, ("Calling linux_xfs_sgid_mkdirat(%s)\n",
smb_fname->base_name));
@@ -53,9 +53,14 @@ static int linux_xfs_sgid_mkdirat(vfs_handle_struct *handle,
return -1;
}
- ok = parent_smb_fname(talloc_tos(), fname, &dname, NULL);
- if (!ok) {
- DBG_WARNING("parent_smb_fname() failed\n");
+ status = SMB_VFS_PARENT_PATHNAME(handle->conn,
+ talloc_tos(),
+ fname,
+ &dname,
+ NULL);
+ if (!NT_STATUS_IS_OK(status)) {
+ DBG_WARNING("SMB_VFS_PARENT_PATHNAME() failed with %s\n",
+ nt_errstr(status));
/* return success, we did the mkdir */
return mkdir_res;
}
diff --git a/source3/modules/vfs_not_implemented.c b/source3/modules/vfs_not_implemented.c
index 9cde162c593..8b93b3444e2 100644
--- a/source3/modules/vfs_not_implemented.c
+++ b/source3/modules/vfs_not_implemented.c
@@ -687,6 +687,15 @@ NTSTATUS vfs_not_implemented_translate_name(struct vfs_handle_struct *handle,
return NT_STATUS_NOT_IMPLEMENTED;
}
+NTSTATUS vfs_not_implemented_parent_pathname(struct vfs_handle_struct *handle,
+ TALLOC_CTX *mem_ctx,
+ const struct smb_filename *smb_fname_in,
+ struct smb_filename **parent_dir_out,
+ struct smb_filename **atname_out)
+{
+ return NT_STATUS_NOT_IMPLEMENTED;
+}
+
NTSTATUS vfs_not_implemented_fsctl(struct vfs_handle_struct *handle,
struct files_struct *fsp,
TALLOC_CTX *ctx,
@@ -1067,6 +1076,7 @@ static struct vfs_fn_pointers vfs_not_implemented_fns = {
--
Samba Shared Repository
More information about the samba-cvs
mailing list