From 295d7d026babe3cd5123d0f53adcb16868907f05 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 25 Oct 2021 12:01:58 -0700 Subject: [PATCH] s3: VFS: streams_depot. Allow unlinkat to cope with dangling symlinks. BUG: https://bugzilla.samba.org/show_bug.cgi?id=14879 Signed-off-by: Jeremy Allison Reviewed-by: Ralph Boehme --- source3/modules/vfs_streams_depot.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/source3/modules/vfs_streams_depot.c b/source3/modules/vfs_streams_depot.c index 973edeeda24..ae73ba965a5 100644 --- a/source3/modules/vfs_streams_depot.c +++ b/source3/modules/vfs_streams_depot.c @@ -823,6 +823,16 @@ static int streams_depot_unlink_internal(vfs_handle_struct *handle, ret = SMB_VFS_NEXT_LSTAT(handle, full_fname); } else { ret = SMB_VFS_NEXT_STAT(handle, full_fname); + if (ret == -1 && (errno == ENOENT || errno == ELOOP)) { + if (VALID_STAT(smb_fname->st) && + S_ISLNK(smb_fname->st.st_ex_mode)) { + /* + * Original name was a link - Could be + * trying to remove a dangling symlink. + */ + ret = SMB_VFS_NEXT_LSTAT(handle, full_fname); + } + } } if (ret == -1) { TALLOC_FREE(full_fname); -- 2.47.2