Skip to content

Commit

Permalink
s3: smbd: Fix SMB2-FLUSH against directories.
Browse files Browse the repository at this point in the history
Directories opened with either FILE_ADD_FILE or
FILE_ADD_SUBDIRECTORY can be flushed even if
they're not writable in the conventional sense.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=13428

Signed-off-by: Jeremy Allison <[email protected]>
Reviewed-by: Ralph Boehme <[email protected]>
  • Loading branch information
jrasamba committed May 17, 2018
1 parent 48f7280 commit 42aadf4
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions source3/smbd/smb2_flush.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "smbd/globals.h"
#include "../libcli/smb/smb_common.h"
#include "../lib/util/tevent_ntstatus.h"
#include "libcli/security/security.h"

#undef DBGC_CLASS
#define DBGC_CLASS DBGC_SMB2
Expand Down Expand Up @@ -147,8 +148,29 @@ static struct tevent_req *smbd_smb2_flush_send(TALLOC_CTX *mem_ctx,
}

if (!CHECK_WRITE(fsp)) {
tevent_req_nterror(req, NT_STATUS_ACCESS_DENIED);
return tevent_req_post(req, ev);
bool allow_dir_flush = false;
uint32_t flush_access = FILE_ADD_FILE | FILE_ADD_SUBDIRECTORY;

if (!fsp->is_directory) {
tevent_req_nterror(req, NT_STATUS_ACCESS_DENIED);
return tevent_req_post(req, ev);
}

/*
* Directories are not writable in the conventional
* sense, but if opened with *either*
* FILE_ADD_FILE or FILE_ADD_SUBDIRECTORY
* they can be flushed.
*/

if ((fsp->access_mask & flush_access) != 0) {
allow_dir_flush = true;
}

if (allow_dir_flush == false) {
tevent_req_nterror(req, NT_STATUS_ACCESS_DENIED);
return tevent_req_post(req, ev);
}
}

if (fsp->fh->fd == -1) {
Expand Down

0 comments on commit 42aadf4

Please sign in to comment.