From f10027a40f54781b41a8e57f911bfe747f97fe7f Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 13 Jan 2010 14:36:37 -0800 Subject: [PATCH] Fix bug #7033 - SMBrmdir call always returns true, even on failure to delete a directory. There is a codepath missing to propagate back error returns from the rmdir POSIX call inside close_directory when delete on close is set. This means doing an rmdir on a Windows command line will always report success, even when the directory was not deleted. This fix adds that codepath back into Samba. (This fix contains both ce8dcbe91ba0252140a0e4f84ea4bc746259ddde and 33ee8b5a4e390f9aa43cceeec137c0ed82171340 from master). Jeremy. --- source3/smbd/close.c | 8 ++++++-- source3/smbd/reply.c | 8 ++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/source3/smbd/close.c b/source3/smbd/close.c index e81a2fd..ca1ac47 100644 --- a/source3/smbd/close.c +++ b/source3/smbd/close.c @@ -926,6 +926,7 @@ static NTSTATUS close_directory(struct smb_request *req, files_struct *fsp, struct share_mode_lock *lck = NULL; bool delete_dir = False; NTSTATUS status = NT_STATUS_OK; + NTSTATUS status1 = NT_STATUS_OK; /* * NT can set delete_on_close of the last open @@ -1025,9 +1026,9 @@ static NTSTATUS close_directory(struct smb_request *req, files_struct *fsp, fsp, NT_STATUS_OK); } - status = fd_close(fsp); + status1 = fd_close(fsp); - if (!NT_STATUS_IS_OK(status)) { + if (!NT_STATUS_IS_OK(status1)) { DEBUG(0, ("Could not close dir! fname=%s, fd=%d, err=%d=%s\n", fsp_str_dbg(fsp), fsp->fh->fd, errno, strerror(errno))); @@ -1045,6 +1046,9 @@ static NTSTATUS close_directory(struct smb_request *req, files_struct *fsp, out: TALLOC_FREE(lck); + if (NT_STATUS_IS_OK(status) && !NT_STATUS_IS_OK(status1)) { + status = status1; + } return status; } diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c index b2d98bf..b6316aa 100644 --- a/source3/smbd/reply.c +++ b/source3/smbd/reply.c @@ -5368,8 +5368,12 @@ void reply_rmdir(struct smb_request *req) goto out; } - close_file(req, fsp, NORMAL_CLOSE); - reply_outbuf(req, 0, 0); + status = close_file(req, fsp, NORMAL_CLOSE); + if (!NT_STATUS_IS_OK(status)) { + reply_nterror(req, status); + } else { + reply_outbuf(req, 0, 0); + } dptr_closepath(sconn, smb_dname->base_name, req->smbpid); -- 1.5.4.3