diff options
Diffstat (limited to 'source3')
-rw-r--r-- | source3/smbd/dosmode.c | 22 | ||||
-rw-r--r-- | source3/smbd/nttrans.c | 18 |
2 files changed, 21 insertions, 19 deletions
diff --git a/source3/smbd/dosmode.c b/source3/smbd/dosmode.c index 86f7807506..628f887187 100644 --- a/source3/smbd/dosmode.c +++ b/source3/smbd/dosmode.c @@ -20,6 +20,7 @@ #include "includes.h" #include "librpc/gen_ndr/ndr_xattr.h" +#include "../libcli/security/security.h" static uint32_t filter_mode_by_protocol(uint32_t mode) { @@ -855,6 +856,25 @@ NTSTATUS file_set_sparse(connection_struct *conn, uint32_t new_dosmode; NTSTATUS status; + if (!CAN_WRITE(conn)) { + DEBUG(9,("file_set_sparse: fname[%s] set[%u] " + "on readonly share[%s]\n", + smb_fname_str_dbg(fsp->fsp_name), + sparse, + lp_servicename(SNUM(conn)))); + return NT_STATUS_MEDIA_WRITE_PROTECTED; + } + + if (!(fsp->access_mask & FILE_WRITE_DATA) && + !(fsp->access_mask & FILE_WRITE_ATTRIBUTES)) { + DEBUG(9,("file_set_sparse: fname[%s] set[%u] " + "access_mask[0x%08X] - access denied\n", + smb_fname_str_dbg(fsp->fsp_name), + sparse, + fsp->access_mask)); + return NT_STATUS_ACCESS_DENIED; + } + DEBUG(10,("file_set_sparse: setting sparse bit %u on file %s\n", sparse, smb_fname_str_dbg(fsp->fsp_name))); @@ -888,7 +908,7 @@ NTSTATUS file_set_sparse(connection_struct *conn, notify_fname(conn, NOTIFY_ACTION_MODIFIED, FILE_NOTIFY_CHANGE_ATTRIBUTES, - smb_fname->base_name); + fsp->fsp_name->base_name); return NT_STATUS_OK; } diff --git a/source3/smbd/nttrans.c b/source3/smbd/nttrans.c index 55804b9035..cccb47a97f 100644 --- a/source3/smbd/nttrans.c +++ b/source3/smbd/nttrans.c @@ -2122,24 +2122,6 @@ static void call_nt_transact_ioctl(connection_struct *conn, return; } - if (!CAN_WRITE(conn)) { - DEBUG(9,("FSCTL_SET_SPARSE: fname[%s] set[%u] " - "on readonly share[%s]\n", - smb_fname_str_dbg(fsp->fsp_name), set_sparse, - lp_servicename(SNUM(conn)))); - reply_nterror(req, NT_STATUS_MEDIA_WRITE_PROTECTED); - return; - } - - if (!(fsp->access_mask & FILE_WRITE_DATA) && - !(fsp->access_mask & FILE_WRITE_ATTRIBUTES)) { - DEBUG(9,("FSCTL_SET_SPARSE: fname[%s] set[%u] " - "access_mask[0x%08X] - access denied\n", - smb_fname_str_dbg(fsp->fsp_name), set_sparse, fsp->access_mask)); - reply_nterror(req, NT_STATUS_ACCESS_DENIED); - return; - } - status = file_set_sparse(conn, fsp, set_sparse); if (!NT_STATUS_IS_OK(status)) { DEBUG(9,("FSCTL_SET_SPARSE: fname[%s] set[%u] - %s\n", |