Fix bug #7033 - SMBrmdir call always returns true, even on failure to delete a directory.
authorJeremy Allison <jra@samba.org>
Wed, 13 Jan 2010 22:36:37 +0000 (14:36 -0800)
committerKarolin Seeger <kseeger@samba.org>
Mon, 25 Jan 2010 09:59:25 +0000 (10:59 +0100)
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
105f876eb447e6839b9b19c2d264c4a168cf0cc9 from master).

Jeremy.
(cherry picked from commit fd04e3a2b74dbd31c7574355c73779626c10070e)

source3/smbd/close.c
source3/smbd/reply.c

index 05c3c709a1e7a31611d48ee9438dc843c08e1dad..fa83e16b16bfe021319b131fc6944720d70abcad 100644 (file)
@@ -924,6 +924,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
@@ -1022,9 +1023,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)));
@@ -1042,6 +1043,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;
 }
 
index b2d98bfbc0284fb31cb6efbe74f60dfdbd0e7006..b6316aac467cf545b364f08ef6c8a8edf236193d 100644 (file)
@@ -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);