[SCM] Samba Shared Repository - branch master updated
Ralph Böhme
slow at samba.org
Tue Feb 18 22:35:03 UTC 2020
The branch, master has been updated
via 9ee1320049c s3: DFS: Remove is_msdfs_link_internal() - no longer used.
via 94068b54380 s3: DFS: Change the last use of is_msdfs_link_internal() -> SMB_VFS_READ_DFS_PATHAT() inside form_junctions().
via 3c77a9e7116 s3: DFS: Replace calls to is_msdfs_link_internal() inside dfs_path_lookup() with SMB_VFS_READ_DFS_PATHAT().
via 1668c9ee15b s3: DFS: Change dfs_path_lookup() to return struct referral list and count directly.
via 1ffc52abeda s3: DFS: Parse the returned target path in dfs_path_lookup().
via 07a3cd56cdd s3: DFS: Change simple is_msdfs_link() call to use SMB_VFS_READ_DFS_PATHAT().
via 0528584482f s3: VFS: vfs_time_audit: Add read_dfs_pathat().
via 263df988831 s3: VFS: vfs_full_audit: Add read_dfs_pathat().
via 16acdc348db s3: VFS: catia: Add read_dfs_pathat().
via 9f6c01b2cd8 s3: VFS: cap: Add cap_read_dfs_pathat().
via 9e92d46b757 s3: VFS: shadow_copy2: Add shadow_copy2_read_dfs_pathat().
via 018af49b93f s3: VFS: gluster: Add vfs_gluster_read_dfs_pathat().
via e52e2135dd9 s3: VFS: ceph: Add vfswrap_ceph_read_dfs_pathat().
via 96bc3298fc0 s3: VFS: Add SMB_VFS_READ_DFS_PATHAT().
via 74b47bf578d s3: smbd: dfs: Clean up exits / talloc heirarchy in parse_msdfs_symlink().
via ed527dc1d8b s3: smbd: dfs: Make parameter names consistent.
via 4e4afc52e6f s3: smbd: dfs: Allow parse_msdfs_symlink() to be called with NULL pointers.
via a211c640878 s3: smbd: dfs: Apply some README.Coding to parse_msdfs_symlink().
via 012b812188f s3: smbd: dfs: Make parse_msdfs_symlink() external.
via 028c33e09ab s3: smbd: dfs: Move lp_msdfs_shuffle_referrals() call out of parse_msdfs_symlink().
via d22b0d90725 s3: smbd: dfs: Cleanup, reformat calls to parse_msdfs_symlink()
via 0450593e38d s3: DFS: Don't allow link deletion on a read-only share.
via b4195cd488e s3: DFS: Don't allow link creation on a read-only share.
from e2ea059e671 s3:tests: Add test for a dropbox with dir mode 0733
https://git.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit 9ee1320049cf148a2bb102bbdee4a4bcc24c0de1
Author: Jeremy Allison <jra at samba.org>
Date: Wed Feb 12 13:54:08 2020 -0800
s3: DFS: Remove is_msdfs_link_internal() - no longer used.
All DFS links are now read through the VFS and not via
symlink calls.
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): Tue Feb 18 22:34:16 UTC 2020 on sn-devel-184
commit 94068b5438013479b0426fea7f83bbd7f8f935e9
Author: Jeremy Allison <jra at samba.org>
Date: Wed Feb 12 13:52:58 2020 -0800
s3: DFS: Change the last use of is_msdfs_link_internal() -> SMB_VFS_READ_DFS_PATHAT() inside form_junctions().
is_msdfs_link_internal() is no longer used.
Signed-off-by: Jeremy Allison <jra at samba.org>
Reviewed-by: Ralph Boehme <slow at samba.org>
commit 3c77a9e7116bc3f1e3c9bf89c28a32bdb6cdffe1
Author: Jeremy Allison <jra at samba.org>
Date: Wed Feb 12 13:41:56 2020 -0800
s3: DFS: Replace calls to is_msdfs_link_internal() inside dfs_path_lookup() with SMB_VFS_READ_DFS_PATHAT().
Signed-off-by: Jeremy Allison <jra at samba.org>
Reviewed-by: Ralph Boehme <slow at samba.org>
commit 1668c9ee15b421093756ac9d709f55ce3e808791
Author: Jeremy Allison <jra at samba.org>
Date: Wed Feb 12 13:17:51 2020 -0800
s3: DFS: Change dfs_path_lookup() to return struct referral list and count directly.
Remove external parse of returned link targetpath, expose
the parsing previously added to dfs_path_lookup().
Signed-off-by: Jeremy Allison <jra at samba.org>
Reviewed-by: Ralph Boehme <slow at samba.org>
commit 1ffc52abedae9787f745795a4f502c26b4c005d1
Author: Jeremy Allison <jra at samba.org>
Date: Tue Feb 11 14:21:12 2020 -0800
s3: DFS: Parse the returned target path in dfs_path_lookup().
Currently unused, but this will ease the transition to
using SMB_VFS_READ_DFS_PATHAT().
Signed-off-by: Jeremy Allison <jra at samba.org>
Reviewed-by: Ralph Boehme <slow at samba.org>
commit 07a3cd56cddfc0e27a75ca76e556e2fdb18c3291
Author: Jeremy Allison <jra at samba.org>
Date: Tue Feb 11 13:35:53 2020 -0800
s3: DFS: Change simple is_msdfs_link() call to use SMB_VFS_READ_DFS_PATHAT().
This will need an extra dirfsp parameter in future, but this
is the easiest change for now.
Signed-off-by: Jeremy Allison <jra at samba.org>
Reviewed-by: Ralph Boehme <slow at samba.org>
commit 0528584482f798753d636675da778917f50ca845
Author: Jeremy Allison <jra at samba.org>
Date: Fri Feb 14 13:08:04 2020 -0800
s3: VFS: vfs_time_audit: Add read_dfs_pathat().
Not yet used.
Signed-off-by: Jeremy Allison <jra at samba.org>
Reviewed-by: Ralph Boehme <slow at samba.org>
commit 263df988831a40ba751b19c1715277e80095818c
Author: Jeremy Allison <jra at samba.org>
Date: Tue Feb 11 10:02:18 2020 -0800
s3: VFS: vfs_full_audit: Add read_dfs_pathat().
Not yet used.
Signed-off-by: Jeremy Allison <jra at samba.org>
Reviewed-by: Ralph Boehme <slow at samba.org>
commit 16acdc348db71a29bec93d62073ca30a4a920389
Author: Jeremy Allison <jra at samba.org>
Date: Tue Feb 11 10:02:00 2020 -0800
s3: VFS: catia: Add read_dfs_pathat().
Not yet used.
Signed-off-by: Jeremy Allison <jra at samba.org>
Reviewed-by: Ralph Boehme <slow at samba.org>
commit 9f6c01b2cd82963bfa05552aa41dfafcb0bf7637
Author: Jeremy Allison <jra at samba.org>
Date: Tue Feb 11 09:48:05 2020 -0800
s3: VFS: cap: Add cap_read_dfs_pathat().
Not yet used.
Signed-off-by: Jeremy Allison <jra at samba.org>
Reviewed-by: Ralph Boehme <slow at samba.org>
commit 9e92d46b757d6a4cdd0f956c24b30df89adf2798
Author: Jeremy Allison <jra at samba.org>
Date: Tue Jan 28 12:12:09 2020 -0800
s3: VFS: shadow_copy2: Add shadow_copy2_read_dfs_pathat().
Not yet used.
Signed-off-by: Jeremy Allison <jra at samba.org>
Reviewed-by: Ralph Boehme <slow at samba.org>
commit 018af49b93f8e9a2cbc0d40cc68b8202e5c95c9a
Author: Jeremy Allison <jra at samba.org>
Date: Tue Jan 28 10:46:43 2020 -0800
s3: VFS: gluster: Add vfs_gluster_read_dfs_pathat().
Not yet used.
Signed-off-by: Jeremy Allison <jra at samba.org>
Reviewed-by: Ralph Boehme <slow at samba.org>
commit e52e2135dd9b8bd2e65261c210e7b8d36a727396
Author: Jeremy Allison <jra at samba.org>
Date: Tue Jan 28 10:18:04 2020 -0800
s3: VFS: ceph: Add vfswrap_ceph_read_dfs_pathat().
Not yet used.
Signed-off-by: Jeremy Allison <jra at samba.org>
Reviewed-by: Ralph Boehme <slow at samba.org>
commit 96bc3298fc025d1d76fc06833fece6c62faa5e1a
Author: Jeremy Allison <jra at samba.org>
Date: Tue Jan 28 09:51:17 2020 -0800
s3: VFS: Add SMB_VFS_READ_DFS_PATHAT().
Not yet used.
Signed-off-by: Jeremy Allison <jra at samba.org>
Reviewed-by: Ralph Boehme <slow at samba.org>
commit 74b47bf578dab9ce94a9f2439fa672e51afe809e
Author: Jeremy Allison <jra at samba.org>
Date: Tue Jan 28 09:36:26 2020 -0800
s3: smbd: dfs: Clean up exits / talloc heirarchy in parse_msdfs_symlink().
Ensure on error or clean return we don't leave memory on mem_ctx.
Signed-off-by: Jeremy Allison <jra at samba.org>
Reviewed-by: Ralph Boehme <slow at samba.org>
commit ed527dc1d8bd21d942bc14677d83363144e5f46b
Author: Jeremy Allison <jra at samba.org>
Date: Tue Jan 28 09:28:30 2020 -0800
s3: smbd: dfs: Make parameter names consistent.
Initialize reflist to NULL.
Signed-off-by: Jeremy Allison <jra at samba.org>
Reviewed-by: Ralph Boehme <slow at samba.org>
commit 4e4afc52e6f63fa4058310c6b0a0314b8f73c189
Author: Jeremy Allison <jra at samba.org>
Date: Mon Jan 27 16:45:20 2020 -0800
s3: smbd: dfs: Allow parse_msdfs_symlink() to be called with NULL pointers.
In case we don't want all the data.
Signed-off-by: Jeremy Allison <jra at samba.org>
Reviewed-by: Ralph Boehme <slow at samba.org>
commit a211c640878d856e859ab2fdfbbe61036240b8eb
Author: Jeremy Allison <jra at samba.org>
Date: Mon Jan 27 16:42:11 2020 -0800
s3: smbd: dfs: Apply some README.Coding to parse_msdfs_symlink().
Signed-off-by: Jeremy Allison <jra at samba.org>
Reviewed-by: Ralph Boehme <slow at samba.org>
commit 012b812188f636d9b8cf0edee34df5d43d2ac0a8
Author: Jeremy Allison <jra at samba.org>
Date: Mon Jan 27 16:35:25 2020 -0800
s3: smbd: dfs: Make parse_msdfs_symlink() external.
So it can be called by a future new VFS call.
Signed-off-by: Jeremy Allison <jra at samba.org>
Reviewed-by: Ralph Boehme <slow at samba.org>
commit 028c33e09ab52b55f33f83e26a12498f57918334
Author: Jeremy Allison <jra at samba.org>
Date: Mon Jan 27 16:31:52 2020 -0800
s3: smbd: dfs: Move lp_msdfs_shuffle_referrals() call out of parse_msdfs_symlink().
Removes dependency on snum for what is text parsing code.
Signed-off-by: Jeremy Allison <jra at samba.org>
Reviewed-by: Ralph Boehme <slow at samba.org>
commit d22b0d907252939c2ded9d73cc67dbbf8bb57fb7
Author: Jeremy Allison <jra at samba.org>
Date: Mon Jan 27 16:29:46 2020 -0800
s3: smbd: dfs: Cleanup, reformat calls to parse_msdfs_symlink()
Make parameter easier to change.
Signed-off-by: Jeremy Allison <jra at samba.org>
Reviewed-by: Ralph Boehme <slow at samba.org>
commit 0450593e38d62fe0b925d789486517ade31fe3c6
Author: Jeremy Allison <jra at samba.org>
Date: Thu Feb 6 16:20:59 2020 -0800
s3: DFS: Don't allow link deletion on a read-only share.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14269
Signed-off-by: Jeremy Allison <jra at samba.org>
Reviewed-by: Ralph Boehme <slow at samba.org>
commit b4195cd488e1366887acfea6ae03bf4198514a15
Author: Jeremy Allison <jra at samba.org>
Date: Thu Feb 6 15:55:13 2020 -0800
s3: DFS: Don't allow link creation on a read-only share.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14269
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 | 11 ++
examples/VFS/skel_transparent.c | 16 +++
source3/include/vfs.h | 19 +++
source3/include/vfs_macros.h | 14 ++
source3/modules/vfs_cap.c | 38 ++++-
source3/modules/vfs_catia.c | 42 ++++++
source3/modules/vfs_ceph.c | 100 +++++++++++++
source3/modules/vfs_default.c | 103 ++++++++++++++
source3/modules/vfs_full_audit.c | 28 ++++
source3/modules/vfs_glusterfs.c | 98 +++++++++++++
source3/modules/vfs_not_implemented.c | 11 ++
source3/modules/vfs_shadow_copy2.c | 55 ++++++++
source3/modules/vfs_time_audit.c | 29 ++++
source3/smbd/msdfs.c | 259 ++++++++++++++++------------------
source3/smbd/proto.h | 5 +
source3/smbd/vfs.c | 16 +++
16 files changed, 704 insertions(+), 140 deletions(-)
Changeset truncated at 500 lines:
diff --git a/examples/VFS/skel_opaque.c b/examples/VFS/skel_opaque.c
index 71c34de8013..c1b5923b752 100644
--- a/examples/VFS/skel_opaque.c
+++ b/examples/VFS/skel_opaque.c
@@ -112,6 +112,16 @@ static NTSTATUS skel_create_dfs_pathat(struct vfs_handle_struct *handle,
return NT_STATUS_NOT_IMPLEMENTED;
}
+static NTSTATUS skel_read_dfs_pathat(struct vfs_handle_struct *handle,
+ TALLOC_CTX *mem_ctx,
+ struct files_struct *dirfsp,
+ const struct smb_filename *smb_fname,
+ struct referral **ppreflist,
+ size_t *preferral_count)
+{
+ return NT_STATUS_NOT_IMPLEMENTED;
+}
+
static DIR *skel_opendir(vfs_handle_struct *handle,
const struct smb_filename *smb_fname,
const char *mask,
@@ -1042,6 +1052,7 @@ static struct vfs_fn_pointers skel_opaque_fns = {
.fs_capabilities_fn = skel_fs_capabilities,
.get_dfs_referrals_fn = skel_get_dfs_referrals,
.create_dfs_pathat_fn = skel_create_dfs_pathat,
+ .read_dfs_pathat_fn = skel_read_dfs_pathat,
.snap_check_path_fn = skel_snap_check_path,
.snap_create_fn = skel_snap_create,
.snap_delete_fn = skel_snap_delete,
diff --git a/examples/VFS/skel_transparent.c b/examples/VFS/skel_transparent.c
index 4b91f64f15e..d2d05673fb4 100644
--- a/examples/VFS/skel_transparent.c
+++ b/examples/VFS/skel_transparent.c
@@ -113,6 +113,21 @@ static NTSTATUS skel_create_dfs_pathat(struct vfs_handle_struct *handle,
referral_count);
}
+static NTSTATUS skel_read_dfs_pathat(struct vfs_handle_struct *handle,
+ TALLOC_CTX *mem_ctx,
+ struct files_struct *dirfsp,
+ const struct smb_filename *smb_fname,
+ struct referral **ppreflist,
+ size_t *preferral_count)
+{
+ return SMB_VFS_NEXT_READ_DFS_PATHAT(handle,
+ mem_ctx,
+ dirfsp,
+ smb_fname,
+ ppreflist,
+ preferral_count);
+}
+
static DIR *skel_opendir(vfs_handle_struct *handle,
const struct smb_filename *smb_fname,
const char *mask,
@@ -1344,6 +1359,7 @@ static struct vfs_fn_pointers skel_transparent_fns = {
.fs_capabilities_fn = skel_fs_capabilities,
.get_dfs_referrals_fn = skel_get_dfs_referrals,
.create_dfs_pathat_fn = skel_create_dfs_pathat,
+ .read_dfs_pathat_fn = skel_read_dfs_pathat,
.snap_check_path_fn = skel_snap_check_path,
.snap_create_fn = skel_snap_create,
.snap_delete_fn = skel_snap_delete,
diff --git a/source3/include/vfs.h b/source3/include/vfs.h
index 656fad8b5ee..fec38f20644 100644
--- a/source3/include/vfs.h
+++ b/source3/include/vfs.h
@@ -289,6 +289,7 @@
/* Version 42 - Remove struct write_cache *wcp from files_struct */
/* Version 42 - SMB_VFS_NTIMES() receives null times based on UTIMES_OMIT */
/* Version 42 - Add SMB_VFS_CREATE_DFS_PATHAT() */
+/* Version 42 - Add SMB_VFS_READ_DFS_PATHAT() */
#define SMB_VFS_INTERFACE_VERSION 42
@@ -716,6 +717,12 @@ struct vfs_fn_pointers {
const struct smb_filename *smb_fname,
const struct referral *reflist,
size_t referral_count);
+ NTSTATUS (*read_dfs_pathat_fn)(struct vfs_handle_struct *handle,
+ TALLOC_CTX *mem_ctx,
+ struct files_struct *dirfsp,
+ const struct smb_filename *smb_fname,
+ struct referral **ppreflist,
+ size_t *preferral_count);
/* Directory operations */
@@ -1224,6 +1231,12 @@ NTSTATUS smb_vfs_call_create_dfs_pathat(struct vfs_handle_struct *handle,
const struct smb_filename *smb_fname,
const struct referral *reflist,
size_t referral_count);
+NTSTATUS smb_vfs_call_read_dfs_pathat(struct vfs_handle_struct *handle,
+ TALLOC_CTX *mem_ctx,
+ struct files_struct *dirfsp,
+ const struct smb_filename *smb_fname,
+ struct referral **ppreflist,
+ size_t *preferral_count);
DIR *smb_vfs_call_opendir(struct vfs_handle_struct *handle,
const struct smb_filename *smb_fname,
const char *mask,
@@ -1666,6 +1679,12 @@ NTSTATUS vfs_not_implemented_create_dfs_pathat(struct vfs_handle_struct *handle,
const struct smb_filename *smb_fname,
const struct referral *reflist,
size_t referral_count);
+NTSTATUS vfs_not_implemented_read_dfs_pathat(struct vfs_handle_struct *handle,
+ TALLOC_CTX *mem_ctx,
+ struct files_struct *dirfsp,
+ const struct smb_filename *smb_fname,
+ struct referral **ppreflist,
+ size_t *preferral_count);
DIR *vfs_not_implemented_opendir(vfs_handle_struct *handle,
const struct smb_filename *smb_fname,
const char *mask,
diff --git a/source3/include/vfs_macros.h b/source3/include/vfs_macros.h
index d4ccb8f5c73..112169ab83b 100644
--- a/source3/include/vfs_macros.h
+++ b/source3/include/vfs_macros.h
@@ -90,6 +90,20 @@
(smb_fname), \
(reflist), \
(count))
+#define SMB_VFS_READ_DFS_PATHAT(conn, mem_ctx, dirfsp, smb_fname, ppreflist, pcount) \
+ smb_vfs_call_read_dfs_pathat((conn)->vfs_handles, \
+ (mem_ctx), \
+ (dirfsp), \
+ (smb_fname), \
+ (ppreflist), \
+ (pcount))
+#define SMB_VFS_NEXT_READ_DFS_PATHAT(handle, mem_ctx, dirfsp, smb_fname, ppreflist, pcount) \
+ smb_vfs_call_read_dfs_pathat((handle)->next, \
+ (mem_ctx), \
+ (dirfsp), \
+ (smb_fname), \
+ (ppreflist), \
+ (pcount))
/* Directory operations */
#define SMB_VFS_OPENDIR(conn, smb_fname, mask, attr) \
diff --git a/source3/modules/vfs_cap.c b/source3/modules/vfs_cap.c
index bc6daeccca7..e67cb750e0f 100644
--- a/source3/modules/vfs_cap.c
+++ b/source3/modules/vfs_cap.c
@@ -1008,6 +1008,41 @@ static NTSTATUS cap_create_dfs_pathat(vfs_handle_struct *handle,
return status;
}
+static NTSTATUS cap_read_dfs_pathat(struct vfs_handle_struct *handle,
+ TALLOC_CTX *mem_ctx,
+ struct files_struct *dirfsp,
+ const struct smb_filename *smb_fname,
+ struct referral **ppreflist,
+ size_t *preferral_count)
+{
+ char *cappath = capencode(talloc_tos(), smb_fname->base_name);
+ struct smb_filename *cap_smb_fname = NULL;
+ NTSTATUS status;
+
+ if (cappath == NULL) {
+ return NT_STATUS_NO_MEMORY;
+ }
+ cap_smb_fname = synthetic_smb_fname(talloc_tos(),
+ cappath,
+ NULL,
+ NULL,
+ smb_fname->flags);
+ if (cap_smb_fname == NULL) {
+ TALLOC_FREE(cappath);
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ status = SMB_VFS_NEXT_READ_DFS_PATHAT(handle,
+ mem_ctx,
+ dirfsp,
+ cap_smb_fname,
+ ppreflist,
+ preferral_count);
+ TALLOC_FREE(cappath);
+ TALLOC_FREE(cap_smb_fname);
+ return status;
+}
+
static struct vfs_fn_pointers vfs_cap_fns = {
.disk_free_fn = cap_disk_free,
.get_quota_fn = cap_get_quota,
@@ -1040,7 +1075,8 @@ static struct vfs_fn_pointers vfs_cap_fns = {
.fremovexattr_fn = cap_fremovexattr,
.setxattr_fn = cap_setxattr,
.fsetxattr_fn = cap_fsetxattr,
- .create_dfs_pathat_fn = cap_create_dfs_pathat
+ .create_dfs_pathat_fn = cap_create_dfs_pathat,
+ .read_dfs_pathat_fn = cap_read_dfs_pathat
};
static_decl_vfs;
diff --git a/source3/modules/vfs_catia.c b/source3/modules/vfs_catia.c
index 1739fd77d5b..5bb55cf89f6 100644
--- a/source3/modules/vfs_catia.c
+++ b/source3/modules/vfs_catia.c
@@ -2404,6 +2404,47 @@ static NTSTATUS catia_create_dfs_pathat(struct vfs_handle_struct *handle,
return status;
}
+static NTSTATUS catia_read_dfs_pathat(struct vfs_handle_struct *handle,
+ TALLOC_CTX *mem_ctx,
+ struct files_struct *dirfsp,
+ const struct smb_filename *smb_fname,
+ struct referral **ppreflist,
+ size_t *preferral_count)
+{
+ char *mapped_name = NULL;
+ const char *path = smb_fname->base_name;
+ struct smb_filename *mapped_smb_fname = NULL;
+ NTSTATUS status;
+
+ status = catia_string_replace_allocate(handle->conn,
+ path,
+ &mapped_name,
+ vfs_translate_to_unix);
+ if (!NT_STATUS_IS_OK(status)) {
+ errno = map_errno_from_nt_status(status);
+ return status;
+ }
+ mapped_smb_fname = synthetic_smb_fname(talloc_tos(),
+ mapped_name,
+ NULL,
+ &smb_fname->st,
+ smb_fname->flags);
+ if (mapped_smb_fname == NULL) {
+ TALLOC_FREE(mapped_name);
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ status = SMB_VFS_NEXT_READ_DFS_PATHAT(handle,
+ mem_ctx,
+ dirfsp,
+ mapped_smb_fname,
+ ppreflist,
+ preferral_count);
+ TALLOC_FREE(mapped_name);
+ TALLOC_FREE(mapped_smb_fname);
+ return status;
+}
+
static struct vfs_fn_pointers vfs_catia_fns = {
.connect_fn = catia_connect,
@@ -2455,6 +2496,7 @@ static struct vfs_fn_pointers vfs_catia_fns = {
.get_compression_fn = catia_get_compression,
.set_compression_fn = catia_set_compression,
.create_dfs_pathat_fn = catia_create_dfs_pathat,
+ .read_dfs_pathat_fn = catia_read_dfs_pathat,
/* NT ACL operations. */
.get_nt_acl_fn = catia_get_nt_acl,
diff --git a/source3/modules/vfs_ceph.c b/source3/modules/vfs_ceph.c
index 3526cbe0f6d..76393a84152 100644
--- a/source3/modules/vfs_ceph.c
+++ b/source3/modules/vfs_ceph.c
@@ -1331,6 +1331,105 @@ static NTSTATUS cephwrap_create_dfs_pathat(struct vfs_handle_struct *handle,
return status;
}
+/*
+ * Read and return the contents of a DFS redirect given a
+ * pathname. A caller can pass in NULL for ppreflist and
+ * preferral_count but still determine if this was a
+ * DFS redirect point by getting NT_STATUS_OK back
+ * without incurring the overhead of reading and parsing
+ * the referral contents.
+ */
+
+static NTSTATUS cephwrap_read_dfs_pathat(struct vfs_handle_struct *handle,
+ TALLOC_CTX *mem_ctx,
+ struct files_struct *dirfsp,
+ const struct smb_filename *smb_fname,
+ struct referral **ppreflist,
+ size_t *preferral_count)
+{
+ NTSTATUS status = NT_STATUS_NO_MEMORY;
+ size_t bufsize;
+ char *link_target = NULL;
+ int referral_len;
+ bool ok;
+#if defined(HAVE_BROKEN_READLINK)
+ char link_target_buf[PATH_MAX];
+#else
+ char link_target_buf[7];
+#endif
+
+ SMB_ASSERT(dirfsp == dirfsp->conn->cwd_fsp);
+
+ if (ppreflist == NULL && preferral_count == NULL) {
+ /*
+ * We're only checking if this is a DFS
+ * redirect. We don't need to return data.
+ */
+ bufsize = sizeof(link_target_buf);
+ link_target = link_target_buf;
+ } else {
+ bufsize = PATH_MAX;
+ link_target = talloc_array(mem_ctx, char, bufsize);
+ if (!link_target) {
+ goto err;
+ }
+ }
+
+ referral_len = ceph_readlink(handle->data,
+ smb_fname->base_name,
+ link_target,
+ bufsize - 1);
+ if (referral_len < 0) {
+ /* ceph errors are -errno. */
+ if (-referral_len == EINVAL) {
+ DBG_INFO("%s is not a link.\n",
+ smb_fname->base_name);
+ status = NT_STATUS_OBJECT_TYPE_MISMATCH;
+ } else {
+ status = map_nt_error_from_unix(-referral_len);
+ DBG_ERR("Error reading "
+ "msdfs link %s: %s\n",
+ smb_fname->base_name,
+ strerror(errno));
+ }
+ goto err;
+ }
+ link_target[referral_len] = '\0';
+
+ DBG_INFO("%s -> %s\n",
+ smb_fname->base_name,
+ link_target);
+
+ if (!strnequal(link_target, "msdfs:", 6)) {
+ status = NT_STATUS_OBJECT_TYPE_MISMATCH;
+ goto err;
+ }
+
+ if (ppreflist == NULL && preferral_count == NULL) {
+ /* Early return for checking if this is a DFS link. */
+ return NT_STATUS_OK;
+ }
+
+ ok = parse_msdfs_symlink(mem_ctx,
+ lp_msdfs_shuffle_referrals(SNUM(handle->conn)),
+ link_target,
+ ppreflist,
+ preferral_count);
+
+ if (ok) {
+ status = NT_STATUS_OK;
+ } else {
+ status = NT_STATUS_NO_MEMORY;
+ }
+
+ err:
+
+ if (link_target != link_target_buf) {
+ TALLOC_FREE(link_target);
+ }
+ return status;
+}
+
static struct vfs_fn_pointers ceph_fns = {
/* Disk operations */
@@ -1356,6 +1455,7 @@ static struct vfs_fn_pointers ceph_fns = {
/* File operations */
.create_dfs_pathat_fn = cephwrap_create_dfs_pathat,
+ .read_dfs_pathat_fn = cephwrap_read_dfs_pathat,
.open_fn = cephwrap_open,
.close_fn = cephwrap_close,
.pread_fn = cephwrap_pread,
diff --git a/source3/modules/vfs_default.c b/source3/modules/vfs_default.c
index f0c92f873e4..37b59d8c3c0 100644
--- a/source3/modules/vfs_default.c
+++ b/source3/modules/vfs_default.c
@@ -404,6 +404,108 @@ static NTSTATUS vfswrap_create_dfs_pathat(struct vfs_handle_struct *handle,
return status;
}
+/*
+ * Read and return the contents of a DFS redirect given a
+ * pathname. A caller can pass in NULL for ppreflist and
+ * preferral_count but still determine if this was a
+ * DFS redirect point by getting NT_STATUS_OK back
+ * without incurring the overhead of reading and parsing
+ * the referral contents.
+ */
+
+static NTSTATUS vfswrap_read_dfs_pathat(struct vfs_handle_struct *handle,
+ TALLOC_CTX *mem_ctx,
+ struct files_struct *dirfsp,
+ const struct smb_filename *smb_fname,
+ struct referral **ppreflist,
+ size_t *preferral_count)
+{
+ NTSTATUS status = NT_STATUS_NO_MEMORY;
+ size_t bufsize;
+ char *link_target = NULL;
+ int referral_len;
+ bool ok;
+#if defined(HAVE_BROKEN_READLINK)
+ char link_target_buf[PATH_MAX];
+#else
+ char link_target_buf[7];
+#endif
+
+ SMB_ASSERT(dirfsp == dirfsp->conn->cwd_fsp);
+
+ if (ppreflist == NULL && preferral_count == NULL) {
+ /*
+ * We're only checking if this is a DFS
+ * redirect. We don't need to return data.
+ */
+ bufsize = sizeof(link_target_buf);
+ link_target = link_target_buf;
+ } else {
+ bufsize = PATH_MAX;
+ link_target = talloc_array(mem_ctx, char, bufsize);
+ if (!link_target) {
+ goto err;
+ }
+ }
+
+ referral_len = readlinkat(dirfsp->fh->fd,
+ smb_fname->base_name,
+ link_target,
+ bufsize - 1);
+ if (referral_len == -1) {
+ if (errno == EINVAL) {
+ /*
+ * If the path isn't a link, readlinkat
+ * returns EINVAL. Allow the caller to
+ * detect this.
+ */
+ DBG_INFO("%s is not a link.\n", smb_fname->base_name);
+ status = NT_STATUS_OBJECT_TYPE_MISMATCH;
+ } else {
+ status = map_nt_error_from_unix(errno);
+ DBG_ERR("Error reading "
+ "msdfs link %s: %s\n",
+ smb_fname->base_name,
+ strerror(errno));
+ }
+ goto err;
+ }
+ link_target[referral_len] = '\0';
+
+ DBG_INFO("%s -> %s\n",
+ smb_fname->base_name,
+ link_target);
+
+ if (!strnequal(link_target, "msdfs:", 6)) {
+ status = NT_STATUS_OBJECT_TYPE_MISMATCH;
+ goto err;
+ }
+
+ if (ppreflist == NULL && preferral_count == NULL) {
+ /* Early return for checking if this is a DFS link. */
+ return NT_STATUS_OK;
+ }
+
+ ok = parse_msdfs_symlink(mem_ctx,
+ lp_msdfs_shuffle_referrals(SNUM(handle->conn)),
+ link_target,
+ ppreflist,
+ preferral_count);
+
+ if (ok) {
+ status = NT_STATUS_OK;
+ } else {
+ status = NT_STATUS_NO_MEMORY;
+ }
+
+ err:
+
+ if (link_target != link_target_buf) {
+ TALLOC_FREE(link_target);
+ }
+ return status;
+}
+
static NTSTATUS vfswrap_snap_check_path(struct vfs_handle_struct *handle,
TALLOC_CTX *mem_ctx,
const char *service_path,
@@ -3517,6 +3619,7 @@ static struct vfs_fn_pointers vfs_default_fns = {
.fs_capabilities_fn = vfswrap_fs_capabilities,
.get_dfs_referrals_fn = vfswrap_get_dfs_referrals,
.create_dfs_pathat_fn = vfswrap_create_dfs_pathat,
+ .read_dfs_pathat_fn = vfswrap_read_dfs_pathat,
.snap_check_path_fn = vfswrap_snap_check_path,
.snap_create_fn = vfswrap_snap_create,
.snap_delete_fn = vfswrap_snap_delete,
diff --git a/source3/modules/vfs_full_audit.c b/source3/modules/vfs_full_audit.c
index 1e4a641d0a4..5c8267dea9f 100644
--- a/source3/modules/vfs_full_audit.c
+++ b/source3/modules/vfs_full_audit.c
@@ -102,6 +102,7 @@ typedef enum _vfs_op_type {
SMB_VFS_OP_FS_CAPABILITIES,
--
Samba Shared Repository
More information about the samba-cvs
mailing list