From: Stefan Metzmacher Date: Wed, 23 Dec 2020 11:10:37 +0000 (+0100) Subject: s3:smbd: allow close_file() with a non-fsa fsp for {SHUTDOWN,ERROR}_CLOSE X-Git-Tag: samba-4.14.0rc1~56 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=9c277b27dec568677c0b407497da6eb95ae7cb8d;p=thirdparty%2Fsamba.git s3:smbd: allow close_file() with a non-fsa fsp for {SHUTDOWN,ERROR}_CLOSE Such an fsp was typically created via create_internal_fsp() and opened via fd_openat() without going through SMB_VFS_CREATE_FILE(), so they should be closed via fd_close(). Signed-off-by: Stefan Metzmacher Reviewed-by: Volker Lendecke Reviewed-by: Ralph Boehme --- diff --git a/source3/smbd/close.c b/source3/smbd/close.c index 83b75677d92..97d13473082 100644 --- a/source3/smbd/close.c +++ b/source3/smbd/close.c @@ -1337,15 +1337,28 @@ NTSTATUS close_file(struct smb_request *req, files_struct *fsp, } } - if (fsp->fsp_flags.is_directory) { - status = close_directory(req, fsp, close_type); - } else if (fsp->fake_file_handle != NULL) { + if (fsp->fake_file_handle != NULL) { status = close_fake_file(req, fsp); } else if (fsp->print_file != NULL) { /* FIXME: return spool errors */ print_spool_end(fsp, close_type); file_free(req, fsp); status = NT_STATUS_OK; + } else if (!fsp->fsp_flags.is_fsa) { + if (close_type == NORMAL_CLOSE) { + DBG_ERR("unexpected NORMAL_CLOSE for [%s] " + "is_fsa[%u] is_pathref[%u] is_directory[%u]\n", + fsp_str_dbg(fsp), + fsp->fsp_flags.is_fsa, + fsp->fsp_flags.is_pathref, + fsp->fsp_flags.is_directory); + } + SMB_ASSERT(close_type != NORMAL_CLOSE); + fd_close(fsp); + file_free(req, fsp); + status = NT_STATUS_OK; + } else if (fsp->fsp_flags.is_directory) { + status = close_directory(req, fsp, close_type); } else { status = close_normal_file(req, fsp, close_type); }