From: Jeremy Allison Date: Thu, 3 Jun 2021 18:15:50 +0000 (-0700) Subject: s3: smbd: Allow rmdir_internals() to cope with veto'ed symlinks. X-Git-Tag: tevent-0.11.0~576 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=bf36c88516a96a224b0abdd3ca831f895d877b7b;p=thirdparty%2Fsamba.git s3: smbd: Allow rmdir_internals() to cope with veto'ed symlinks. We are only dealing with VETO'ed objects here. If it's a symlink, just delete the link without caring what it is pointing to as this operation is safe. Signed-off-by: Jeremy Allison Reviewed-by: Ralph Boehme --- diff --git a/source3/smbd/close.c b/source3/smbd/close.c index 0113bed781c..9b53c4a088c 100644 --- a/source3/smbd/close.c +++ b/source3/smbd/close.c @@ -1125,25 +1125,44 @@ static NTSTATUS rmdir_internals(TALLOC_CTX *ctx, struct files_struct *fsp) goto err_break; } - status = synthetic_pathref(talloc_tos(), - dirfsp, - dname, - NULL, - &smb_dname_full->st, - smb_dname->twrp, - smb_dname->flags, - &direntry_fname); - if (!NT_STATUS_IS_OK(status)) { - errno = map_errno_from_nt_status(status); - goto err_break; - } + /* + * We are only dealing with VETO'ed objects + * here. If it's a symlink, just delete the + * link without caring what it is pointing + * to. + */ + if (S_ISLNK(smb_dname_full->st.st_ex_mode)) { + direntry_fname = synthetic_smb_fname(talloc_tos(), + dname, + NULL, + &smb_dname_full->st, + smb_dname->twrp, + smb_dname->flags); + if (direntry_fname == NULL) { + errno = ENOMEM; + goto err_break; + } + } else { + status = synthetic_pathref(talloc_tos(), + dirfsp, + dname, + NULL, + &smb_dname_full->st, + smb_dname->twrp, + smb_dname->flags, + &direntry_fname); + if (!NT_STATUS_IS_OK(status)) { + errno = map_errno_from_nt_status(status); + goto err_break; + } - if (!is_visible_fsp(direntry_fname->fsp, false)) { - TALLOC_FREE(fullname); - TALLOC_FREE(smb_dname_full); - TALLOC_FREE(talloced); - TALLOC_FREE(direntry_fname); - continue; + if (!is_visible_fsp(direntry_fname->fsp, false)) { + TALLOC_FREE(fullname); + TALLOC_FREE(smb_dname_full); + TALLOC_FREE(talloced); + TALLOC_FREE(direntry_fname); + continue; + } } unlink_flags = 0;